Why AI tools produce this: AI coding tools produce this regularly, typically when prompted for a shortcut or a quick fix.
Why this matters
Authorization codes, client_secret, access/refresh tokens, and the code_verifier then travel unencrypted: a network attacker can read or rewrite them and take over the flow.
RFC 6749 §3.1 / §10.9 require TLS for the authorization and token endpoints. Use https:// for every authorize, token, userinfo, and .well-known discovery URL. http://localhost and loopback addresses are fine for local development and are not flagged.
"""OAuth/OIDC endpoints over TLS, plus loopback dev hosts that are exempt."""import requests# ok: auth.py.oauth.insecure-token-endpoint -- TLS, the requirementTOKEN_URL = "https://idp.example.com/oauth/token"# ok: auth.py.oauth.insecure-token-endpoint -- TLS authorize endpointAUTHORIZE_URL = "https://idp.example.com/authorize?response_type=code&client_id=abc123"# ok: auth.py.oauth.insecure-token-endpoint -- localhost dev host is exemptLOCAL_TOKEN = "http://localhost:8080/oauth/token"# ok: auth.py.oauth.insecure-token-endpoint -- loopback dev host is exemptLOOPBACK = "http://127.0.0.1:9000/connect/token"# ok: auth.py.oauth.insecure-token-endpoint -- plain http URL with no OAuth markerHEALTHCHECK = "http://idp.example.com/healthz"def fetch_token(code: str): # ok: auth.py.oauth.insecure-token-endpoint -- TLS token exchange return requests.post(TOKEN_URL, data={"grant_type": "authorization_code", "code": code})
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.