jordancoin/ios-skills-collection/dpearson2699-ios-security
Claude Code and agent skill by jordancoin/ios-skills-collection
- community
Checking that the SKILL.md file is still in the repository.
Secure iOS apps with Keychain Services, CryptoKit encryption, biometric authentication (Face ID, Touch ID), Secure Enclave key storage, LAContext, App Transport Security (ATS), certificate pinning, data protection classes, and secure coding patterns. Use when implementing app security features, auditing privacy manifests, configuring App Transport Security, securing keychain access, adding biometric authentication, or encrypting sensitive data with CryptoKit.
Install
npx vskill@latest install jordancoin/ios-skills-collection/dpearson2699-ios-securitySKILL.md
iOS Security
Guidance for handling sensitive data, authenticating users, encrypting correctly, and following Apple's security best practices on iOS.
Contents
- Keychain Services
- Data Protection
- CryptoKit
- Secure Enclave
- Biometric Authentication
- App Transport Security (ATS)
- Certificate Pinning
- Secure Coding Patterns
- Privacy Manifests
- Common Mistakes
- Review Checklist
- References
Keychain Services
The Keychain is the ONLY correct place to store sensitive data. Never store passwords, tokens, API keys, or secrets in UserDefaults, files, or Core Data.
Storing Credentials
Reading Credentials
Deleting Credentials
kSecAttrAccessible Values
| Value | When Available | Device-Only | Use For | |
|---|---|---|---|---|
kSecAttrAccessibleWhenUnlocked | Device unlocked | No | General credentials | |
kSecAttrAccessibleWhenUnlockedThisDeviceOnly | Device unlocked | Yes | Sensitive credentials | |
kSecAttrAccessibleAfterFirstUnlock | After first unlock | No | Background-accessible tokens | |
kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly | After first unlock | Yes | Background tokens, no backup | |
kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly | Passcode set + unlocked | Yes | Highest security |
Rules:
- Use
ThisDeviceOnlyvariants for sensitive data. Prevents backup/restore to other devices. - Use
AfterFirstUnlockfor tokens needed by background operations. - Use
WhenPasscodeSetThisDeviceOnlyfor most sensitive data. Item is deleted if passcode is removed. - NEVER use
kSecAttrAccessibleAlways(deprecated and insecure).
Keychain Access Groups
Share keychain items across apps from the same team:
@AppStorage vs Keychain
| Storage | Use For | Security | |
|---|---|---|---|
@AppStorage / UserDefaults | Non-sensitive preferences (theme, onboarding state, feature flags) | Not encrypted at rest | |
| Keychain | Passwords, tokens, API keys, secrets | Hardware-encrypted, access-controlled |
Rule: If the data would be embarrassing or dangerous if exposed, it goes in Keychain. Everything else can use @AppStorage.
Data Protection
iOS encrypts files based on their protection class:
| Class | When Available | Use For | |
|---|---|---|---|
.complete | Only when unlocked | Sensitive user data | |
.completeUnlessOpen | Open handles survive lock | Active downloads, recordings | |
.completeUntilFirstUserAuthentication | After first unlock (default) | Most app data | |
.none | Always | Non-sensitive, system-needed data |
Use .complete for any file containing user-sensitive data. The default .completeUntilFirstUserAuthentication is acceptable for general app data.
CryptoKit
Use CryptoKit for all cryptographic operations. Do not use CommonCrypto or the raw Security framework for new code.
Symmetric Encryption (AES-GCM)
Hashing
HMAC (Message Authentication)
For digital signatures (P256/ECDSA), key agreement (Curve25519), ChaChaPoly, and HKDF key derivation, see references/cryptokit-advanced.md.
Secure Enclave
For the highest security, store keys in the Secure Enclave. Keys never leave the hardware. Only P256 is supported.
Biometric Authentication
This section covers biometric protection for Keychain items and data access. For user-facing biometric sign-in flows (LAContext.evaluatePolicy as a login mechanism), see the authentication skill.
LocalAuthentication (Face ID / Touch ID)
Info.plist Requirement
You MUST include NSFaceIDUsageDescription in Info.plist:
Missing this key causes a crash on Face ID devices.
LAContext Configuration
Biometric + Keychain
Protect keychain items with biometric access:
SecAccessControl flags:
.biometryCurrentSet-- Requires biometry, invalidated if enrollment changes. Most secure..biometryAny-- Requires biometry, survives enrollment changes..userPresence-- Biometry or passcode. Most flexible.
App Transport Security (ATS)
ATS enforces HTTPS by default. Do NOT disable it.
What ATS Requires
- TLS 1.2 or later
- Forward secrecy cipher suites
- SHA-256 or better certificates
- 2048-bit or greater RSA keys (or 256-bit ECC)
Exception Domains (Last Resort)
Rules:
- NEVER set
NSAllowsArbitraryLoadsto true. Apple will reject the app. - Exception domains require justification in App Review notes.
- Use exception domains only for third-party servers you cannot control.
Certificate Pinning
Pin certificates for sensitive API connections to prevent MITM attacks.
URLSession Delegate Pinning
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/dpearson2699--ios-security/SKILL.md
Popularity
- Repository stars
- 6
- 7-day trend score
- 10
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jordancoin/ios-skills-collection/dpearson2699-ios-security)