How to fix: PHP Composer auth.json Exposed With Registry Credentials
A Composer auth.json file was found publicly accessible with a live http-basic password or OAuth token, not just placeholder values. This file grants access to private package repositories and, for a GitHub/GitLab token, to the linked account's API.
Why it matters
An exposed http-basic credential grants direct access to whatever private Composer repository it authenticates. An exposed github-oauth or gitlab-token value is a real personal access token: depending on its scopes, an attacker can read private repositories, push commits, or publish packages under the victim's account.
auth.json holds the credentials Composer uses to reach private package repositories, split out from composer.json specifically so it can be gitignored and kept off the server. When it ends up in the web root anyway, the credentials inside it are as exposed as if they were printed on the homepage.
How to fix it
- 1Remove auth.json from the web root immediately.
- 2Revoke and rotate every credential the file contained: http-basic passwords and GitHub/GitLab/Bitbucket tokens.
- 3Set COMPOSER_AUTH as an environment variable in CI/CD instead of committing or deploying auth.json.
- 4Add auth.json to .gitignore and block dotfiles at the web server level as defense-in-depth.
Code examples
Use an environment variable instead of a deployed auth.json
# Never deploy auth.json. In CI/CD:
export COMPOSER_AUTH='{"github-oauth":{"github.com":"'"$GITHUB_TOKEN"'"}}'
composer install --no-devReferences
Detected automatically by VulnRadar. The check id is supply-chain-composer-auth-json-exposed, stable across every scan so you can filter or diff on it.
More supply chain checks
- Mediumnpm/yarn Lock File Exposed
- MediumPython Requirements File Exposed
- MediumRuby Gemfile or Gemfile.lock Exposed
- MediumExternal CDN Script Without SRI Hash
- HighHTTP Script Loaded on HTTPS Page
- MediumPHP composer.json or composer.lock Exposed
- HighDockerfile or docker-compose.yml Exposed
- Critical.env File Exposed at Public URL
Questions
- How severe is PHP Composer auth.json Exposed With Registry Credentials?
- VulnRadar rates this critical 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-auth-json-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does PHP Composer auth.json Exposed With Registry Credentials map to?
- It maps to CWE-538. 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.