How to fix: Python pyproject.toml exposed
The response is a Python pyproject.toml, served directly over HTTP. It is identified by a [tool.poetry] or [build-system] table, or a [project] table with a requires-python key.
Why it matters
The file declares the dependency set with its version constraints, the optional dependency groups, and the requires-python range, which brackets the Python version in use. Tool sections beneath it commonly configure ruff, mypy and pytest, and those sections sometimes carry paths that reveal the source layout on the build machine.
Where a lockfile gives the resolved set, pyproject gives the constraints, so it shows what a rebuild would pull in rather than what is installed now. A caret or wildcard constraint on a package with a recent advisory tells an attacker that the next deployment may reintroduce it. It also names any private index configured under tool.poetry.source.
How to fix it
- 1Exclude packaging files from the served directory.
- 2Replace open-ended version constraints on security-sensitive packages with bounded ones, backed by a lockfile.
- 3Confirm any private index URL the file disclosed still requires authentication.
Code examples
Copy only the application into the runtime image
FROM python:3.12-slim AS build
WORKDIR /src
COPY pyproject.toml poetry.lock ./
RUN pip install poetry && poetry export -f requirements.txt -o /tmp/req.txt
FROM python:3.12-slim
COPY --from=build /tmp/req.txt /tmp/req.txt
RUN pip install --no-cache-dir -r /tmp/req.txt
COPY ./src /appReferences
Detected automatically by VulnRadar. The check id is supply-chain-pyproject-toml-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 Python pyproject.toml exposed?
- VulnRadar rates this low 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-pyproject-toml-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Python pyproject.toml exposed map to?
- It maps to CWE-540. 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.