Protects apps and APIs with DeviceCheck and App Attest. Use for per-device fraud state, App Attest key generation and attestation, request assertions, server verification, compromised-device signals, app authenticity, replay resistance, or sensitive endpoint protection.
94%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Verify that requests to your server originate from genuine Apple devices running legitimate instances of your app. DCDevice provides per-device bits for persistent state (e.g., promo redemption), while DCAppAttestService provides cryptographic proof of app authenticity using Secure Enclave keys.
Security Boundary: App Attest proves client hardware/app integrity; it does not replace user authentication, TLS, authorization, or certificate pinning. Always enforce user authentication after App Attest verification succeeds.
DCDevice generates ephemeral, single-use tokens sent to your backend, which communicates with Apple to read or update two per-device bits that persist across app reinstallation.
import DeviceCheck
func generateDeviceToken() async throws -> Data {
guard DCDevice.current.isSupported else {
throw DeviceIntegrityError.deviceCheckUnsupported
}
return try await DCDevice.current.generateToken()
}Treat each token as strictly single-use. Generate a fresh token for every server interaction.
Available on iOS 14+. Validates app-instance integrity through three stages:
let service = DCAppAttestService.shared
guard service.isSupported else { throw DeviceIntegrityError.unsupported }Generate a key and request attestation from Apple before sending it to your backend:
// 1. Generate key once and persist keyId
let keyId = try await service.generateKey()
// 2. Fetch one-time challenge from server
let challenge = try await fetchAttestationChallenge()
let clientDataHash = Data(SHA256.hash(data: challenge))
// 3. Attest key with Apple and send to server
let attestation = try await service.attestKey(keyId, clientDataHash: clientDataHash)
try await sendAttestationToServer(keyId: keyId, attestation: attestation)The server verifies the CBOR attestation object against Apple's App Attest root CA, checking that the certificate extension nonce matches SHA256(authData || SHA256(challenge)).
Sign request payloads and server challenges with the attested key to prove ongoing legitimacy:
// clientData contains one-time challenge + request context
let clientDataHash = Data(SHA256.hash(data: clientData))
let assertion = try await service.generateAssertion(keyId, clientDataHash: clientDataHash)
var request = URLRequest(url: endpointURL)
request.setValue(assertion.base64EncodedString(), forHTTPHeaderField: "X-App-Attest-Assertion")
request.setValue(clientData.base64EncodedString(), forHTTPHeaderField: "X-App-Attest-Client-Data")The server recomputes the hash, validates the assertion signature with the stored public key, and verifies the counter strictly increases to prevent replay attacks.
Handle DCError codes gracefully:
.serverUnavailable: Retry attestation with the same keyId and the same clientDataHash using exponential backoff..invalidKey: Discard the corrupted/rejected keyId and generate a fresh key before retrying..featureUnsupported: Fall back to DCDevice token validation or server-side risk scoring.keyId.SHA256(authData || SHA256(challenge)), not SHA256(challenge) alone.com.apple.developer.devicecheck.appattest-environment entitlement appropriately.DCAppAttestService.isSupported verified with fallback for unsupported devices/extensionskeyId persisted in Keychain.serverUnavailable retried with identical key/hash; .invalidKey regenerates keydevelopment vs production)thienqo/ios-skills
6bf8b62
Canonical home
since May 23, 2026
Also appears in
on Sep 6, 2026
since May 22, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.