Skip to main content
MediumSupply chainOWASP A05:2021CWE-200

How to fix: PHP composer.json or composer.lock Exposed

A composer.json or composer.lock file was found publicly accessible. PHP Composer dependency files reveal exact package versions including all transitive dependencies.

Why it matters

Exposed composer.lock allows attackers to identify vulnerable PHP packages (CVEs in Laravel, Symfony, Doctrine, etc.) and target accordingly. Combined with PHP version from Server or X-Powered-By headers, this provides a complete attack surface map.

Composer files should be in the project root above the web root. If the webroot is set to the project root rather than public/ or web/, all project files become accessible.

How to fix it

  1. 1Set your web server document root to the public/ or web/ directory, not the project root.
  2. 2In Nginx: root /var/www/myapp/public; (not /var/www/myapp/)
  3. 3Block access to composer.json and composer.lock at the web server level.
  4. 4In Laravel: verify document root points to the public/ folder.

Code examples

Nginx correct document root

nginx
server {
  root /var/www/myapp/public; # Not /var/www/myapp/
  
  # Block sensitive files as defense-in-depth
  location ~* /(composer\.(json|lock)|Makefile|\.env) {
    deny all;
    return 404;
  }
}

References

Detected automatically by VulnRadar. The check id is supply-chain-composer-json-exposed, stable across every scan so you can filter or diff on it.

See every supply chain check

Questions

How severe is PHP composer.json or composer.lock Exposed?
VulnRadar rates this medium severity in the supply chain category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id supply-chain-composer-json-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does PHP composer.json or composer.lock Exposed map to?
It maps to CWE-200. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for php composer.json or composer.lock exposed

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

PHP composer.json or composer.lock Exposed fix | VulnRadar