Skip to main content
CriticalSupply chainOWASP A05:2021CWE-538

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

  1. 1Remove auth.json from the web root immediately.
  2. 2Revoke and rotate every credential the file contained: http-basic passwords and GitHub/GitLab/Bitbucket tokens.
  3. 3Set COMPOSER_AUTH as an environment variable in CI/CD instead of committing or deploying auth.json.
  4. 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

bash
# Never deploy auth.json. In CI/CD:
export COMPOSER_AUTH='{"github-oauth":{"github.com":"'"$GITHUB_TOKEN"'"}}'
composer install --no-dev

References

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.

See every supply chain check

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.

Propose a checkHow a check is built

Scan your own site for php composer auth.json exposed with registry credentials

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 auth.json Exposed With Registry Credentials | VulnRadar