Skip to main content
LowSupply chainOWASP A05:2021CWE-540

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

  1. 1Exclude packaging files from the served directory.
  2. 2Replace open-ended version constraints on security-sensitive packages with bounded ones, backed by a lockfile.
  3. 3Confirm any private index URL the file disclosed still requires authentication.

Code examples

Copy only the application into the runtime image

DOCKERFILE
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 /app

References

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.

See every supply chain check

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.

Propose a checkHow a check is built

Scan your own site for python pyproject.toml 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

How to fix: Python pyproject.toml exposed | VulnRadar