Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Exposed wp-config backups and install scripts: find and fix

OPS-167High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

WordPress keeps its database host, name, user, password and security keys in wp-config.php. The server runs this file as PHP, so visitors only see a blank page. But if someone copies it to wp-config.php.bak, wp-config.php~, wp-config.old, wp-config.txt or wp-config.php.save, the server no longer treats it as PHP. It sends the raw text to anyone who asks for it.

Why it costs you leads or sales

How a leftover backup becomes a breach
  1. Backup copy savedwp-config.php.bak left in web root
  2. File is publicServed as plain text
  3. Credentials readDB password and keys exposed
  4. Data accessedLeads and orders at risk

The break is the public copy of the config file. Everything after it is at risk.

How to check if your site has it

Check common file names (replace example.com)bash
for f in wp-config.php.bak wp-config.php~ wp-config.old wp-config.txt wp-config.php.save wp-config.php.orig wp-config.bak install.php setup-config.php installer.php; do
  code=$(curl -s -o /dev/null -w "%{http_code}" "https://example.com/$f")
  echo "$code  $f"
done
List suspicious files on the serverbash
cd /path/to/site
ls -la wp-config* 
find . -maxdepth 2 \( -iname '*install*.php' -o -iname '*installer*' -o -iname '*.bak' -o -iname '*.old' -o -iname '*.orig' -o -iname '*~' \) -not -path './wp-content/plugins/*'

How to fix it

Remove the files and secure your credentials
  1. Delete the exposed files

    Remove every backup copy and leftover installer from the web root. Keep backups in a folder above the web root or in off-site storage, never in a public folder.

  2. Assume the secrets leaked

    If a file was reachable, even briefly, change the database password, then update DB_PASSWORD in the real wp-config.php. Replace the keys and salts with new ones from the official WordPress secret-key generator at api.wordpress.org/secret-key/1.1/salt/. This logs everyone out.

  3. Check for signs of misuse

    Review admin users, recently changed files and unknown plugins. Run a malware scan with your security plugin or host tools.

  4. Block these file types at the server

    Add a rule so backup-style names are never served, even if one appears again. See the server snippets below.

  5. Fix the cause

    Stop editors and deploy scripts writing copies into the web root. Remove installer files as the last step of any migration.

Block access by platform
  1. Delete files via SFTP or your host's file manager

    Remove wp-config backups and installer files from the site root and subfolders. Migration plugins such as Duplicator leave installer files; check the plugin's cleanup option in its admin screen.

  2. Move wp-config.php up one level if your host allows

    WordPress will find wp-config.php one folder above the web root, which keeps it out of public reach.

Apache (.htaccess): block backup-style fileshtaccess
<FilesMatch "(^wp-config.*\.(bak|old|orig|save|txt|swp|zip)$|~$|^(install|installer|setup-config)\.php$)">
  Require all denied
</FilesMatch>
<Files wp-config.php>
  Require all denied
</Files>
Nginx: block backup-style filesnginx
location ~* /wp-config.*\.(bak|old|orig|save|txt|swp|zip)$ {
    deny all;
}
location ~ ~$ {
    deny all;
}
location = /wp-config.php {
    deny all;
}

How to confirm it's fixed

Confirmation checks
  • Re-run the curl loop: every file name returns 403 or 404, not 200
  • No wp-config backups or installer files remain when you list the server folders
  • The site, login and your lead forms still work after the new rules
  • The database password and secret keys have been changed if a file was ever reachable
  • Admin users and recent file changes look normal

How to prevent it happening again

Habits that stop it
  • Never save copies of config files in the web root; edit a copy elsewhere
  • Store backups off-site or outside the public folder
  • Delete installers and migration files as the last step of every move
  • Keep the server deny rules in place permanently
  • Turn off editor backup files (for example the tilde copies some editors create) on deploy machines
  • Repeat the file-name check after every migration, redesign or host change

How FunnelGuard handles this

Questions people ask

Why is my wp-config.php.bak file a security risk?

A .bak file is not run as PHP, so the server sends its contents as plain text. Anyone who guesses the name can read your database password and secret keys. Delete it and change the exposed credentials.

How do I check if my wp-config backup is publicly accessible?

Open https://yoursite.com/wp-config.php.bak and similar names in a browser, or run a curl loop. A 200 response showing readable code means it is exposed. A 403 or 404 means it is not reachable.

What should I do if my wp-config backup was exposed?

Delete the file, then change your database password and update it in the real wp-config.php. Replace the keys and salts, review admin users and recent file changes, and run a malware scan.

Is wp-config.php itself safe to leave in the web root?

Usually yes, because the server runs it as PHP and shows nothing. It is safer to block direct requests to it or move it one folder above the web root. The danger is renamed copies the server serves as text.

Should I delete install.php after installing WordPress?

Core's wp-admin/install.php is part of WordPress and is safe on a finished site. Delete extra installer files left by migration plugins or manual builds, such as installer.php or setup scripts in the site root.

How do I block access to backup files in Apache or Nginx?

In Apache, add a FilesMatch rule with Require all denied for names like wp-config.php.bak. In Nginx, add a location block using deny all. Test afterwards to confirm a 403 response.

Does FunnelGuard detect exposed wp-config backups?

No. FunnelGuard does not check for this yet, though it could be added later. It monitors your funnels, tracking and lead delivery, so use the manual file check or a security scanner for this issue.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: site safety (Stage 26, daily): wp-config.php backups (verified sites).

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.