CVE-2017-16894 in laravel

LogPulse has a published detection rule for this CVE: it raises a notable when someone tries to exploit it.

What the vulnerability is

In Laravel framework through 5.5.21, remote attackers can obtain sensitive information (such as externally usable passwords) via a direct request for the /.env URI. NOTE: this CVE is only about Laravel framework's writeNewEnvironmentFileWith function in src/Illuminate/Foundation/Console/KeyGenerateCommand.php, which uses file_put_contents without restricting the .env permissions. The .env filename is not used exclusively by Laravel framework.

Affected software: laravel

Scores

What LogPulse has for it

How to mitigate it

Point the web root at public/ and rotate the secrets in .env

Change a setting. When the web server serves the project folder instead of public/, anyone can download .env with database passwords, APP_KEY and API keys. Serving only public/ closes it; leaked secrets must be rotated.

Applies to: Laravel and other frameworks that keep secrets in a .env file in the project root.

  1. Request https://<site>/.env from outside; a 200 with key=value lines means it is exposed.
  2. Set the document root of the virtual host to the public/ folder of the Laravel project (nginx root, Apache DocumentRoot) and reload the web server.
  3. Add a deny rule for dot files (location ~ /\. { deny all; } in nginx, or a FilesMatch block in Apache).
  4. Rotate everything that was in .env: APP_KEY, database and mail passwords, cloud and API keys.

Sources:

Source data: NIST NVD, CISA KEV and FIRST EPSS. LogPulse processes new CVEs every hour.

We build every detection with great care, but no two environments are the same. Log sources, parsing and configuration differ, so test a detection in your own environment before you rely on it.

Start free with LogPulse