Log date · Mon
Does App Attest protect offline app logic?
Published on · Updated
No. App Attest helps a server validate requests; it does not protect logic that executes entirely offline.
The short answer: protect requests, not offline logic
App Attest helps your server assess whether a request comes from a valid instance of your app. It does not hide or enforce an algorithm that runs entirely on the device. Key attestation contacts Apple; later assertions are generated on the device and verified by your server. [1][2]
We compare two paths in a fictional quoting app: claiming premium quota online and calculating a quote without a connection. This is a worked example based on Apple’s documentation; the snippets and verification flow were not executed. This Mac has Xcode 27.2 and Swift 6.4.2, but we did not establish the complete real-device, Apple-service and app-server chain.
| Question | Finding |
|---|---|
| Online quota | The server can verify an assertion before granting quota. |
| Offline quote | No server participates in the decision; the rules still ship in the app. |
| Assertion passes | A signal tied to the request, not user authorization or correct business data. |
First connection: attest the key
Suppose a user first enables online quota. The app checks isSupported, creates a key for that user on that device, and persists the key ID. The server issues and remembers a random, single-use challenge. The app hashes the challenge with SHA-256 and calls attestKey. The Apple service returns an attestation object, which the app sends with the key ID to its own server. [1]
let service = DCAppAttestService.shared
guard service.isSupported else { return }
let keyID = try await service.generateKey()
let challenge = try await fetchChallengeFromOurServer()
let hash = Data(SHA256.hash(data: challenge))
let attestation = try await service.attestKey(keyID, clientDataHash: hash)
try await sendAttestationToOurServer(keyID, attestation)The server must verify independently instead of trusting a client’s “success” flag. Apple calls for checking the CBOR structure and certificate chain against the App Attest root, recomputing the nonce and matching the certificate extension, then checking the public key against the key ID, App ID hash, initial counter, environment, credential ID and the documented extension fields. [2]
attestation = decode_expected_cbor(object)
verify_chain(attestation.x5c, APPLE_APP_ATTEST_ROOT)
nonce = SHA256(authData || SHA256(saved_challenge))
require certificate_nonce(attestation) == nonce
require public_key_hash_matches(keyID)
require rp_id_matches(appID) and counter == 0
require environment_and_credential_id_match()
require expected_validation_category_and_bundle_version()
verify_and_store_receipt(); store_public_key_for_user_device()
consume_challenge_once()Only after all checks pass, store the public key and independently verified receipt against the user and device. Keep development and production records separate, and allow for multiple devices per user. Bind each challenge to the right session, expire it and consume it once so concurrent requests cannot both use it.
Later requests: bind an assertion to the operation
To claim quota, the app obtains another single-use challenge and encodes the operation, quantity, account context and challenge as clientData. It hashes those exact bytes and calls generateAssertion. The server receives those same bytes and the assertion and verifies them with the stored public key. [1][3] If the signed data contains only an “app valid” flag, the server cannot use it to establish that the quantity and other fields were bound to the assertion.
clientData = encode({action: "claimQuota", units: 10, challenge: serverChallenge})
assertion = generateAssertion(keyID, SHA256(clientData))
send(keyID, clientData, assertion)require challenge_is_pending_for_session(clientData.challenge)
parse assertion as expected CBOR
nonce = SHA256(authenticatorData || SHA256(clientData))
verify_signature(stored_public_key, nonce, signature)
require rp_id_matches(appID)
require counter > stored_counter
require expected_validation_category_and_bundle_version()
atomically consume_challenge_and_save_counter()
authorize_user_and_check_quota_then_execute(clientData)The server also checks the challenge, App ID, increasing counter and extension fields, then saves the new counter. [2] For concurrent requests using the same key, make the counter and challenge checks and updates atomic; define how expired, replayed and out-of-order requests are handled. A valid signature does not replace login, authorization, quota accounting or business validation.
The server should verify the received clientData bytes, then parse and execute the business operation. Agree on encoding, fields and versioning so client and server cannot interpret one request differently. Log verification categories and failure reasons without recording credentials or sensitive user content.
What remains when the app is offline
Now take the second path: the user enables airplane mode and a local function calculates a quote from a quantity and discount table. Even if attestation succeeded earlier, calculation and display still happen on the user’s device without a server approving each operation. A certificate or signature does not turn a discount table shipped with the app into a server secret.
| Question | Finding |
|---|---|
| Online request origin signal | After validation, usable in the server’s risk decision. |
| Request data and freshness | Signature, one-time challenge and counter support binding and replay resistance. |
| Local algorithm and rules | No confidentiality; offline execution does not pass through server validation. |
| Account access and abuse | Still requires authentication, authorization, limits and risk policy. |
If rules must remain confidential, server-side calculation offers a clearer boundary, at the cost of connectivity, latency, operating expense and offline usability. Another product choice is to accept that local rules can be studied while keeping valuable quota, synchronization or settlement on the server. Cached authorization can improve offline use, but requires an explicit expiry, revocation delay and behavior when the device clock is unreliable.
Choose by business need and handle failures
These are engineering recommendations. Write down each feature’s offline requirements, failure experience and risk before choosing which requests deserve verification. Apple recommends checking device support, testing in the development environment and onboarding gradually; attestation can encounter network failures or throttling. [1][4]
| Question | Finding |
|---|---|
| High-value online quota | Verify assertions on the server alongside authentication, limits and monitoring. |
| Offline-only editing or calculation | Preserve offline use; assess exposure of local data and rules rather than treating attestation as secrecy. |
| Unsupported or temporarily unavailable | Choose fallback, deferred action or denial by risk, and explain it to the user. |
| Key invalidated or app reinstalled | Enroll a new device key; test account recovery and old-record cleanup. |
Distinguish unsupported devices, temporary unavailability and verification failure. For serverUnavailable, Apple says to retry attestation later with the same key; for other attestation errors, discard the key ID and generate a new one for the next attempt. [1] A product might fall back for a low-risk feature while deferring high-value quota, without treating a single network error as proof of abuse.
Keys survive ordinary updates, but reinstallation, migration or restoration from backup requires a new key. [1] Distinguish these normal lifecycle events from verification anomalies in monitoring, and design flows for a new device, sign-out and account recovery. During rollout, observe support, failure reasons and latency before expanding coverage.
Try the flow on your own app
Start with a device, your app and a test server in Apple’s development environment. Confirm that the App ID, environment and server trust root agree. For one online quota request, retain an auditable test record: build, device environment, whether the challenge was consumed, verification category and final business decision. Keep real challenges, receipts and account data out of public logs. [2][4]
Compare at least four paths: a normal request, resubmission of the same request, a changed signed quantity, and an offline local quote. The first three should respectively verify, be rejected and be rejected; the last should match the product’s offline contract. These are acceptance expectations; actual results depend on your implementation.
Also test an unsupported device, network failure, reinstallation and concurrent requests. Check that server failure reasons match what the user sees, and that rejection happens before quota is granted. Repeat the scenarios whenever encoding, verification or fallback policy changes.
Your checklist
- Separate high-value online requests from offline features.
- Issue and consume a one-time challenge for each attestation or assertion.
- Validate the certificate, identity, signature and counter on the server.
- Add account authorization, quota checks and a failure policy.
- Test replay, offline use, reinstallation and concurrency on real devices.
Primary sources
- Apple: Establishing your app’s integrity · Checked 2026-11-11
- Apple: Validating apps that connect to your server · Checked 2026-11-11
- Apple: generateAssertion · Checked 2026-11-11
- Apple: Preparing to use the App Attest service · Checked 2026-11-11