SKY-D434 · Security in code
Sensitive data stored in UserDefaults
Skylos reports writes of token- or password-like values to Foundation UserDefaults, the platform preference store. A supported local alias of the preference store carries the check to later writes.
- Languages
- Swift
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
Why it matters
UserDefaults is designed for ordinary preferences. Sensitive values stored there do not receive the access controls of a credential store.
What Skylos flags
import Foundation func saveSession(value: String) { UserDefaults.standard.set(value, forKey: "auth.refresh_token")}What Skylos leaves alone
import Foundation func savePreferences(value: String) { UserDefaults.standard.set(value, forKey: "displayStyle")}Why Skylos leaves it alone
The key and value name describe an ordinary display preference.
How Skylos decides
- Resolves Foundation UserDefaults receivers and supported aliases, then checks set and setValue writes.
- Uses credential-like names in a fixed key or in the value expression as review evidence. Preference keys, literal booleans and deletion writes can stay quiet.
How to fix it
Store credentials in the Keychain or another approved credential store. Reserve UserDefaults for ordinary preferences.
When it can be wrong
- A credential-like key can hold a non-sensitive marker. Verify the value written on this path before accepting a key-based finding.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Mark the reviewed line with a rule-scoped Skylos ignore for SKY-D434. Record the evidence that justifies the exception.