axiom-security
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSecurity & Credentials
安全与凭据
You MUST use this skill for ANY keychain, encryption, passkey, app integrity, file protection, or code signing work.
任何涉及Keychain、加密、Passkey、应用完整性、文件保护或代码签名的工作,都必须使用本技能。
Quick Reference
快速参考
| Symptom / Task | Reference |
|---|---|
| Store tokens, passwords, API keys securely | See |
| Choose kSecAttrAccessible level, biometric protection | See |
| SecItem function signatures, attribute constants | See |
| errSecDuplicateItem, errSecItemNotFound, errSecInteractionNotAllowed | See |
| Encrypt data, sign payloads, key management | See |
| Hash functions, HMAC, AES-GCM, ChaChaPoly, ECDSA, EdDSA, key agreement | See |
| Passkey sign-in, WebAuthn, ASAuthorizationController | See |
| App integrity verification, DCAppAttestService | See |
| NSFileProtection levels, data protection at rest | See |
| Certificate management, provisioning profiles, CI/CD signing | See |
| Certificate not found, profile mismatch, entitlement errors | See |
| Certificate CLI, profile inspection, entitlement extraction | See |
| 症状/任务 | 参考文档 |
|---|---|
| 安全存储令牌、密码、API密钥 | 查看 |
| 选择kSecAttrAccessible级别、生物识别保护 | 查看 |
| SecItem函数签名、属性常量 | 查看 |
| errSecDuplicateItem、errSecItemNotFound、errSecInteractionNotAllowed | 查看 |
| 加密数据、签名负载、密钥管理 | 查看 |
| 哈希函数、HMAC、AES-GCM、ChaChaPoly、ECDSA、EdDSA、密钥协商 | 查看 |
| Passkey登录、WebAuthn、ASAuthorizationController | 查看 |
| 应用完整性验证、DCAppAttestService | 查看 |
| NSFileProtection级别、静态数据保护 | 查看 |
| 证书管理、配置文件、CI/CD签名 | 查看 |
| 证书未找到、配置文件不匹配、权限错误 | 查看 |
| 证书CLI、配置文件检查、权限提取 | 查看 |
Decision Tree
决策树
dot
digraph security {
start [label="Security task" shape=ellipse];
what [label="What do you need?" shape=diamond];
start -> what;
what -> "skills/keychain.md" [label="store/retrieve\ncredentials, tokens,\nsecrets"];
what -> "skills/keychain-ref.md" [label="SecItem API syntax,\nattribute constants,\naccess levels"];
what -> "skills/keychain-diag.md" [label="keychain errors\n(errSec codes)"];
what -> "skills/cryptokit.md" [label="encrypt data,\nsign payloads,\nSecure Enclave keys"];
what -> "skills/cryptokit-ref.md" [label="CryptoKit API\n(AES, ECDSA, HPKE,\npost-quantum)"];
what -> "skills/passkeys.md" [label="passkey sign-in,\nreplace passwords"];
what -> "skills/app-attest.md" [label="app integrity,\nfraud prevention"];
what -> "skills/file-protection-ref.md" [label="file encryption,\nNSFileProtection"];
what -> "skills/code-signing.md" [label="set up signing,\nprofiles, CI/CD"];
what -> "skills/code-signing-diag.md" [label="signing errors,\nupload rejections"];
what -> "skills/code-signing-ref.md" [label="CLI commands,\nprofile inspection"];
}- Store tokens, passwords, API keys securely? → 1a. Need SecItem function signatures, attribute constants? →
skills/keychain.md1b. Keychain errors (errSecDuplicateItem, errSecItemNotFound)? →skills/keychain-ref.mdskills/keychain-diag.md - Encrypt data, sign payloads, manage keys? → 2a. Need CryptoKit API details (AES-GCM, ECDSA, HPKE, post-quantum)? →
skills/cryptokit.mdskills/cryptokit-ref.md - Implement passkey sign-in, replace passwords? →
skills/passkeys.md - Verify app integrity, prevent fraud? →
skills/app-attest.md - File encryption at rest, NSFileProtection levels? →
skills/file-protection-ref.md - Set up code signing, manage certificates, CI/CD? → 6a. Code signing error troubleshooting? →
skills/code-signing.md6b. Certificate CLI commands, profile inspection? →skills/code-signing-diag.mdskills/code-signing-ref.md - Build/upload failures after signing? → See axiom-build
- App Store submission prep? →
/skill axiom-shipping - Privacy manifests, tracking transparency? → See axiom-integration
- Data persistence (SwiftData, Core Data, storage strategy)? →
/skill axiom-data - TLS configuration, certificate pinning for network requests? →
/skill axiom-networking - Want automated security scan? → security-privacy-scanner (Agent)
dot
digraph security {
start [label="Security task" shape=ellipse];
what [label="What do you need?" shape=diamond];
start -> what;
what -> "skills/keychain.md" [label="store/retrieve\ncredentials, tokens,\nsecrets"];
what -> "skills/keychain-ref.md" [label="SecItem API syntax,\nattribute constants,\naccess levels"];
what -> "skills/keychain-diag.md" [label="keychain errors\n(errSec codes)"];
what -> "skills/cryptokit.md" [label="encrypt data,\nsign payloads,\nSecure Enclave keys"];
what -> "skills/cryptokit-ref.md" [label="CryptoKit API\n(AES, ECDSA, HPKE,\npost-quantum)"];
what -> "skills/passkeys.md" [label="passkey sign-in,\nreplace passwords"];
what -> "skills/app-attest.md" [label="app integrity,\nfraud prevention"];
what -> "skills/file-protection-ref.md" [label="file encryption,\nNSFileProtection"];
what -> "skills/code-signing.md" [label="set up signing,\nprofiles, CI/CD"];
what -> "skills/code-signing-diag.md" [label="signing errors,\nupload rejections"];
what -> "skills/code-signing-ref.md" [label="CLI commands,\nprofile inspection"];
}- 需要安全存储令牌、密码、API密钥?→ 1a. 需要SecItem函数签名、属性常量?→
skills/keychain.md1b. 遇到Keychain错误(errSecDuplicateItem、errSecItemNotFound)?→skills/keychain-ref.mdskills/keychain-diag.md - 需要加密数据、签名负载、管理密钥?→ 2a. 需要CryptoKit API详情(AES-GCM、ECDSA、HPKE、后量子算法)?→
skills/cryptokit.mdskills/cryptokit-ref.md - 需要实现Passkey登录、替代密码?→
skills/passkeys.md - 需要验证应用完整性、防范欺诈?→
skills/app-attest.md - 需要静态文件加密、NSFileProtection级别设置?→
skills/file-protection-ref.md - 需要设置代码签名、管理证书、CI/CD配置?→ 6a. 需要排查代码签名错误?→
skills/code-signing.md6b. 需要证书CLI命令、配置文件检查?→skills/code-signing-diag.mdskills/code-signing-ref.md - 签名后构建/上传失败?→ 查看axiom-build
- App Store提交准备?→
/skill axiom-shipping - 隐私清单、追踪透明度?→ 查看axiom-integration
- 数据持久化(SwiftData、Core Data、存储策略)?→
/skill axiom-data - TLS配置、网络请求证书固定?→
/skill axiom-networking - 需要自动安全扫描?→ security-privacy-scanner (Agent)
Conflict Resolution
冲突解决
security vs axiom-build: When build fails with signing errors:
- Code signing errors (certificate, profile, entitlement) → use security
- Environment issues (Xcode version, simulator, Derived Data) → use axiom-build
- If unsure, check the error message: ,
CODESIGN,ITMS-90xxx→ securityerrSec
security vs shipping: When preparing for App Store:
- Privacy manifests, submission checklists, rejections → use shipping
- Code signing for distribution, certificate management → use security
security vs axiom-data: When storing sensitive data:
- Tokens, passwords, API keys → use security (keychain)
- User preferences, non-sensitive settings → use axiom-data (UserDefaults/SwiftData)
- File encryption levels for database files → use security (file-protection-ref)
security vs axiom-networking: When securing network communication:
- TLS configuration, certificate pinning → use axiom-networking
- Signing API requests, encrypting payloads → use security (CryptoKit)
security vs axiom-build:当构建因签名错误失败时:
- 代码签名错误(证书、配置文件、权限问题)→ 使用security
- 环境问题(Xcode版本、模拟器、Derived Data)→ 使用axiom-build
- 若不确定,查看错误信息:、
CODESIGN、ITMS-90xxx→ securityerrSec
security vs shipping:当准备App Store提交时:
- 隐私清单、提交检查清单、驳回问题 → 使用shipping
- 分发代码签名、证书管理 → 使用security
security vs axiom-data:当存储敏感数据时:
- 令牌、密码、API密钥 → 使用security(Keychain)
- 用户偏好、非敏感设置 → 使用axiom-data(UserDefaults/SwiftData)
- 数据库文件的加密级别设置 → 使用security(file-protection-ref)
security vs axiom-networking:当保障网络通信安全时:
- TLS配置、证书固定 → 使用axiom-networking
- API请求签名、负载加密 → 使用security(CryptoKit)
Critical Patterns
核心模式
Keychain ():
skills/keychain.md- SecItem mental model: uniqueness constraints, data protection classes
- Biometric access control (Face ID / Touch ID)
- Keychain sharing between app and extensions
- Background access pitfalls, Mac keychain differences
- Migration from UserDefaults/@AppStorage for sensitive data
Keychain API ():
skills/keychain-ref.md- SecItemAdd/CopyMatching/Update/Delete signatures
- Item class attributes, uniqueness constraint rules
- kSecAttrAccessible levels and when each applies
- Access control flags, biometric integration
- Complete error code reference
Keychain Diagnostics ():
skills/keychain-diag.md- errSecDuplicateItem from unexpected uniqueness constraints
- errSecItemNotFound despite item existing (query mismatch)
- errSecInteractionNotAllowed in background contexts
- Access group and entitlement mismatches
- Items disappearing after app updates
CryptoKit ():
skills/cryptokit.md- AES-GCM and ChaChaPoly authenticated encryption
- ECDSA/EdDSA digital signatures
- Secure Enclave hardware-backed keys
- Key agreement (ECDH) for end-to-end encryption
- HPKE for modern asymmetric encryption
- Post-quantum algorithms (ML-KEM, ML-DSA)
- CommonCrypto migration path
CryptoKit API ():
skills/cryptokit-ref.md- Hash functions (SHA-256/384/512, SHA-3), HMAC
- Symmetric encryption (AES-GCM, ChaChaPoly)
- Asymmetric signing (P256, P384, P521, Curve25519, Ed25519)
- Key agreement, key derivation (HKDF)
- Secure Enclave key creation and usage
- Swift Crypto cross-platform parity
Passkeys ():
skills/passkeys.md- ASAuthorizationController registration and assertion flows
- AutoFill-assisted requests (QuickType bar integration)
- Automatic passkey upgrades for existing users (iOS 18+)
- Combined credential requests (passkey + password + Sign in with Apple)
- Associated domains configuration for WebAuthn
App Attest ():
skills/app-attest.md- DCAppAttestService attestation and assertion flows
- Server-side validation of attestation objects
- DeviceCheck 2-bit per-device state
- Gradual rollout strategies for large install bases
- Handling unsupported devices gracefully
File Protection ():
skills/file-protection-ref.md- NSFileProtection levels (complete, completeUnlessOpen, afterFirstUnlock, none)
- Hardware-accelerated encryption tied to device passcode
- Background file access requirements
- Keychain vs file protection comparison
Code Signing ():
skills/code-signing.md- Automatic vs manual signing tradeoffs
- Certificate and profile management across teams
- fastlane match for team-wide certificate sharing
- CI/CD signing setup (GitHub Actions, Xcode Cloud)
- Distribution build preparation (App Store, TestFlight, Ad Hoc)
Code Signing Diagnostics ():
skills/code-signing-diag.md- Certificate issues (expired, missing, wrong type, revoked)
- Provisioning profile issues (expired, missing cert, wrong App ID)
- Entitlement mismatches (capability in Xcode but not in profile)
- Keychain issues in CI (locked keychain, errSecInternalComponent)
- Archive/export failures (wrong export method, wrong cert type)
Code Signing CLI ():
skills/code-signing-ref.md- ,
security find-identityfor profile inspectionsecurity cms -D - for entitlement extraction
codesign -d --entitlements - Certificate types, validity periods, per-account limits
- fastlane match commands and Keychain management
Keychain ():
skills/keychain.md- SecItem思维模型:唯一性约束、数据保护类别
- 生物识别访问控制(Face ID / Touch ID)
- 应用与扩展之间的Keychain共享
- 后台访问陷阱、Mac Keychain差异
- 从UserDefaults/@AppStorage迁移至敏感数据存储
Keychain API ():
skills/keychain-ref.md- SecItemAdd/CopyMatching/Update/Delete签名
- 项目类别属性、唯一性约束规则
- kSecAttrAccessible级别及其适用场景
- 访问控制标志、生物识别集成
- 完整错误码参考
Keychain诊断 ():
skills/keychain-diag.md- 因意外唯一性约束导致的errSecDuplicateItem
- 项目存在但仍出现errSecItemNotFound(查询不匹配)
- 后台上下文出现errSecInteractionNotAllowed
- 访问组与权限不匹配
- 应用更新后项目消失
CryptoKit ():
skills/cryptokit.md- AES-GCM和ChaChaPoly认证加密
- ECDSA/EdDSA数字签名
- Secure Enclave硬件支持密钥
- 密钥协商(ECDH)用于端到端加密
- HPKE现代非对称加密
- 后量子算法(ML-KEM、ML-DSA)
- CommonCrypto迁移路径
CryptoKit API ():
skills/cryptokit-ref.md- 哈希函数(SHA-256/384/512、SHA-3)、HMAC
- 对称加密(AES-GCM、ChaChaPoly)
- 非对称签名(P256、P384、P521、Curve25519、Ed25519)
- 密钥协商、密钥派生(HKDF)
- Secure Enclave密钥创建与使用
- Swift Crypto跨平台一致性
Passkeys ():
skills/passkeys.md- ASAuthorizationController注册与断言流程
- AutoFill辅助请求(QuickType栏集成)
- 为现有用户自动升级Passkey(iOS 18+)
- 组合凭据请求(Passkey + 密码 + Apple登录)
- WebAuthn的关联域配置
App Attest ():
skills/app-attest.md- DCAppAttestService认证与断言流程
- 认证对象的服务器端验证
- DeviceCheck每设备2位状态
- 针对大规模安装基数的逐步推出策略
- 优雅处理不支持的设备
文件保护 ():
skills/file-protection-ref.md- NSFileProtection级别(complete、completeUnlessOpen、afterFirstUnlock、none)
- 与设备密码绑定的硬件加速加密
- 后台文件访问要求
- Keychain与文件保护对比
代码签名 ():
skills/code-signing.md- 自动签名与手动签名的权衡
- 跨团队的证书与配置文件管理
- fastlane match用于团队范围内的证书共享
- CI/CD签名设置(GitHub Actions、Xcode Cloud)
- 分发构建准备(App Store、TestFlight、Ad Hoc)
代码签名诊断 ():
skills/code-signing-diag.md- 证书问题(过期、缺失、类型错误、吊销)
- 配置文件问题(过期、缺少证书、App ID错误)
- 权限不匹配(Xcode中启用了功能但配置文件中未包含)
- CI中的Keychain问题(锁定的Keychain、errSecInternalComponent)
- 归档/导出失败(导出方法错误、证书类型错误)
代码签名CLI ():
skills/code-signing-ref.md- 、
security find-identity用于配置文件检查security cms -D - 用于权限提取
codesign -d --entitlements - 证书类型、有效期、每个账户的限制
- fastlane match命令与Keychain管理
Automated Scanning
自动化扫描
Security audit → Launch agent (scans for hardcoded credentials, insecure @AppStorage usage, missing Privacy Manifests, ATS violations, sensitive data in logs)
security-privacy-scanner安全审计 → 启动 Agent(扫描硬编码凭据、不安全的@AppStorage使用、缺失的隐私清单、ATS违规、日志中的敏感数据)
security-privacy-scannerAnti-Rationalization
误区纠正
| Thought | Reality |
|---|---|
| "I'll store the token in UserDefaults for now" | UserDefaults is a plist file readable by any process with file access. Keychain takes 10 lines. |
| "My app doesn't need encryption" | If you store any user data at rest, iOS file protection is free. |
| "CommonCrypto works fine, no need to migrate" | CommonCrypto is C API with manual memory management and no compile-time safety. CryptoKit prevents buffer overflows and key misuse. |
| "I'll just use automatic signing" | Automatic signing works until CI, team scaling, or capability changes break it. Understand manual signing before you need it. |
| "Passkeys are too new, passwords are fine" | Passkeys are phishing-resistant and supported since iOS 16. The migration path supports both simultaneously. |
| "I'll regenerate all certificates to fix this" | Regenerating revokes existing certs and breaks every teammate's build. Diagnose first. |
| "App Attest is overkill for my app" | If your app has any server-verified purchase, promotion, or competitive feature, tampered clients will exploit it. |
| "I'll use @unchecked Sendable on my crypto wrapper" | Hiding thread-safety issues from the compiler in security code is how data corruption happens. See axiom-concurrency for safe patterns. |
| "kSecAttrAccessibleAlways is fine" | Deprecated since iOS 12. Items are accessible even when device is locked and unencrypted during backup. Use kSecAttrAccessibleAfterFirstUnlock at minimum. |
| 错误想法 | 实际情况 |
|---|---|
| "我现在先把令牌存在UserDefaults里" | UserDefaults是plist文件,任何拥有文件访问权限的进程都能读取。Keychain实现仅需10行代码。 |
| "我的应用不需要加密" | 如果你存储任何用户静态数据,iOS文件保护是免费的。 |
| "CommonCrypto用得好好的,不需要迁移" | CommonCrypto是C API,需要手动内存管理且无编译时安全保障。CryptoKit可防止缓冲区溢出和密钥误用。 |
| "我只用自动签名就行" | 自动签名在CI、团队扩展或功能变更时会失效。在需要手动签名前先了解它。 |
| "Passkey太新了,密码就够用" | Passkey具备防钓鱼能力,自iOS 16起就支持。迁移路径允许同时使用两者。 |
| "我重新生成所有证书来解决这个问题" | 重新生成会吊销现有证书,导致所有团队成员的构建失败。先诊断问题。 |
| "App Attest对我的应用来说太小题大做了" | 如果你的应用有任何服务器验证的购买、促销或竞争功能,被篡改的客户端会利用它。 |
| "我在加密包装器上用@unchecked Sendable" | 在安全代码中向编译器隐藏线程安全问题会导致数据损坏。查看axiom-concurrency获取安全模式。 |
| "kSecAttrAccessibleAlways没问题" | 自iOS 12起已废弃。即使设备锁定且备份时未加密,项目仍可访问。至少使用kSecAttrAccessibleAfterFirstUnlock。 |
Example Invocations
调用示例
User: "How do I store an auth token securely?"
→ Read:
skills/keychain.mdUser: "errSecDuplicateItem when saving to keychain"
→ Read:
skills/keychain-diag.mdUser: "What are the SecItem attribute constants?"
→ Read:
skills/keychain-ref.mdUser: "How do I encrypt user data with AES?"
→ Read:
skills/cryptokit.mdUser: "What's the CryptoKit API for ECDSA signing?"
→ Read:
skills/cryptokit-ref.mdUser: "How do I add passkey sign-in to my app?"
→ Read:
skills/passkeys.mdUser: "How do I verify my app hasn't been tampered with?"
→ Read:
skills/app-attest.mdUser: "What NSFileProtection level should I use?"
→ Read:
skills/file-protection-ref.mdUser: "My build fails with 'No signing certificate found'"
→ Read:
skills/code-signing-diag.mdUser: "How do I set up fastlane match for CI?"
→ Read:
skills/code-signing.mdUser: "How do I inspect a provisioning profile?"
→ Read:
skills/code-signing-ref.mdUser: "Scan my code for security issues"
→ Invoke: agent
security-privacy-scanner用户:"如何安全存储认证令牌?"
→ 参考:
skills/keychain.md用户:"保存到Keychain时出现errSecDuplicateItem错误"
→ 参考:
skills/keychain-diag.md用户:"SecItem的属性常量有哪些?"
→ 参考:
skills/keychain-ref.md用户:"如何用AES加密用户数据?"
→ 参考:
skills/cryptokit.md用户:"CryptoKit中ECDSA签名的API是什么?"
→ 参考:
skills/cryptokit-ref.md用户:"如何在我的应用中添加Passkey登录?"
→ 参考:
skills/passkeys.md用户:"如何验证我的应用未被篡改?"
→ 参考:
skills/app-attest.md用户:"我应该使用哪个NSFileProtection级别?"
→ 参考:
skills/file-protection-ref.md用户:"我的构建失败,提示'未找到签名证书'"
→ 参考:
skills/code-signing-diag.md用户:"如何为CI设置fastlane match?"
→ 参考:
skills/code-signing.md用户:"如何检查配置文件?"
→ 参考:
skills/code-signing-ref.md用户:"扫描我的代码查找安全问题"
→ 调用: Agent
security-privacy-scanner