ios-app-security/SKILL.md
Use when securing an iOS app — Keychain best practices with Secure Enclave, Data Protection classes for files, App Transport Security, certificate pinning via URLSession delegate, jailbreak detection, runtime tamper detection, binary protection (anti-debugging, anti-hooking), code signing and entitlements hygiene, and iOS 17+ privacy manifest. Complements ios-development (general standards), ios-stability-solutions (crash patterns), and ios-biometric-login (LocalAuthentication).
npx skillsauth add peterbamuhigire/skills-web-dev ios-app-securityInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
ios-app-security or would be better handled by a more specific companion skill.references only as needed.SKILL.md first, then load only the referenced deep-dive files that are necessary for the task.references/ directory for deep detail after reading the core workflow below.Defensive security patterns for iOS apps built in Swift. Covers data-at-rest, data-in-transit, runtime integrity, binary protection, code signing hygiene, and privacy compliance so teams can ship apps that resist realistic attacks without over-investing in unwinnable battles.
Load this skill when:
Do not load this skill for:
ios-development).ios-stability-solutions).ios-biometric-login).The iOS security model is a defence-in-depth stack. An app on a stock, passcode-protected device is wrapped by several independent layers:
Your job as an app developer is not to reinvent these layers but to opt in correctly: store secrets in the right container, declare the minimum entitlements, turn on the strictest file protection class that still works for your use case, and add extra friction (pinning, tamper detection) only where the threat model justifies it.
| # | Domain | Reference |
|---|--------|-----------|
| 1 | Keychain and Secure Enclave | references/keychain-secure-enclave.md |
| 2 | Data Protection Classes | references/data-protection-classes.md |
| 3 | ATS and Certificate Pinning | references/ats-cert-pinning.md |
| 4 | Jailbreak Detection | references/jailbreak-detection.md |
| 5 | Runtime Tamper Detection | references/runtime-tamper-detection.md |
| 6 | Binary Protection | references/binary-protection.md |
| 7 | Code Signing and Entitlements | references/code-signing-entitlements.md |
| 8 | Privacy Manifest | references/privacy-manifest.md |
The first question for any piece of data you persist is: where does it belong? There are three viable buckets on iOS:
The rule of thumb is one sentence: if losing it would embarrass you or harm the user, it belongs in the Keychain or in a file with at least .complete protection. See references/keychain-secure-enclave.md and references/data-protection-classes.md for the implementation details.
Keychain items should always specify an accessibility attribute. The default on modern iOS is kSecAttrAccessibleWhenUnlockedThisDeviceOnly for new apps, but you should pass it explicitly in code so reviewers can see the choice. The ThisDeviceOnly suffix is important: it prevents the item from being restored onto a different device from a backup, which is usually what you want for auth material.
For the highest bar, generate a signing key in the Secure Enclave and use it for challenge-response authentication against your backend. The private key never leaves the SEP, and you can gate its use on Face ID/Touch ID, so a stolen device with an unknown passcode cannot complete the handshake.
iOS enforces App Transport Security (ATS) by default: HTTPS only, TLS 1.2 or higher, strong ciphers, forward secrecy. Any exception you add to Info.plist is a gap you must justify. For new apps, add zero exceptions. If you must connect to a legacy system, scope the exception tightly to a single domain and file a ticket to remove it.
For high-value endpoints (authentication, payments, personal data) add certificate pinning on top of ATS. Pin the public key hash (SPKI hash), not the full certificate, so you can rotate certificates without pushing an app update. Implement pinning in your URLSessionDelegate's urlSession(_:didReceive:completionHandler:) method; WKWebView requires its own pinning via WKNavigationDelegate. Pin two keys (current and next) so you can rotate without downtime.
Pinning is not absolute. A jailbroken device running SSL Kill Switch or a Frida hook will bypass your check. If your threat model requires resilience against that level of attacker, combine pinning with jailbreak detection and runtime integrity checks. See references/ats-cert-pinning.md.
Runtime protection is about making your app unpleasant to modify while it is running, not about making modification impossible. Expect a determined attacker with a jailbroken device to win eventually. Your goal is to raise the cost and catch the casual attacker.
references/jailbreak-detection.md.references/runtime-tamper-detection.md.Once an .ipa is on disk, it can be decrypted, disassembled, and examined. Assume attackers can read your Objective-C class list, your string literals, and your Swift symbol names. Plan accordingly:
DEPLOYMENT_POSTPROCESSING=YES, STRIP_INSTALLED_PRODUCT=YES, STRIP_STYLE=all. Keep the dSYM for crash symbolication.strings but does not stop a determined reverse engineer. Spend obfuscation budget on the two or three most sensitive functions, not on everything.class-dump.See references/binary-protection.md.
Entitlements are capabilities. Each one you add is something an attacker, a buggy library, or a compromised credential can abuse. Apply the principle of least privilege ruthlessly:
NSCameraUsageDescription, etc.) in human terms the user will see on the permission prompt.NSAllowsArbitraryLoads to true in a release build.App Attest on iOS 14+ to have your backend verify the app binary is genuine before granting sensitive endpoints.Keep signing keys out of your repository. CI should use app-specific signing identities stored in a secure keychain, not committed .p12 files. See references/code-signing-entitlements.md.
As of May 2024, Apple requires every app and SDK that uses a "required reason" API to ship a privacy manifest (PrivacyInfo.xcprivacy). The manifest declares:
UserDefaults, file timestamp APIs, system boot time APIs, disk space APIs, active keyboard APIs) and why.Your App Store Connect privacy labels must match the manifest. A mismatch is a common rejection cause. If you use third-party SDKs, you inherit their declared APIs and data types — review them before integrating.
App Tracking Transparency (ATT) is separate: if you use the IDFA or any cross-app tracking identifier, call ATTrackingManager.requestTrackingAuthorization and provide a usage description. See references/privacy-manifest.md.
Run through this before every release. Every unchecked box is a finding to fix or an acknowledged risk to document.
UserDefaults....WhenUnlockedThisDeviceOnly or stricter.kSecAttrAccessibleAlways anywhere in the codebase..complete protection, or .completeUntilFirstUserAuthentication with documented justification.URLSession and any WKWebView.ptrace(PT_DENY_ATTACH) enabled in release builds.willResignActive.UIScreen.main.isCaptured checked before rendering secrets.PrivacyInfo.xcprivacy present and matches App Store Connect labels.ATTrackingManager prompt implemented if any tracking is used.kSecAttrAccessibleAlways. Lets the item be read even while the device is locked. Almost never the right answer.NSAllowsArbitraryLoads. Removes the entire TLS baseline. Fix the endpoint instead.isJailbroken() function is the first thing a reverser patches. Compose many independent checks and hide the orchestration.references/keychain-secure-enclave.md — Keychain classes, accessibility, Secure Enclave key generation, access control flags, sharing across app groups.references/data-protection-classes.md — The four protection classes, defaults, file APIs, isProtectedDataAvailable, Core Data options.references/ats-cert-pinning.md — ATS configuration, URLSession delegate SPKI pinning, rotation strategy, WKWebView pinning, bypass mitigation.references/jailbreak-detection.md — File, URL scheme, sandbox, dylib, and fork-based heuristics with a composed Swift helper and telemetry strategy.references/runtime-tamper-detection.md — ptrace, sysctl, code hash self-check, Frida detection, screen capture, pasteboard hygiene.references/binary-protection.md — Symbol stripping, string obfuscation trade-offs, compiler flags, resource encryption, commercial obfuscators.references/code-signing-entitlements.md — Chain of trust, provisioning profiles, entitlement review list, App Attest, CI signing key hygiene.references/privacy-manifest.md — PrivacyInfo.xcprivacy schema, required-reason APIs, ATT, SDK manifests, App Store Connect alignment.ios-development — general Swift and architecture standards; this skill layers defensive patterns on top.ios-stability-solutions — crash prevention; stability and security are complementary (a crash is often a security bug, and a locked-down app that crashes constantly is not secure in practice).ios-biometric-login — LAContext, Face ID/Touch ID integration; cross-referenced from Keychain access control and Secure Enclave key gating.ios-networking-advanced — production URLSession client where pinning is wired in; this skill specifies the pinning policy, that skill shows where it plugs in.ios-data-persistence — repository pattern over SwiftData/SQLite; this skill specifies the protection class those stores must use.app-store-review — Review Guidelines, privacy labels, TestFlight; the privacy manifest and ATT material here aligns with the review skill's checklist.ios-project-setup — Xcode build settings, xcconfig, code signing; where the binary protection and stripping flags actually live.data-ai
Use when adding AI-powered analytics to a SaaS platform — semantic search over business data, natural language queries, trend detection, anomaly alerts, and AI-generated insights for dashboards. Covers embeddings, NL2SQL, and per-tenant analytics...
data-ai
Design AI-powered analytics dashboards — what metrics to show, how to display AI predictions and confidence, drill-down patterns, KPI cards, trend visualisation, AI Insights panels, export design, and role-based dashboard variants. Invoke when...
development
Use when designing, building, reviewing, or upgrading production software systems that must be secure, performant, maintainable, scalable, and user-centered. Apply before writing specs, code, architecture, APIs, databases, mobile apps, SaaS platforms, or ERP systems.
development
Professional web app UI using commercial templates (Tabler/Bootstrap 5) with strong frontend design direction when needed. Use for CRUD interfaces, dashboards, admin panels with SweetAlert2, DataTables, Flatpickr. Clone seeder-page.php, use...