Skip to main content

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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

Preferences.swift · SwiftReported on line 4
import Foundation func saveSession(value: String) {    UserDefaults.standard.set(value, forKey: "auth.refresh_token")}

What Skylos leaves alone

Preferences.swift · Swift
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

  1. Resolves Foundation UserDefaults receivers and supported aliases, then checks set and setValue writes.
  2. 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.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.