Spot AI-hallucinated and slopsquatting Python dependencies, typosquats, and hardcoded secrets.
Project description
depmirage
Catch AI-hallucinated and slopsquatting Python dependencies before they ship.
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
- Package existence (the hero feature). Every dependency in
requirements.txtis checked against PyPI. Non-existent names are flagged as hallucinated / slopsquatting risk. - 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.
- Hardcoded secrets.
.pyfiles are scanned for OpenAI-stylesk-…keys, AWSAKIA…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). - Output + exit code. A colored
richtable — 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f383725d1ad89fe8100deebafa28a4b3289c0fe0503c852f7cfa89d826dd845
|
|
| MD5 |
851895900d4a3ebf8e8d3953737e3309
|
|
| BLAKE2b-256 |
a7b2a8fa8010bf7982794b4f5eb4bc2290d30ecb57954fb7b23cd29cfaf60436
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65a6aa0affe17085473f1acdcdd99f8d25e31f6fd888e250f0d7cc39d75f0fcd
|
|
| MD5 |
359fe1a62ebafc6370007d441af751ae
|
|
| BLAKE2b-256 |
9bc119d778ffae07d25b502cd2a990d6af65a46724dece7bb6283a0eacd224cd
|