Starlette's TrustedHostMiddleware is added but configured to trust every Host header (allowed_hosts=["*"], or a list that contains "*").
Why AI tools produce this: AI coding tools produce this regularly, typically when prompted for a shortcut or a quick fix.
Why this matters
The middleware exists specifically to validate the incoming Host/X-Forwarded-Host header against an allow-list; a wildcard disables that check, re-opening Host header injection: password-reset-link poisoning, cache poisoning, and routing of absolute URLs the app builds from the Host (CWE-346). This is a common AI-generated shortcut to silence a host-validation error rather than enumerate the real hostnames.
List the exact hostnames the service answers on, e.g. app.add_middleware(TrustedHostMiddleware, allowed_hosts=["app.example.com", "www.example.com"]) (a leading-dot entry like "*.example.com" matches subdomains and is fine; the problem is the bare "*").
Suppressing this rule
If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.
# oauthlint-disable-next-line auth.py.fastapi.trusted-host-wildcard -- <reason>