Skip to main content

phantom-deps

A hallucinated-dependency scanner. Before you pip install or npm install what an AI assistant just recommended, phantom-deps checks that every package name actually exists on PyPI / npm — and flags packages published so recently (< 30 days) that they smell like slopsquatting.

1 in 5 AI-suggested packages doesn't exist. Research presented at USENIX Security 2025 found that 19.7% of the 2.23 million package references produced by 16 large language models point to packages that were never published. The classic failure: the model invents a plausible-sounding library name, you install it, and an attacker who registered that exact name first gets code execution on your machine (the "slopsquatting" attack). phantom-deps is the 30-second check you run between "the AI gave me code" and "I installed its dependencies".

Zero dependencies. Python standard library only (urllib talks to the PyPI JSON API and the npm registry directly). Everything stays local; registry results are cached under ~/.cache/phantom-deps/.

Install

pip install phantom-deps

Or from source:

git clone https://github.com/hahahahahahahahah6/phantom-deps
cd phantom-deps
pip install .

Requires Python 3.9+.

Usage

# scan a project directory (requirements.txt, pyproject.toml,
# package.json, and bare Python imports are all picked up)
phantom-deps ./my-ai-generated-project

# scan specific files
phantom-deps requirements.txt package.json

# machine-readable output
phantom-deps . --json

# exit codes: 0 = clean, 1 = phantom or brand-new packages found,
#             2 = usage error (bad path)

Example output:

PHANTOM — does not exist on the registry (1):
  ✗ datavalidator-pro [pypi, from requirements.txt]

NEW — published recently, high risk (1):
  ! fastjson-utils (6d old) [pypi, from imports]

1 known-good packages checked, 3 total.

Useful flags:

Flag Meaning
--json emit JSON instead of text
--new-days N risk window for "recently published" (default: 30)
--ignore-new / --ignore-phantom don't fail on that class
--no-cache skip the local registry-result cache
--timeout SEC per-request timeout (default: 15)
--no-color disable colored output

Typical CI / pre-commit gate:

phantom-deps . || echo "unverified dependencies — review before installing"

Notes:

  • Bare imports are mapped to distribution names on a best-effort basis (bs4 → beautifulsoup4, PIL → Pillow, cv2 → opencv-python, …). Every mapped name is still verified against the real registry, so a wrong guess only costs an extra lookup — it can never produce a wrong verdict.
  • The scanner fails open on network errors: an unreachable registry is reported as a note, never as a false "phantom".

Differentiation

Supply-chain scanners already exist — this one is aimed at a different moment. Tools in the slopsquatting space generally watch registries for malicious uploads or audit lockfiles you already committed. phantom-deps targets the "the LLM just recommended this — verify before installing" step:

  1. Pre-install, not post-hoc. It runs on the AI-generated snippet's requirements.txt / import block before anything touches your environment, not on a lockfile after the fact.
  2. Nonexistence is the primary signal. Most scanners assume the package exists and ask "is it malicious?". For AI-generated code the base rate is different — ~1 in 5 suggested packages was never published at all — so "does this exist?" is the cheapest, highest-value question.
  3. Zero-dependency and instant. One pip install (or none — it runs from source with the stdlib alone), no daemon, no account, no SBOM pipeline.

License

MIT — see LICENSE.

Metadata

Release files for phantom-deps 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for phantom-deps 0.1.0
File Size Uploaded
phantom_deps-0.1.0.tar.gz 15.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for phantom-deps 0.1.0
File Interpreter ABI Platform
phantom_deps-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.5 kB

Release files / phantom_deps-0.1.0.tar.gz

Download URL phantom_deps-0.1.0.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5e219f8459a339f1347534a42f2357d9a34250d48ff8f6e8be308896ec8a9a79
BLAKE2b-256 checksum
How to use checksums
bccf8999822f194f8c3c2df2c73a8d2e33cea6d4986443bed225c46b1cc51f15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / phantom_deps-0.1.0-py3-none-any.whl

Download URL phantom_deps-0.1.0-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5524429565dfcc74869794a396b72b6e29a2d4179fedf148b9a91dc52e092bd8
BLAKE2b-256 checksum
How to use checksums
64b86b21a9774b54bf163343d19140c3859b52dd9f75b9eb7aaebcb8ec509c28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page