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

How to fix: Python setup.py source exposed

The response is a Python setup.py: a setup() call with an install_requires list.

Why it matters

Beyond the declared dependency list, setup.py is executable Python that runs at install time. A served copy shows any custom cmdclass, build step or post-install hook the package runs, and those are exactly the places where a package fetches something at install time or writes outside its own tree.

Unlike a lockfile, this one is code, so it is worth reading rather than just inventorying. The dependency_links and extras_require entries are also informative: dependency_links can point at a private index or a direct URL, and extras name optional integrations the application supports even when they are not installed here.

How to fix it

  1. 1Remove packaging files from the served directory; deploy the installed package, not the source distribution.
  2. 2Review the file's own install-time hooks: a setup.py that downloads or executes anything at install time is a supply-chain risk in its own right.
  3. 3Audit the versions in install_requires.

Code examples

Nginx: deny Python packaging files

nginx
location ~* /(setup\.py|setup\.cfg|pyproject\.toml|MANIFEST\.in)$ {
    return 404;
}

References

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

See every supply chain check

Questions

How severe is Python setup.py source 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-setup-py-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Python setup.py source 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 setup.py source 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 setup.py source exposed | VulnRadar