Skip to main content

depmirage

Catch AI-hallucinated and slopsquatting Python dependencies before they ship.

CI PyPI python os license

depmirage demo

Why this exists

Large language models routinely invent Python packages that do not exist. In "We Have a Package for You!" (Spracklen et al., USENIX Security 2025), researchers found that 5.2%–21.7% of package references generated by popular code LLMs point at packages that were never published — a phenomenon now called slopsquatting: an attacker registers the hallucinated name, and the next developer who copies an LLM's pip install suggestion pulls hostile code. Because the same wrong name is hallucinated repeatedly, these become predictable, reservable attack surface. depmirage scans your project for exactly this class of risk — plus classic typosquats and hardcoded secrets — and fails your build if it finds any.

Paper: arXiv:2406.10279

Install

pip install depmirage

From source:

git clone https://github.com/AABurmov18/depmirage
cd depmirage
pip install .

Requires Python 3.10+. Only two runtime dependencies: requests and rich (both pure-install, no C toolchain — builds clean on Windows).

Usage

depmirage scan <path>          # scan a folder, requirements.txt, or .py file
depmirage scan                 # defaults to the current directory
depmirage scan . --offline     # cached fixtures, ZERO network calls
depmirage scan . --json        # machine-readable output

Exit codes make it a drop-in CI / pre-commit gate:

Exit Meaning
0 No findings
1 At least one finding (hallucinated pkg, typosquat, or secret)
2 Bad invocation (path not found)
depmirage scan examples/demo || echo "findings present — failing the build"

What it checks

  1. Package existence (the hero feature). Every dependency in requirements.txt is checked against PyPI. Non-existent names are flagged as hallucinated / slopsquatting risk.
  2. Typosquat / lookalike. Names within edit-distance 1 of a bundled list of ~200 popular packages (or non-existent-and-close) are flagged as high typosquat risk. Levenshtein is implemented in pure Python — no C extensions.
  3. Hardcoded secrets. .py files are scanned for OpenAI-style sk-… keys, AWS AKIA… keys, secret-looking assignments (KEY/TOKEN/SECRET/ PASSWORD/APIKEY), and generic high-entropy string literals (Shannon entropy). Findings show file + line; the value is always masked (first/last 4 characters only).
  4. Output + exit code. A colored rich table — green [PASS], red [FAIL], yellow for "could not verify" — and a CI-friendly exit code.

Honest positioning

depmirage is not a replacement for gitleaks, trufflehog, Snyk, or pip-audit. Those tools are deeper at what they do, and you should keep using them.

The novel, defensible feature here is AI-hallucination + slopsquatting detection for the Python/PyPI ecosystem. The secret and (future) vulnerability checks are convenience layers built with well-known techniques so a single pre-commit hook covers the most common "LLM pasted something risky" cases.

Prior art. slopcheck and slop-scan-style tools exist, but they are npm-/markdown-focused. depmirage is Python/PyPI-first and scans both requirements.txt and .py source.

Pre-commit

Add to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/AABurmov18/depmirage
    rev: v0.1.0
    hooks:
      - id: depmirage

CI (GitHub Actions)

name: depmirage
on: [push, pull_request]
jobs:
  slopsquat-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: { python-version: "3.12" }
      - run: pip install depmirage
      - run: depmirage scan .

How it works

depmirage parses your requirements.txt (stripping version specifiers, extras, and environment markers), queries https://pypi.org/pypi/{name}/json for each name with a 5-second timeout, and caches results on disk (~/.depmirage_cache) so repeat runs are fast. Only package names ever leave your machine — never source code, never secrets. Network failures degrade gracefully to "could not verify" instead of crashing. --offline short-circuits all of this with bundled fixtures for a fully deterministic, air-gapped run.

Ethics

depmirage only reads public registries (PyPI, npm). It will never register, publish, or reserve any hallucinated package name it discovers — doing so would itself be the slopsquatting attack. It never transmits your scanned code or the secrets it finds; only bare package names are sent over the wire, and secret values are masked before they are ever displayed. Use it to defend your own supply chain, not to weaponize someone else's mistake.

Contributing

Issues and PRs welcome. Run the tests with:

pip install -e ".[dev]"
pytest

Good first contributions: extend the popular-package list, add ecosystems (npm/package.json existence is partially wired up), or add OSV.dev vulnerability lookups.

License

MIT.

Metadata

Release files for depmirage 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 depmirage 0.1.0
File Size Uploaded Provenance
depmirage-0.1.0.tar.gz 22.7 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 42.1 kB

Release files / depmirage-0.1.0.tar.gz

Download URL depmirage-0.1.0.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0f383725d1ad89fe8100deebafa28a4b3289c0fe0503c852f7cfa89d826dd845
BLAKE2b-256 checksum
How to use checksums
a7b2a8fa8010bf7982794b4f5eb4bc2290d30ecb57954fb7b23cd29cfaf60436
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

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

Download URL depmirage-0.1.0-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65a6aa0affe17085473f1acdcdd99f8d25e31f6fd888e250f0d7cc39d75f0fcd
BLAKE2b-256 checksum
How to use checksums
9bc119d778ffae07d25b502cd2a990d6af65a46724dece7bb6283a0eacd224cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for depmirage 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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