mobile-security-architect
Architect-level mobile security — the trust model of a device you do not own, token storage in Keychain/Keystore, biometrics and session lifetime, deep links and IPC as an attack surface, certificate pinning's cost, and what tampering can and cannot be defended against. Use when a mobile app handles accounts, payments, health data, or enterprise access.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- mobile-security-architect
- license
- MIT
- metadata
- { "crusor-path": "mobile-architect/data-architect/mobile-security-architect", "crusor-domain": "mobile-architect", "crusor-origin": "original", "crusor-sources": "developer.android.com/privacy-and-security/keystore; developer.apple.com/documentation/security; owasp.org/www-project-mobile-top-10", "crusor-triggers": "mobile security, keychain, keystore, biometric, jwt in app, certificate pinning, app tampering, deep link, jailbreak, auth token, token storage, secure storage, keychain storage", "crusor-verified-on": "2026-10-30" }
- description
- Architect-level mobile security — the trust model of a device you do not own, token storage in Keychain/Keystore, biometrics and session lifetime, deep links and IPC as an attack surface, certificate pinning's cost, and what tampering can and cannot be defended against. Use when a mobile app handles accounts, payments, health data, or enterprise access.
- compatibility
- iOS Keychain, Android Keystore, App Attest, Play Integrity
03 SKILL.md 正文
Mobile Security Architect
The device is outside your trust boundary. Every secret that reaches the app must be cheap to lose, and every check the client makes must be re-checked on the server.
When to use
- Handling accounts, tokens, payments, health or enterprise data.
- Designing login, biometrics, or secure storage.
- Adding deep links, file sharing, or a webview.
When NOT to use
- Purely anonymous, offline, no-account utility.
- The finding is a server-side authorization bug → web security books.
Decision 1 — Trust model
| Assumption | Consequence |
|---|---|
| device may be rooted/jailbroken | do not rely on local checks |
| app binary can be extracted | no API keys, no long-lived secrets |
| traffic can be intercepted (user CA) | pinning raises cost, never absolute |
| storage is readable if unlocked+compromised | encrypt with a Keychain-backed key |
- Anything enforcing money, entitlements, or permissions belongs on the server.
- Client checks are UX and defence-in-depth, never the control itself.
Decision 2 — Tokens and credentials
- Access token: short-lived (minutes), in memory. Refresh token: in Keychain / Keystore-backed storage, rotating.
- Never in UserDefaults / SharedPreferences / a plist / build config.
- One keychain item per concern; accessibility class chosen deliberately
(
whenUnlockedThisDeviceOnlyfor anything sensitive). - Logout clears tokens, cached PII, and the local database of user data.
- Do not put API keys for third-party services in the app — proxy through your backend.
Decision 3 — Authentication and biometrics
- Biometrics unlock a key; they are not the credential. The credential is a device-bound key attested by the platform.
- Refresh token rotation with reuse detection: a replayed token means theft.
- Session lifetime, idle timeout, and re-auth on sensitive actions (payment, export) are stated, not implied.
- Enterprise: SSO via the system browser (ASWebAuthenticationSession / Custom Tabs), never an embedded webview login.
Decision 4 — Surfaces
| Surface | Rule |
|---|---|
| deep links / universal links | validate the URL, never auto-execute actions |
| webviews | allowlist origins, no JS bridge exposing native APIs |
| file import/export | validate type, size, path traversal |
| clipboard | no secrets written implicitly |
| screenshots/app switcher | blur sensitive screens |
| push payloads | no secrets; they are visible on the lock screen |
Decision 5 — Network
- TLS everywhere, no ATS exceptions, no cleartext.
- Pinning: protects against user-installed CAs; breaks on cert rotation unless you pin a set with a backup. Decide who owns the rotation runbook.
- Certificate rotation and pin expiry must be tested before release, not after.
Decision 6 — Tamper signals
- Attestation (App Attest / Play Integrity) is a risk signal, not a gate — use it to raise friction, not to silently break users.
- Root/jailbreak detection produces false positives; log and step up, do not brick.
- Obfuscation raises cost; it does not protect a secret in the binary.
Failure modes at scale
- Refresh token in plain preferences, extracted from a backup file.
- Pinning rolled out without a backup pin; one rotation bricks the installed base.
- Deep link that opens an authenticated screen without checking the session.
- Biometric prompt used as the only gate for a payment.
- Logout that leaves the local cache intact on a shared device.
Verification receipts
- Secret inventory: what is stored, where, and with which accessibility class.
- Token lifetime and rotation tested, including refresh-token reuse detection.
- Deep-link fuzzing: malformed and hostile URLs rejected.
- Pinning rotation rehearsed with the backup pin.
- Logout test on a used device: no user data remains in storage or caches.
04 同仓库更多 Skills
interaction-patterns-architect
Architect-level interaction design in code — choosing established patterns over invented ones, feedback and latency behaviour, destructive-action safeguards, navigation and overlay conventions, and the state model behind every interactive surface. Use when a screen has to behave, not just look.
design-system-ops-architect
Architect-level operation of a design system in code — token pipelines and versioning, component API and variant policy, the catalogue as the contract, adoption metrics, and the governance that stops a system from forking into three. Use when a component library must survive several teams.
design-handoff-architect
Architect-level design handoff — what must be specified before implementation starts, tokens over raw values, responsive and content-limit contracts, state matrices, and the review loop that catches drift between design and code. Use when a design is about to become code.
content-microcopy-architect
Architect-level UI content — where strings live, voice and terminology consistency, error and empty-state copy as part of the interface, translation-ready authoring, and the content model a product needs before it multiplies screens. Use when the words in the interface matter as much as the pixels.
ui-ux-implementation-architect
Architect-level direction for turning a design into working UI — the handoff contract, component ownership versus screen-level layout, interaction and state conventions, design QA gates, and the review habits that keep an implementation faithful without frozen pixels. Use before any specific UI implementation skill.
test-strategy-architect
Architect-level test strategy — allocating assertions across unit, integration, contract and end-to-end layers, designing for testability through dependency boundaries, fixture and data strategy, and the flake and coverage policies that keep a suite trustworthy. Use when defining how a codebase is tested.