pkgscan.dev · Documentation

How to check a PyPI package for malicious code

Python packaging gives a package several ways to run code before your program does: setup.py, a build backend, or a wheel that executes on import. pkgscan scans the artifact you point it at and reports each engine separately — but static analysis has hard limits on Python. Here is what it can and cannot tell you.

Updated 2026-11-05

Where PyPI malware hides

Scan a PyPI package with pkgscan

Open pkgscan.dev and search for the package, or use the PURL URL directly: /pkg/pypi/{name}@{version}. pkgscan resolves the version on PyPI, downloads the distributable, and runs every eligible engine. You can also upload a .whl or .tar.gz if the artifact is not public, and a SHA-256 lookup works for artifacts that were scanned before.

# Public report for a version
curl -s https://www.pkgscan.dev/api/pkg/pypi/[email protected]

# Start a fresh scan
curl -s -X POST https://www.pkgscan.dev/api/scan/from-generic-purl \
  -H "Authorization: Bearer pkg_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"purl":"pkg:pypi/[email protected]"}'

Which engines run on a PyPI artifact

EngineWhat it contributes
ArgusContent analysis of the uploaded or downloaded artifact
GuardDogPyPI rule set for install hooks, obfuscation, exfiltration, and credential access
OSV and deps.devPublished advisories and malware advisories matched to the PURL
GrypeKnown CVEs from the advisory databases baked at build time

Inspect an sdist or wheel yourself

# Download without installing dependencies
pip download --no-deps --no-binary :all: -d ./pkgs example-package==1.2.3

# List the archive contents
python3 -m zipfile -l ./pkgs/example_package-1.2.3-py3-none-any.whl

# grep for the usual first-stage markers
grep -RnE 'exec\(|b64decode|marshal\.loads|urlopen|requests\.post|os\.environ' ./pkgs

For an sdist, read setup.py and pyproject.toml before anything else. For a wheel, list the files and open the module that runs on import. If the package ships only an sdist and the code is generated during the build, read the build backend as well.

Limits specific to Python packages

Related: checking npm packages, detection methods and verdict semantics.

Check a package or file now: scan it on pkgscan.dev.