PHP2ShellAttacks began 17 Oct. Fixed builds shipped 21–22 Oct. Check your exposure
Common · Laravel and others

Exposed .env files and debug mode

Config files and debug pages can hand over passwords and keys. In Laravel, a debug page left on in production was exploitable for remote code execution (CVE-2021-3129).

CVE-2021-3129

Laravel debug-mode flaw that allowed remote code execution

NVD

Why it matters to you

A `.env` file holds database passwords, API keys and the app key. If the web server is set up so that file can be downloaded, everything in it is exposed. Debug pages show the same secrets in a friendlier format.

Check it yourself

  1. 01On your own site, open yourdomain.com/.env and yourdomain.com/.git/config. You should get a 403 or 404, not a file.
  2. 02Confirm debug is off in production: APP_DEBUG=false in Laravel, WP_DEBUG off in WordPress.
  3. 03Confirm the web server’s document root is the public folder, not the project root.

Fix it

  1. 01Turn debug off in production.
  2. 02Point the document root at the public folder and block dotfiles in the web server configuration.
  3. 03If a file was exposed, rotate every secret in it: database password, API keys and the app key.
  4. 04Delete old backups, archives and .git folders from the web root.

How PatchRig helps

PatchRig checks for exposed files and debug settings, fixes the server configuration on a copy, and rotates secrets if anything was exposed.

Sources

Related guides