python-fastapi-patterns
Fail
Audited by Gen Agent Trust Hub on Feb 15, 2026
Risk Level: HIGHCREDENTIALS_UNSAFE
Full Analysis
- [CREDENTIALS_UNSAFE] (HIGH): Hardcoded database credentials in application template.
- Evidence: In
assets/fastapi-template.py, theSettingsclass provides a defaultdatabase_urlof"postgresql+asyncpg://user:pass@localhost/db". - Risk: Developers using this template might deploy applications with default credentials, allowing unauthorized database access.
- [CREDENTIALS_UNSAFE] (HIGH): Hardcoded API key in dependency injection example.
- Evidence: In
references/dependency-injection.md, theget_api_keyfunction uses a hardcoded comparison:if x_api_key != "secret":. - Risk: If copied as-is, this creates a vulnerability where the application is protected by a well-known, insecure password.
- [DATA_EXFILTRATION] (LOW): Permissive CORS configuration in debug mode.
- Evidence:
assets/fastapi-template.pyallows all origins ("*") when the application is in debug mode. - Risk: This encourages insecure configurations that could lead to data exposure if debug mode is accidentally enabled in production.
Recommendations
- AI detected serious security threats
Audit Metadata