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.
Metadata
Release files for codetrust-hallucination-registry 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| codetrust_hallucination_registry-1.0.0.tar.gz | 6.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| codetrust_hallucination_registry-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.2 kB
Release files / codetrust_hallucination_registry-1.0.0.tar.gz
| Download URL | codetrust_hallucination_registry-1.0.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dcdb4d8db4a6d7db778468f217989dae5bd794126a718771e3c4769773df21e2
|
|
BLAKE2b-256 checksum How to use checksums |
ea17bef9d965aa1f06f5959049a42d8183f8af7525a36bef200d1226ad33dbef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.9
|
Release files / codetrust_hallucination_registry-1.0.0-py3-none-any.whl
| Download URL | codetrust_hallucination_registry-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ecbc84c0e3c2d8163bb398921b0f7ee6eb83c87c28e8e749fe39cc0b93f05cca
|
|
BLAKE2b-256 checksum How to use checksums |
f05e817cc1c34d124370d2cf7cc86bf56fbf314e0e53e211fc90225bc55ce847
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.9
|