strix/skills/frameworks/fastapi.md
Security testing for FastAPI/Starlette applications. Focus on dependency injection flaws, middleware gaps, and authorization drift across routers and channels.
Core Components
include_router, versioned pathsDepends, Security, OAuth2PasswordBearer, HTTPBearer, scopesData Handling
Channels
Deployment
/openapi.json, /docs, /redoc in production (full attack surface map, securitySchemes, server URLs)include_in_schema=False endpoints/jobs/{id}, /tasks/{id}/result)OpenAPI Mining
GET /openapi.json
GET /docs
GET /redoc
GET /api/openapi.json
GET /internal/openapi.json
Extract: paths, parameters, securitySchemes, scopes, servers. Endpoints with include_in_schema=False won't appear—fuzz based on discovered prefixes and common admin/debug names.
Dependency Mapping
For each route, identify:
Dependency Injection Gaps
Depends used instead of Security (ignores scope enforcement)OAuth2PasswordBearer only yields a token string—verify routes don't treat presence as authJWT Misuse
kid header injection for custom key lookup pathsSession Weaknesses
secret_keyOAuth/OIDC
IDOR via Dependencies
Scope Bypass
Pydantic Exploitation
extra = "allow" permits injecting control fields (role, ownerId, scope)Annotated: craft shapes hitting unintended validation branchesContent-Type Switching
application/json ↔ application/x-www-form-urlencoded ↔ multipart/form-data
Different content types hit different validators or code paths (parser differentials).
Parameter Manipulation
X-HTTP-Method-Override (upstream respects, app doesn't)CORS Misconfiguration
allow_origin_regexCSRF Exposure
Header Spoofing
X-Forwarded-For/Proto to influence auth/IP gatingTemplate Injection (Jinja2)
{{7*7}} # Arithmetic confirmation
{{cycler.__init__.__globals__['os'].popen('id').read()}} # RCE
Check autoescape settings and custom filters/globals.
SSRF
file://, ftp://, gopher-like shims if custom clientsFile Upload
UploadFile.filename with control charactersSub-apps at /admin, /static, /metrics may bypass global middlewares. Verify auth enforcement parity across all mounts.
X-HTTP-Method-Override)