CRITICAL missing tlsfastapi

Missing Tls in Fastapi

How Missing Tls Manifests in Fastapi

Missing TLS in FastAPI applications creates multiple attack vectors that directly impact data confidentiality and integrity. When FastAPI endpoints are exposed over HTTP instead of HTTPS, several critical vulnerabilities emerge.

The most immediate risk is credential exposure during authentication flows. FastAPI's OAuth2PasswordBearer and API key authentication mechanisms transmit sensitive tokens over unencrypted channels. An attacker positioned on the same network can intercept these credentials using simple packet sniffing tools like Wireshark or tcpdump.

Consider a FastAPI authentication endpoint:

 

Fastapi-Specific Detection

Detecting missing TLS in FastAPI applications requires examining both configuration and runtime behavior. Start by inspecting your FastAPI application's startup configuration and middleware stack.

Check your main application file for HTTP-only server initialization:

 

Related CWEs: encryption

CWE IDNameSeverity
CWE-319Cleartext Transmission of Sensitive Information HIGH
CWE-295Improper Certificate Validation HIGH
CWE-326Inadequate Encryption Strength HIGH
CWE-327Use of a Broken or Risky Cryptographic Algorithm HIGH
CWE-328Use of Weak Hash HIGH
CWE-330Use of Insufficiently Random Values HIGH
CWE-338Use of Cryptographically Weak PRNG MEDIUM
CWE-693Protection Mechanism Failure MEDIUM
CWE-757Selection of Less-Secure Algorithm During Negotiation HIGH
CWE-261Weak Encoding for Password HIGH