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

How to fix: Dockerfile or docker-compose.yml Exposed

A Dockerfile or docker-compose.yml file was found publicly accessible. These files reveal the base image, environment variables, secrets handling, port mappings, and infrastructure topology.

Why it matters

Dockerfiles often contain ARG/ENV values with credentials, reveal base image versions with known vulnerabilities, and expose internal service topology. docker-compose.yml often includes database credentials in environment variables.

Container configuration files should never be in the web-accessible directory. They're build-time artifacts that reveal everything about how your application is deployed.

How to fix it

  1. 1Store Dockerfiles and docker-compose files above the web root.
  2. 2Block access to Dockerfile, docker-compose.yml, .dockerignore at the web server.
  3. 3Never put actual secrets in Dockerfiles: use Docker secrets or environment injection at runtime.
  4. 4Scan Dockerfiles with docker scan or Trivy for base image vulnerabilities.

Code examples

Nginx deny rule

nginx
location ~* /(Dockerfile|docker-compose\.ya?ml|\.dockerignore|Makefile) {
  deny all;
  return 404;
}

References

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

See every supply chain check

Questions

How severe is Dockerfile or docker-compose.yml Exposed?
VulnRadar rates this high 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-dockerfile-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Dockerfile or docker-compose.yml 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 dockerfile or docker-compose.yml 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

Dockerfile or docker-compose.yml Exposed fix | VulnRadar