The open database of AI code hallucinations. 70+ phantom APIs, 25+ cross-language confusions, 15+ phantom packages that LLMs generate. Free, offline, zero dependencies.
Project description
CodeTrust Hallucination Registry
The open database of AI code hallucinations. 70+ phantom APIs, 25+ cross-language confusions, 15+ phantom packages that AI coding tools generate.
45% of AI-generated code contains vulnerabilities. Many are hallucinations — functions, methods, and packages that the AI invented but don't actually exist. Traditional security scanners (Snyk, SonarQube, Semgrep) don't detect these because they only look for known vulnerabilities in real code. Hallucinated code is a new vulnerability class.
Install
pip install codetrust-hallucination-registry
Zero dependencies. Runs offline. MIT licensed.
Usage
from codetrust_registry import is_phantom, check, get_all_phantoms
# Quick check
is_phantom("os.get_env") # True — doesn't exist in Python
is_phantom("os.getenv") # False — this is real
is_phantom("json.parse") # True — this is JavaScript, not Python
is_phantom(".push") # True — JavaScript Array method
is_phantom(".append") # False — Python list method
# Detailed check
result = check("os.get_env")
# {
# "is_phantom": True,
# "correct": "os.getenv()",
# "cwe_id": "CT-HALL-001",
# "description": "os.get_env() does not exist. The correct function is os.getenv().",
# "ai_tools": "copilot,chatgpt,cursor"
# }
# Get all patterns
phantoms = get_all_phantoms(language="python")
print(f"{len(phantoms)} phantom patterns for Python")
# Filter by category
cross_lang = get_all_phantoms(category="cross_language")
phantom_apis = get_all_phantoms(category="phantom_api")
phantom_pkgs = get_all_phantoms(category="phantom_package")
What It Catches
Phantom APIs (CT-HALL-001)
Functions that AI tools invent but don't exist in the target library:
os.get_env()→ should beos.getenv()json.read_file()→ should bejson.load(open(path))hashlib.encrypt()→ hashlib does hashing, not encryptionsubprocess.execute()→ should besubprocess.run()
Cross-Language Confusion (CT-HALL-003)
JavaScript/Java methods that AI puts in Python code:
.push()→ should be.append().trim()→ should be.strip().toUpperCase()→ should be.upper().contains()→ should be'x' in string.length→ should belen()JSON.parse()→ should bejson.loads()console.log()→ should beprint()
Phantom Packages (CT-HALL-002)
Packages that AI imports but don't exist on PyPI — potential supply chain attack vectors:
flask_secure_headers— doesn't exist, attacker could register itfastapi_helpers— doesn't existdjango_utilsas a package — doesn't exist (django.utils is a module)
Why This Matters
When AI generates from flask_secure_headers import SecureHeaders, that package doesn't exist. But an attacker can register flask-secure-headers on PyPI with malicious code. The next time someone runs pip install, they get owned. This is called dependency confusion via AI hallucination — a new attack vector that didn't exist before AI coding tools.
API
The full registry is also available as a REST API (no auth required):
# Check a function
curl https://codetrust-api.agreeablewave-62213e7f.ukwest.azurecontainerapps.io/v1/registry/check?function=os.get_env
# List all patterns
curl https://codetrust-api.agreeablewave-62213e7f.ukwest.azurecontainerapps.io/v1/registry/phantoms
# Get stats
curl https://codetrust-api.agreeablewave-62213e7f.ukwest.azurecontainerapps.io/v1/registry/stats
Contributing
Found a new hallucination pattern? Report it:
- Open an issue on GitHub
- Or use the API:
POST /v1/registry/report(requires free CodeTrust account)
Full Scanner
This registry is the open database. For the full scanning engine (AST-based analysis, compliance, URL scanning, enterprise features), see CodeTrust Enterprise.
License
MIT — use freely in your projects, CI/CD, and tools.
Published by AutoAI Labs.
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 codetrust_hallucination_registry-1.0.0.tar.gz.
File metadata
- Download URL: codetrust_hallucination_registry-1.0.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcdb4d8db4a6d7db778468f217989dae5bd794126a718771e3c4769773df21e2
|
|
| MD5 |
f37b9a6ec5ef5c25cdf2883ddfd11a8e
|
|
| BLAKE2b-256 |
ea17bef9d965aa1f06f5959049a42d8183f8af7525a36bef200d1226ad33dbef
|
File details
Details for the file codetrust_hallucination_registry-1.0.0-py3-none-any.whl.
File metadata
- Download URL: codetrust_hallucination_registry-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecbc84c0e3c2d8163bb398921b0f7ee6eb83c87c28e8e749fe39cc0b93f05cca
|
|
| MD5 |
66588be53ad39a36dc620453bf0c4ab0
|
|
| BLAKE2b-256 |
f05e817cc1c34d124370d2cf7cc86bf56fbf314e0e53e211fc90225bc55ce847
|