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 →
HIGH AI PREVALENCE: HIGH auth.kotlin.cors.anyhost-credentials

A Ktor CORS configuration combines anyHost() with allowCredentials = true.

Why AI tools produce this: AI coding tools generate this anti-pattern by default, it appears in a large share of AI-written auth code.

Why this matters

This tells the browser to send cookies and Authorization headers on cross-origin requests from ANY origin and to expose the authenticated response back to that origin, so any malicious website a logged-in user visits can call this API with their credentials and read the result (CWE-942, Permissive Cross-domain Policy). This is a common AI-generated mistake: anyHost() is used to "make CORS work" while credentials are also enabled.

Never pair anyHost() with credentials. Allow only the specific origins that need credentialed access: allowHost("app.example.com", schemes = listOf("https"))

VULNERABLE
vulnerable.kt
import io.ktor.server.application.*
import io.ktor.server.plugins.cors.routing.*

fun Application.configureCors() {
    install(CORS) {
        // ruleid: auth.kotlin.cors.anyhost-credentials
        anyHost()
        allowCredentials = true
    }
}
SAFE
safe.kt
import io.ktor.server.application.*
import io.ktor.server.plugins.cors.routing.*

fun Application.configureCors() {
    install(CORS) {
        allowHost("app.example.com", schemes = listOf("https"))
        allowCredentials = true
    }
}

fun Application.configurePublicCors() {
    // anyHost without credentials is a public, read-only API — out of scope.
    install(CORS) {
        anyHost()
    }
}

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.cors.anyhost-credentials -- <reason>

References

https://ktor.io/docs/server-cors.html ↗https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#credentialed_requests_and_wildcards ↗https://cwe.mitre.org/data/definitions/942.html ↗