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 (CWE-319).
RFC 6749 §3.1 / §10.9 require TLS for the authorization and token endpoints. Use https:// for every authorize, token, and userinfo URL. http://localhost and loopback addresses are fine for local development and are not flagged.
class OAuthEndpoints { // TLS-protected token endpoint. String tokenUrl() { // ok: auth.java.oauth.insecure-token-endpoint return "https://idp.example.com/oauth/token"; } // TLS-protected authorize request. String authorizeUrl(String clientId) { // ok: auth.java.oauth.insecure-token-endpoint return "https://idp.example.com/authorize?response_type=code&client_id=" + clientId; } // True-negative trap: a cleartext http:// URL that is NOT an OAuth endpoint // (no OAuth marker), and a loopback dev token endpoint — neither is flagged. String healthUrl() { // ok: auth.java.oauth.insecure-token-endpoint return "http://status.example.com/health"; } String localDevToken() { // ok: auth.java.oauth.insecure-token-endpoint return "http://localhost:8080/oauth/token"; } String loopbackToken() { // ok: auth.java.oauth.insecure-token-endpoint return "http://127.0.0.1:9000/connect/token"; }}
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.