[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6E63N1G3HRAASK4YRN5PJVF":3,"skill-same:01M6E63N1G3HRAASK4YRN5PJVF":65},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":45,"repositoryHtmlUrl":46,"repositoryHomepageUrl":47,"ownerHtmlUrl":48,"ownerBlogUrl":6,"ownerDescription":49,"updatedAt":50,"install":51,"resources":64},"01M6E63N1G3HRAASK4YRN5PJVF","axiom-app-attest",null,"Use when implementing app integrity verification, preventing fraud with DCAppAttestService, validating requests from legitimate app instances, using DeviceCheck for promotional abuse prevention, or needing server-side attestation\u002Fassertion validation. Covers key generation, attestation, assertion, rollout strategy, and risk metrics.","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FCharlesWiltgen\u002FAxiom\u002Faxiom-app-attest\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"axiom app attest","app","strategy","server-side","generation","instances","integrity verification","rollout","use","validation","integrity","attestation","prevention","risk","fraud","server","metrics","verification","2026-11-10 10:12:30",false,"---\nname: axiom-app-attest\ndescription: Use when implementing app integrity verification, preventing fraud with DCAppAttestService, validating requests from legitimate app instances, using DeviceCheck for promotional abuse prevention, or needing server-side attestation\u002Fassertion validation. Covers key generation, attestation, assertion, rollout strategy, and risk metrics.\nlicense: MIT\n---\n\n# App Attest\n\nDevice-backed app integrity verification for fraud prevention. Proves three things to your server: the request came from a genuine Apple device, running your genuine app, with an untampered payload.\n\n## When to Use This Skill\n\nUse when you need to:\n- Verify requests come from legitimate app instances (not modified\u002Fcloned apps)\n- Prevent fraud in purchases, promotions, or competitive features\n- Implement DCAppAttestService attestation or assertion flows\n- Handle DeviceCheck 2-bit per-device state for promotional abuse\n- Build server-side validation for attestation objects or assertion signatures\n- Plan a gradual App Attest rollout for a large install base\n\n## Example Prompts\n\n\"How do I verify my app hasn't been tampered with?\"\n\"DCAppAttestService attestKey keeps failing with serverUnavailable\"\n\"How do I prevent users from claiming a free trial multiple times?\"\n\"What's the difference between attestation and assertion?\"\n\"How do I validate an attestation object on my server?\"\n\"isSupported returns false — should I block the user?\"\n\"We have 2M DAU, how do I roll out App Attest safely?\"\n\"How do I detect if someone is creating fake app instances?\"\n\n## Red Flags\n\nSigns you're headed for trouble:\n\n- **Validating app integrity on-device** — Modified apps control the runtime. Any local check can be patched out. Verification MUST happen server-side.\n- **Not guarding with isSupported** — DCAppAttestService crashes on unsupported devices. Always check before calling any API.\n- **Blocking users when isSupported returns false** — Some legitimate devices return false. Treat as risk signal, not hard block.\n- **Reusing keys across multiple users on same device** — One key per user per device. Shared keys break account-level trust association.\n- **Enabling App Attest for all users at once** — `attestKey` calls Apple's servers. At scale, rate limiting causes failures. Gradual rollout required (WWDC 2021-10244).\n- **Using assertions for every API call** — Cryptographic cost per call. Reserve for sensitive operations (purchases, account changes), not routine fetches.\n- **Discarding key on serverUnavailable error** — Transient Apple server issue. Retry with same key. Only discard on other errors.\n- **Skipping counter validation on server** — Counter must be ever-increasing. Without this, replay attacks succeed.\n\n## Three Properties Verified\n\nApp Attest proves three things about each request:\n\n| Property | What It Proves | How |\n|----------|---------------|-----|\n| Genuine device | Request comes from real Apple hardware | Hardware-backed key in Secure Enclave |\n| Genuine app | Your app binary, unmodified | App identity hash in attestation |\n| Untampered payload | Request data hasn't been altered | Digest signing in assertions |\n\n**Privacy design**: Anonymous. No hardware identifiers. Keys don't survive reinstall\u002Fmigration\u002Frestore. Apple can't correlate across apps or users.\n\n## Key Generation\n\n```swift\nimport DeviceCheck\n\nfunc generateAppAttestKey(for userId: String) async throws -> String {\n    let service = DCAppAttestService.shared\n\n    guard service.isSupported else {\n        \u002F\u002F NOT an error — use as risk signal, not blocker\n        reportUnattestedDevice()\n        throw AppAttestError.unsupported\n    }\n\n    let keyId = try await service.generateKey()\n    \u002F\u002F Cache persistently — one key per user per device\n    UserDefaults.standard.set(keyId, forKey: \"appAttestKeyId_\\(userId)\")\n    return keyId\n}\n```\n\n**Key lifecycle**: One key per user per device. Cache `keyId` persistently (Keychain or UserDefaults). Keys don't survive reinstall, migration, or restore. App Clips share identity with full app. Generate new key on sign-out.\n\n## Attestation Flow\n\nAttestation registers the key with Apple and your server. Happens once per key.\n\n```dot\ndigraph attestation {\n    \"Server issues\\nchallenge\" [shape=ellipse];\n    \"SHA256 hash\\nchallenge\" [shape=box];\n    \"attestKey API\\n(Apple servers)\" [shape=box];\n    \"Send attestation\\nto your server\" [shape=box];\n    \"Server validates\\ncertificate chain\" [shape=box];\n    \"Store public key\\n+ key association\" [shape=doublecircle];\n\n    \"Error?\" [shape=diamond];\n    \"serverUnavailable?\" [shape=diamond];\n    \"Retry same key\" [shape=box];\n    \"Discard key\\ngenerate new\" [shape=box];\n\n    \"Server issues\\nchallenge\" -> \"SHA256 hash\\nchallenge\";\n    \"SHA256 hash\\nchallenge\" -> \"attestKey API\\n(Apple servers)\";\n    \"attestKey API\\n(Apple servers)\" -> \"Error?\" ;\n    \"Error?\" -> \"Send attestation\\nto your server\" [label=\"success\"];\n    \"Error?\" -> \"serverUnavailable?\" [label=\"error\"];\n    \"serverUnavailable?\" -> \"Retry same key\" [label=\"yes\"];\n    \"serverUnavailable?\" -> \"Discard key\\ngenerate new\" [label=\"no\"];\n    \"Send attestation\\nto your server\" -> \"Server validates\\ncertificate chain\";\n    \"Server validates\\ncertificate chain\" -> \"Store public key\\n+ key association\";\n}\n```\n\n```swift\nfunc attestKey(userId: String) async throws {\n    guard let keyId = storedKeyId(for: userId) else {\n        throw AppAttestError.noKey\n    }\n\n    \u002F\u002F 1. Get one-time challenge from YOUR server (minimum 16 bytes)\n    let challenge = try await server.fetchAttestationChallenge()\n\n    \u002F\u002F 2. Hash the challenge\n    let hash = Data(SHA256.hash(data: challenge))\n\n    \u002F\u002F 3. Request attestation from Apple\n    do {\n        let attestation = try await service.attestKey(keyId, clientDataHash: hash)\n        \u002F\u002F 4. Send attestation object to YOUR server for validation\n        try await server.verifyAttestation(attestation, keyId: keyId, challenge: challenge)\n    } catch DCError.serverUnavailable {\n        \u002F\u002F Transient — retry with SAME key later\n        scheduleAttestationRetry(keyId: keyId, userId: userId)\n    } catch {\n        \u002F\u002F Other error — key is compromised or invalid\n        \u002F\u002F Discard and generate a new key\n        clearStoredKey(for: userId)\n        try await generateAndAttestNewKey(userId: userId)\n    }\n}\n```\n\n**Challenge requirements**: Server-generated, single-use, minimum 16 bytes, short-lived (expire after minutes, not hours).\n\n## Assertion Flow\n\nAssertions prove ongoing request integrity. No Apple server involvement — on-device only.\n\n```swift\nfunc assertRequest(payload: Data, userId: String) async throws -> Data {\n    guard let keyId = storedKeyId(for: userId) else {\n        throw AppAttestError.noKey\n    }\n\n    \u002F\u002F Hash the payload you want to protect\n    let hash = Data(SHA256.hash(data: payload))\n\n    \u002F\u002F Generate assertion (on-device, no network)\n    let assertion = try await service.generateAssertion(keyId, clientDataHash: hash)\n\n    \u002F\u002F Send assertion + original payload to server\n    \u002F\u002F Server verifies signature and checks counter\n    return assertion\n}\n```\n\n**When to assert**: Reserve for moments that cost you money or trust if faked.\n\n| Assert | Don't Assert |\n|--------|-------------|\n| In-app purchases | Content fetches |\n| Account changes (email, password) | Read-only API calls |\n| Competitive actions (leaderboard scores) | Analytics events |\n| Promotional claims (free trial) | UI configuration |\n| Reward redemptions | Search queries |\n\n**Performance**: Secure Enclave operations. Fast enough for individual actions, expensive on every request.\n\n## Server-Side Validation\n\nYour server does the actual trust verification. The app only generates cryptographic material.\n\n### Attestation Validation (once per key)\n\n1. **Certificate chain** — Verify roots to Apple's App Attest root CA (Apple Private PKI)\n2. **Nonce** — Recompute SHA256(challenge || clientDataHash), match against credential certificate\n3. **App identity hash** — SHA256(teamId + \".\" + bundleId) must match your app\n4. **Counter** — Store initial value (assertions increment from here)\n5. **Key association** — Extract and store public key, associate with user account\n\n### Assertion Validation (per sensitive request)\n\n1. **Signature** — Verify using stored public key from attestation\n2. **App identity hash** — Must match attestation's hash (prevents cross-app replay)\n3. **Counter** — Must be strictly greater than last seen value (replay protection)\n4. **Client data hash** — Recompute from request payload, must match what was signed\n\n**Counter is critical**: Without strictly-increasing counter validation, replay attacks succeed indefinitely.\n\n## Rollout Strategy\n\nFrom WWDC 2021-10244: `attestKey` makes a network call to Apple's servers. Apple rate-limits these calls per app.\n\n| Install Base | Recommended Ramp Time |\n|-------------|----------------------|\n| \u003C100K DAU | Days |\n| ~1M DAU | ~1 day gradual ramp |\n| ~100M DAU | Weeks |\n| ~1B DAU | 1+ month gradual ramp |\n\n### Gradual Enablement Pattern\n\n```swift\nfunc shouldEnableAppAttest(userId: String) -> Bool {\n    guard DCAppAttestService.shared.isSupported else { return false }\n    \u002F\u002F Server controls rollout percentage — start at 1%, ramp daily\n    return server.isAppAttestEnabled(for: userId)\n}\n```\n\n**Rollout process**: Start at 1%. Monitor attestation success rate. If above 95%, double daily. If rate limiting errors spike, pause. Treat unattested requests as lower-trust during rollout (additional fraud signals), not blocked.\n\n## DeviceCheck Integration\n\nDeviceCheck stores 2 bits of state per device on Apple's servers. Different purpose from App Attest.\n\n| Feature | App Attest | DeviceCheck |\n|---------|-----------|-------------|\n| Purpose | Verify app integrity | Track per-device state |\n| Survives reinstall | No | Yes (tied to hardware) |\n| Apple servers | Attestation only | Every query |\n\n### Promotional Fraud Prevention\n\n```swift\nimport DeviceCheck\n\nfunc checkTrialEligibility() async throws -> Bool {\n    guard DCDevice.current.isSupported else { return true }\n\n    let token = try await DCDevice.current.generateToken()\n    \u002F\u002F Server calls Apple: POST https:\u002F\u002Fapi.devicecheck.apple.com\u002Fv1\u002Fquery_two_bits\n    let state = try await server.queryDeviceState(token: token)\n    return !state.bit0  \u002F\u002F bit0 = has claimed trial\n}\n\nfunc markTrialClaimed() async throws {\n    let token = try await DCDevice.current.generateToken()\n    \u002F\u002F Server calls Apple: POST https:\u002F\u002Fapi.devicecheck.apple.com\u002Fv1\u002Fupdate_two_bits\n    try await server.updateDeviceState(token: token, bit0: true)\n}\n```\n\n**2 bits, your rules**: Apple stores bits + timestamp. Semantics are yours (e.g., bit0=trial claimed, bit1=abuse flagged). Reset on your schedule. Shared across all apps from the same developer team — coordinate meaning across your portfolio.\n\n## Risk Metric Service\n\nAfter attestation, redeem the receipt with Apple to get risk metrics:\n\n**Server-side**: POST receipt to `https:\u002F\u002Fdata.appattest.apple.com\u002Fv1\u002FattestationData` (use `data-development.appattest.apple.com` for sandbox). Response includes approximate key count for the device.\n\n**How to use**: Most devices have 1-3 keys. High key counts signal an attacker creating many fake identities. Redeem periodically (Apple rate-limits), establish a baseline for your app, and combine with other fraud signals (velocity, behavioral analysis).\n\n## Anti-Rationalization Table\n\n| Rationalization | Why It Fails | What To Do Instead |\n|----------------|-------------|-------------------|\n| \"We'll validate integrity on-device\" | Modified apps control the runtime and can patch out any local check | All validation on your server. Device only generates crypto material. |\n| \"isSupported is always true on modern devices\" | Some configurations and enterprise MDM setups return false | Always guard. Handle false as risk signal, not crash. |\n| \"One key per device is enough\" | Multi-user devices need per-user keys for accurate account association | One key per user per device. New key on sign-out. |\n| \"We'll enable App Attest for everyone on launch day\" | Apple rate-limits attestKey calls. Large install bases will see widespread failures. | Server-controlled gradual rollout. Monitor success rate. |\n| \"Assert every API call for maximum security\" | Secure Enclave operations have real cost. Assertion latency on every request degrades UX. | Assert sensitive operations only. Use session tokens for routine calls. |\n| \"serverUnavailable means the key is bad\" | It's a transient Apple server issue. Discarding the key forces re-attestation unnecessarily. | Retry with same key. Only discard on non-transient errors. |\n| \"We don't need counter validation\" | Without strictly-increasing counters, replay attacks succeed indefinitely. | Store counter server-side. Reject assertions with counter \u003C= last seen. |\n| \"DeviceCheck replaces App Attest\" | DeviceCheck is 2-bit state storage, not integrity verification. Different threat models. | Use both: App Attest for integrity, DeviceCheck for per-device flags. |\n\n## Pressure Scenarios\n\n### Scenario 1: \"Block users who fail attestation\"\n\n**Pressure**: \"If they can't attest, they're probably running a modified app. Block them.\"\n\n**Reality**: `isSupported` returns false on legitimate devices (older hardware, enterprise MDM, simulator). During rollout, most users simply haven't been enrolled yet. Blocking = blocking real customers.\n\n**Correct action**: Trust tiers on server. Attested = high trust. Unattested = lower trust with additional fraud signals. Never hard-block on attestation failure alone.\n\n**Push-back template**: \"Some legitimate devices return isSupported=false. Let's use attestation as one signal in a risk score — high trust for attested, additional checks for unattested.\"\n\n### Scenario 2: \"Enable App Attest for everyone at once\"\n\n**Pressure**: \"We've been building this for weeks. Ship it to everyone.\"\n\n**Reality**: `attestKey` calls Apple's servers. Apple rate-limits per app. At 5M DAU, flipping the switch causes a thundering herd — mass failures, error floods, confused users. WWDC 2021-10244 explicitly recommends gradual rollout.\n\n**Correct action**: Server-controlled rollout starting at 1%. At 5M DAU, expect ~1 week to full rollout.\n\n**Push-back template**: \"Apple rate-limits attestKey calls — their WWDC session recommends gradual rollout. I'll set up server-side percentage control starting at 1%, ramping to 100% over about a week.\"\n\n## Checklist\n\nBefore shipping App Attest:\n\n**Key Generation**:\n- [ ] `isSupported` checked before any DCAppAttestService call\n- [ ] Graceful handling when `isSupported` returns false (risk signal, not block)\n- [ ] Key ID cached persistently per user\n- [ ] One key per user per device (not shared)\n\n**Attestation**:\n- [ ] Challenge from server is single-use, minimum 16 bytes, short-lived\n- [ ] `serverUnavailable` retries with same key\n- [ ] Other errors discard key and generate new\n- [ ] Attestation object sent to server for validation (not validated on-device)\n\n**Assertion**:\n- [ ] Used only for sensitive operations (not every API call)\n- [ ] Payload hash covers the actual request data being protected\n- [ ] Server validates signature with stored public key\n- [ ] Server validates counter is strictly increasing\n\n**Server**:\n- [ ] Certificate chain validated against Apple's App Attest root CA\n- [ ] App identity hash (teamId + bundleId) verified\n- [ ] Counter stored and checked for strict increase\n- [ ] Public key associated with user account\n\n**Rollout**:\n- [ ] Server-controlled percentage (not client-side)\n- [ ] Gradual ramp with monitoring\n- [ ] Unattested users handled gracefully (lower trust, not blocked)\n- [ ] Rollback plan if attestation success rate drops\n\n## Resources\n\n**WWDC**: 2021-10244\n\n**Docs**: \u002Fdevicecheck, \u002Fdevicecheck\u002Festablishing-your-app-s-integrity, \u002Fdevicecheck\u002Fvalidating-apps-that-connect-to-your-server\n\n**Skills**: axiom-cryptokit\n","# App Attest\n\nDevice-backed app integrity verification for fraud prevention. Proves three things to your server: the request came from a genuine Apple device, running your genuine app, with an untampered payload.\n\n## When to Use This Skill\n\nUse when you need to:\n- Verify requests come from legitimate app instances (not modified\u002Fcloned apps)\n- Prevent fraud in purchases, promotions, or competitive features\n- Implement DCAppAttestService attestation or assertion flows\n- Handle DeviceCheck 2-bit per-device state for promotional abuse\n- Build server-side validation for attestation objects or assertion signatures\n- Plan a gradual App Attest rollout for a large install base\n\n## Example Prompts\n\n\"How do I verify my app hasn't been tampered with?\"\n\"DCAppAttestService attestKey keeps failing with serverUnavailable\"\n\"How do I prevent users from claiming a free trial multiple times?\"\n\"What's the difference between attestation and assertion?\"\n\"How do I validate an attestation object on my server?\"\n\"isSupported returns false — should I block the user?\"\n\"We have 2M DAU, how do I roll out App Attest safely?\"\n\"How do I detect if someone is creating fake app instances?\"\n\n## Red Flags\n\nSigns you're headed for trouble:\n\n- **Validating app integrity on-device** — Modified apps control the runtime. Any local check can be patched out. Verification MUST happen server-side.\n- **Not guarding with isSupported** — DCAppAttestService crashes on unsupported devices. Always check before calling any API.\n- **Blocking users when isSupported returns false** — Some legitimate devices return false. Treat as risk signal, not hard block.\n- **Reusing keys across multiple users on same device** — One key per user per device. Shared keys break account-level trust association.\n- **Enabling App Attest for all users at once** — `attestKey` calls Apple's servers. At scale, rate limiting causes failures. Gradual rollout required (WWDC 2021-10244).\n- **Using assertions for every API call** — Cryptographic cost per call. Reserve for sensitive operations (purchases, account changes), not routine fetches.\n- **Discarding key on serverUnavailable error** — Transient Apple server issue. Retry with same key. Only discard on other errors.\n- **Skipping counter validation on server** — Counter must be ever-increasing. Without this, replay attacks succeed.\n\n## Three Properties Verified\n\nApp Attest proves three things about each request:\n\n| Property | What It Proves | How |\n|----------|---------------|-----|\n| Genuine device | Request comes from real Apple hardware | Hardware-backed key in Secure Enclave |\n| Genuine app | Your app binary, unmodified | App identity hash in attestation |\n| Untampered payload | Request data hasn't been altered | Digest signing in assertions |\n\n**Privacy design**: Anonymous. No hardware identifiers. Keys don't survive reinstall\u002Fmigration\u002Frestore. Apple can't correlate across apps or users.\n\n## Key Generation\n\n```swift\nimport DeviceCheck\n\nfunc generateAppAttestKey(for userId: String) async throws -> String {\n    let service = DCAppAttestService.shared\n\n    guard service.isSupported else {\n        \u002F\u002F NOT an error — use as risk signal, not blocker\n        reportUnattestedDevice()\n        throw AppAttestError.unsupported\n    }\n\n    let keyId = try await service.generateKey()\n    \u002F\u002F Cache persistently — one key per user per device\n    UserDefaults.standard.set(keyId, forKey: \"appAttestKeyId_\\(userId)\")\n    return keyId\n}\n```\n\n**Key lifecycle**: One key per user per device. Cache `keyId` persistently (Keychain or UserDefaults). Keys don't survive reinstall, migration, or restore. App Clips share identity with full app. Generate new key on sign-out.\n\n## Attestation Flow\n\nAttestation registers the key with Apple and your server. Happens once per key.\n\n```dot\ndigraph attestation {\n    \"Server issues\\nchallenge\" [shape=ellipse];\n    \"SHA256 hash\\nchallenge\" [shape=box];\n    \"attestKey API\\n(Apple servers)\" [shape=box];\n    \"Send attestation\\nto your server\" [shape=box];\n    \"Server validates\\ncertificate chain\" [shape=box];\n    \"Store public key\\n+ key association\" [shape=doublecircle];\n\n    \"Error?\" [shape=diamond];\n    \"serverUnavailable?\" [shape=diamond];\n    \"Retry same key\" [shape=box];\n    \"Discard key\\ngenerate new\" [shape=box];\n\n    \"Server issues\\nchallenge\" -> \"SHA256 hash\\nchallenge\";\n    \"SHA256 hash\\nchallenge\" -> \"attestKey API\\n(Apple servers)\";\n    \"attestKey API\\n(Apple servers)\" -> \"Error?\" ;\n    \"Error?\" -> \"Send attestation\\nto your server\" [label=\"success\"];\n    \"Error?\" -> \"serverUnavailable?\" [label=\"error\"];\n    \"serverUnavailable?\" -> \"Retry same key\" [label=\"yes\"];\n    \"serverUnavailable?\" -> \"Discard key\\ngenerate new\" [label=\"no\"];\n    \"Send attestation\\nto your server\" -> \"Server validates\\ncertificate chain\";\n    \"Server validates\\ncertificate chain\" -> \"Store public key\\n+ key association\";\n}\n```\n\n```swift\nfunc attestKey(userId: String) async throws {\n    guard let keyId = storedKeyId(for: userId) else {\n        throw AppAttestError.noKey\n    }\n\n    \u002F\u002F 1. Get one-time challenge from YOUR server (minimum 16 bytes)\n    let challenge = try await server.fetchAttestationChallenge()\n\n    \u002F\u002F 2. Hash the challenge\n    let hash = Data(SHA256.hash(data: challenge))\n\n    \u002F\u002F 3. Request attestation from Apple\n    do {\n        let attestation = try await service.attestKey(keyId, clientDataHash: hash)\n        \u002F\u002F 4. Send attestation object to YOUR server for validation\n        try await server.verifyAttestation(attestation, keyId: keyId, challenge: challenge)\n    } catch DCError.serverUnavailable {\n        \u002F\u002F Transient — retry with SAME key later\n        scheduleAttestationRetry(keyId: keyId, userId: userId)\n    } catch {\n        \u002F\u002F Other error — key is compromised or invalid\n        \u002F\u002F Discard and generate a new key\n        clearStoredKey(for: userId)\n        try await generateAndAttestNewKey(userId: userId)\n    }\n}\n```\n\n**Challenge requirements**: Server-generated, single-use, minimum 16 bytes, short-lived (expire after minutes, not hours).\n\n## Assertion Flow\n\nAssertions prove ongoing request integrity. No Apple server involvement — on-device only.\n\n```swift\nfunc assertRequest(payload: Data, userId: String) async throws -> Data {\n    guard let keyId = storedKeyId(for: userId) else {\n        throw AppAttestError.noKey\n    }\n\n    \u002F\u002F Hash the payload you want to protect\n    let hash = Data(SHA256.hash(data: payload))\n\n    \u002F\u002F Generate assertion (on-device, no network)\n    let assertion = try await service.generateAssertion(keyId, clientDataHash: hash)\n\n    \u002F\u002F Send assertion + original payload to server\n    \u002F\u002F Server verifies signature and checks counter\n    return assertion\n}\n```\n\n**When to assert**: Reserve for moments that cost you money or trust if faked.\n\n| Assert | Don't Assert |\n|--------|-------------|\n| In-app purchases | Content fetches |\n| Account changes (email, password) | Read-only API calls |\n| Competitive actions (leaderboard scores) | Analytics events |\n| Promotional claims (free trial) | UI configuration |\n| Reward redemptions | Search queries |\n\n**Performance**: Secure Enclave operations. Fast enough for individual actions, expensive on every request.\n\n## Server-Side Validation\n\nYour server does the actual trust verification. The app only generates cryptographic material.\n\n### Attestation Validation (once per key)\n\n1. **Certificate chain** — Verify roots to Apple's App Attest root CA (Apple Private PKI)\n2. **Nonce** — Recompute SHA256(challenge || clientDataHash), match against credential certificate\n3. **App identity hash** — SHA256(teamId + \".\" + bundleId) must match your app\n4. **Counter** — Store initial value (assertions increment from here)\n5. **Key association** — Extract and store public key, associate with user account\n\n### Assertion Validation (per sensitive request)\n\n1. **Signature** — Verify using stored public key from attestation\n2. **App identity hash** — Must match attestation's hash (prevents cross-app replay)\n3. **Counter** — Must be strictly greater than last seen value (replay protection)\n4. **Client data hash** — Recompute from request payload, must match what was signed\n\n**Counter is critical**: Without strictly-increasing counter validation, replay attacks succeed indefinitely.\n\n## Rollout Strategy\n\nFrom WWDC 2021-10244: `attestKey` makes a network call to Apple's servers. Apple rate-limits these calls per app.\n\n| Install Base | Recommended Ramp Time |\n|-------------|----------------------|\n| \u003C100K DAU | Days |\n| ~1M DAU | ~1 day gradual ramp |\n| ~100M DAU | Weeks |\n| ~1B DAU | 1+ month gradual ramp |\n\n### Gradual Enablement Pattern\n\n```swift\nfunc shouldEnableAppAttest(userId: String) -> Bool {\n    guard DCAppAttestService.shared.isSupported else { return false }\n    \u002F\u002F Server controls rollout percentage — start at 1%, ramp daily\n    return server.isAppAttestEnabled(for: userId)\n}\n```\n\n**Rollout process**: Start at 1%. Monitor attestation success rate. If above 95%, double daily. If rate limiting errors spike, pause. Treat unattested requests as lower-trust during rollout (additional fraud signals), not blocked.\n\n## DeviceCheck Integration\n\nDeviceCheck stores 2 bits of state per device on Apple's servers. Different purpose from App Attest.\n\n| Feature | App Attest | DeviceCheck |\n|---------|-----------|-------------|\n| Purpose | Verify app integrity | Track per-device state |\n| Survives reinstall | No | Yes (tied to hardware) |\n| Apple servers | Attestation only | Every query |\n\n### Promotional Fraud Prevention\n\n```swift\nimport DeviceCheck\n\nfunc checkTrialEligibility() async throws -> Bool {\n    guard DCDevice.current.isSupported else { return true }\n\n    let token = try await DCDevice.current.generateToken()\n    \u002F\u002F Server calls Apple: POST https:\u002F\u002Fapi.devicecheck.apple.com\u002Fv1\u002Fquery_two_bits\n    let state = try await server.queryDeviceState(token: token)\n    return !state.bit0  \u002F\u002F bit0 = has claimed trial\n}\n\nfunc markTrialClaimed() async throws {\n    let token = try await DCDevice.current.generateToken()\n    \u002F\u002F Server calls Apple: POST https:\u002F\u002Fapi.devicecheck.apple.com\u002Fv1\u002Fupdate_two_bits\n    try await server.updateDeviceState(token: token, bit0: true)\n}\n```\n\n**2 bits, your rules**: Apple stores bits + timestamp. Semantics are yours (e.g., bit0=trial claimed, bit1=abuse flagged). Reset on your schedule. Shared across all apps from the same developer team — coordinate meaning across your portfolio.\n\n## Risk Metric Service\n\nAfter attestation, redeem the receipt with Apple to get risk metrics:\n\n**Server-side**: POST receipt to `https:\u002F\u002Fdata.appattest.apple.com\u002Fv1\u002FattestationData` (use `data-development.appattest.apple.com` for sandbox). Response includes approximate key count for the device.\n\n**How to use**: Most devices have 1-3 keys. High key counts signal an attacker creating many fake identities. Redeem periodically (Apple rate-limits), establish a baseline for your app, and combine with other fraud signals (velocity, behavioral analysis).\n\n## Anti-Rationalization Table\n\n| Rationalization | Why It Fails | What To Do Instead |\n|----------------|-------------|-------------------|\n| \"We'll validate integrity on-device\" | Modified apps control the runtime and can patch out any local check | All validation on your server. Device only generates crypto material. |\n| \"isSupported is always true on modern devices\" | Some configurations and enterprise MDM setups return false | Always guard. Handle false as risk signal, not crash. |\n| \"One key per device is enough\" | Multi-user devices need per-user keys for accurate account association | One key per user per device. New key on sign-out. |\n| \"We'll enable App Attest for everyone on launch day\" | Apple rate-limits attestKey calls. Large install bases will see widespread failures. | Server-controlled gradual rollout. Monitor success rate. |\n| \"Assert every API call for maximum security\" | Secure Enclave operations have real cost. Assertion latency on every request degrades UX. | Assert sensitive operations only. Use session tokens for routine calls. |\n| \"serverUnavailable means the key is bad\" | It's a transient Apple server issue. Discarding the key forces re-attestation unnecessarily. | Retry with same key. Only discard on non-transient errors. |\n| \"We don't need counter validation\" | Without strictly-increasing counters, replay attacks succeed indefinitely. | Store counter server-side. Reject assertions with counter \u003C= last seen. |\n| \"DeviceCheck replaces App Attest\" | DeviceCheck is 2-bit state storage, not integrity verification. Different threat models. | Use both: App Attest for integrity, DeviceCheck for per-device flags. |\n\n## Pressure Scenarios\n\n### Scenario 1: \"Block users who fail attestation\"\n\n**Pressure**: \"If they can't attest, they're probably running a modified app. Block them.\"\n\n**Reality**: `isSupported` returns false on legitimate devices (older hardware, enterprise MDM, simulator). During rollout, most users simply haven't been enrolled yet. Blocking = blocking real customers.\n\n**Correct action**: Trust tiers on server. Attested = high trust. Unattested = lower trust with additional fraud signals. Never hard-block on attestation failure alone.\n\n**Push-back template**: \"Some legitimate devices return isSupported=false. Let's use attestation as one signal in a risk score — high trust for attested, additional checks for unattested.\"\n\n### Scenario 2: \"Enable App Attest for everyone at once\"\n\n**Pressure**: \"We've been building this for weeks. Ship it to everyone.\"\n\n**Reality**: `attestKey` calls Apple's servers. Apple rate-limits per app. At 5M DAU, flipping the switch causes a thundering herd — mass failures, error floods, confused users. WWDC 2021-10244 explicitly recommends gradual rollout.\n\n**Correct action**: Server-controlled rollout starting at 1%. At 5M DAU, expect ~1 week to full rollout.\n\n**Push-back template**: \"Apple rate-limits attestKey calls — their WWDC session recommends gradual rollout. I'll set up server-side percentage control starting at 1%, ramping to 100% over about a week.\"\n\n## Checklist\n\nBefore shipping App Attest:\n\n**Key Generation**:\n- [ ] `isSupported` checked before any DCAppAttestService call\n- [ ] Graceful handling when `isSupported` returns false (risk signal, not block)\n- [ ] Key ID cached persistently per user\n- [ ] One key per user per device (not shared)\n\n**Attestation**:\n- [ ] Challenge from server is single-use, minimum 16 bytes, short-lived\n- [ ] `serverUnavailable` retries with same key\n- [ ] Other errors discard key and generate new\n- [ ] Attestation object sent to server for validation (not validated on-device)\n\n**Assertion**:\n- [ ] Used only for sensitive operations (not every API call)\n- [ ] Payload hash covers the actual request data being protected\n- [ ] Server validates signature with stored public key\n- [ ] Server validates counter is strictly increasing\n\n**Server**:\n- [ ] Certificate chain validated against Apple's App Attest root CA\n- [ ] App identity hash (teamId + bundleId) verified\n- [ ] Counter stored and checked for strict increase\n- [ ] Public key associated with user account\n\n**Rollout**:\n- [ ] Server-controlled percentage (not client-side)\n- [ ] Gradual ramp with monitoring\n- [ ] Unattested users handled gracefully (lower trust, not blocked)\n- [ ] Rollback plan if attestation success rate drops\n\n## Resources\n\n**WWDC**: 2021-10244\n\n**Docs**: \u002Fdevicecheck, \u002Fdevicecheck\u002Festablishing-your-app-s-integrity, \u002Fdevicecheck\u002Fvalidating-apps-that-connect-to-your-server\n\n**Skills**: axiom-cryptokit\n",{"name":5,"license":15,"description":7},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002FCharlesWiltgen\u002FAxiom\u002Faxiom-app-attest",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill axiom-app-attest",{"tool":57,"command":58},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill axiom-app-attest",{"tool":60,"command":61},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill axiom-app-attest","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FCharlesWiltgen\u002FAxiom\u002Faxiom-app-attest\u002FSKILL.md",true,[],[66,75,84,93,99,105],{"skillNo":67,"name":68,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":37},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[72,73,74],"model","model hierarchy","model hierarchy skill",{"skillNo":76,"name":77,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":37},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[81,82,83],"MCP","zoom","zoom mcp",{"skillNo":85,"name":86,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":37},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[90,91,92,82],"sdk","zoom apps sdk","apps",{"skillNo":94,"name":95,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":37},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[95],{"skillNo":100,"name":101,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":37},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[101],{"skillNo":106,"name":107,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":37},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[107]]