v0.14 is out: a mobile auth pack for Swift/iOS and Android, catching insecure token storage, cleartext traffic, and OAuth in embedded WebViews. Read more →
MEDIUM AI PREVALENCE: MEDIUM auth.kotlin.android.cleartext-auth-url

An authentication / OAuth endpoint is called over cleartext http://.

Why AI tools produce this: AI coding tools produce this regularly, typically when prompted for a shortcut or a quick fix.

Why this matters

Any token, authorization code, or credential exchanged with that endpoint crosses the network unencrypted and is trivially captured on a hostile Wi-Fi or by an on-path attacker (CWE-319). AI-generated samples default to http:// because it "works" against a local test server and the scheme is never upgraded for production hosts.

Use https:// for every auth endpoint: val tokenUrl = "https://accounts.example.com/oauth/token" Cleartext to a local loopback host (localhost / 127.0.0.1 / 10.0.2.2) during development is not flagged.

VULNERABLE
vulnerable.kt
object Endpoints {
    // ruleid: auth.kotlin.android.cleartext-auth-url
    const val authorizeUrl = "http://accounts.example.com/oauth/authorize"

    // ruleid: auth.kotlin.android.cleartext-auth-url
    const val tokenUrl = "http://api.example.com/token"

    // ruleid: auth.kotlin.android.cleartext-auth-url
    const val loginUrl = "http://auth.example.com/login"
}
SAFE
safe.kt
object Endpoints {
    // TLS: safe
    const val authorizeUrl = "https://accounts.example.com/oauth/authorize"

    // TLS token endpoint: safe
    const val tokenUrl = "https://api.example.com/oauth/token"

    // loopback dev host: safe
    const val devToken = "http://localhost:8080/oauth/token"

    // android emulator loopback: safe
    const val emuLogin = "http://10.0.2.2:8080/login"

    // cleartext but non-auth resource: safe
    const val imageUrl = "http://cdn.example.com/logo.png"
}

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.kotlin.android.cleartext-auth-url -- <reason>

References

https://developer.android.com/privacy-and-security/security-config ↗https://cwe.mitre.org/data/definitions/319.html ↗