A token, secret, or credential is written to UserDefaults.
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
UserDefaults is an unencrypted plist on disk (readable from an unlocked device backup, a jailbroken device, or the simulator container) and is never an appropriate place for authentication material (CWE-312). AI-generated iOS code frequently reaches for UserDefaults.standard.set(...) because it is the simplest key/value store, silently persisting access/refresh tokens in the clear. App-group suites (UserDefaults(suiteName:)) are just as exposed.
Store secrets in the Keychain instead (via Security framework or a wrapper such as KeychainAccess), e.g. keychain.set(token, key: "authToken"), and keep UserDefaults for non-sensitive preferences only.
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.swift.storage.token-in-userdefaults -- <reason>