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
- 1Store Dockerfiles and docker-compose files above the web root.
- 2Block access to Dockerfile, docker-compose.yml, .dockerignore at the web server.
- 3Never put actual secrets in Dockerfiles: use Docker secrets or environment injection at runtime.
- 4Scan Dockerfiles with docker scan or Trivy for base image vulnerabilities.
Code examples
Nginx deny rule
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.
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
- Critical.env File Exposed at Public URL
- MediumCDN Script With No Version Pin and No Integrity Hash
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.