iOS Security
Priority: P0 (CRITICAL)
Implementation Workflow
- Store secrets in Keychain — Use
SecItemAdd,SecItemUpdate, andSecItemDeletewithkSecClassGenericPasswordfor tokens/PII. Never useUserDefaults. - Add biometric auth — Use
LocalAuthenticationwithLAContext. Verify availability withcanEvaluatePolicybefore prompting. - Encrypt files — Use
Data.WritingOptions.completeFileProtectionwhen saving to disk. - Keep ATS enabled — Never disable App Transport Security globally in
Info.plist. - Pin certificates — Use
ServerTrustManagerorTrustKitfor production apps to prevent MITM attacks. - Strip sensitive logs — Ensure PII and tokens are removed from logs in Release builds.
See Keychain and biometrics implementation examples
Anti-Patterns
- ❌ Secrets in
UserDefaults— always use Keychain - ❌ Unhandled
LAError— check foruserCancel,authenticationFailed, etc. - ❌ PII/token logging in Release builds — strip sensitive data from all log output
References
Related Topics
- common/security-standards
- architecture