Skip to main content

Spot AI-hallucinated and slopsquatting Python dependencies, typosquats, and hardcoded secrets.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

depmirage-0.1.0.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

depmirage-0.1.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file depmirage-0.1.0.tar.gz.

File metadata

  • Download URL: depmirage-0.1.0.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for depmirage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0f383725d1ad89fe8100deebafa28a4b3289c0fe0503c852f7cfa89d826dd845
MD5 851895900d4a3ebf8e8d3953737e3309
BLAKE2b-256 a7b2a8fa8010bf7982794b4f5eb4bc2290d30ecb57954fb7b23cd29cfaf60436

See more details on using hashes here.

File details

Details for the file depmirage-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: depmirage-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for depmirage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65a6aa0affe17085473f1acdcdd99f8d25e31f6fd888e250f0d7cc39d75f0fcd
MD5 359fe1a62ebafc6370007d441af751ae
BLAKE2b-256 9bc119d778ffae07d25b502cd2a990d6af65a46724dece7bb6283a0eacd224cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page