Decoding WebAuthn Passkey CBOR (attestationObject, authenticatorData, COSE Keys) Without a Backend
When implementing Passkeys (WebAuthn), navigator.credentials.create() hands back an opaque Base64URL-encoded CBOR blob called attestationObject. When a server verifier rejects a registration with RP ID hash mismatch, UV
When implementing Passkeys (WebAuthn), navigator.credentials.create() hands back an opaque Base64URL-encoded CBOR blob called attestationObject. When a server verifier rejects a registration with RP ID hash mismatch, UV flag not set, or Unsupported COSE algorithm, console.log alone does not tell you which byte failed.
Here is the exact binary layout to inspect before blaming your server library.
1. Unwrapping attestationObject
After Base64URL-decoding response.attestationObject, the CBOR map contains three keys:
-
fmtβ attestation statement format ("none","packed","apple","tpm") -
attStmtβ attestation signature map -
authDataβ rawauthenticatorDatabyte buffer
2. The 37-Byte authenticatorData Header
Every WebAuthn registration and assertion starts with the same 37 bytes:
-
Bytes
0..31(32B):SHA-256(rpId)β must match your configured Relying Party ID (e.g.example.com, neverhttps://example.com) -
Byte
32(1B):flagsbitmask:-
0x01(UP): User Present -
0x04(UV): User Verified (biometric / PIN) -
0x08(BE): Backup Eligible (synced passkey) -
0x10(BS): Backup State -
0x40(AT): Attested Credential Data included
-
-
Bytes
33..36(4B): Big-endiansignCount
If your relying party policy requires userVerification: "required" and a hardware key returns flags = 0x41 (UP + AT, without UV 0x04), registration fails immediately.
3. Reading the Trailing COSE Public Key
When the AT bit (0x40) is set, authData continues with:
- 16-byte
aaguid(identifies the authenticator vendor/model) - 2-byte big-endian
credentialIdLength+credentialId - CBOR-encoded COSE Key (
alg: -7for ES256/P-256,alg: -257for RS256)
Inspecting Payloads Strictly Client-Side
Because real WebAuthn registration blobs and JWKs should not be pasted into random remote decoders, I built a zero-upload browser inspector that parses CBOR, flags, AAGUID, and COSE keys entirely in local memory (0 bytes sent over the network):
- Passkey / WebAuthn CBOR Inspector: https://global-utils.com/en/passkey-inspector
- JWK / Key Inspector: https://global-utils.com/en/jwk-inspector
-
Open-Source MIT DevTools MCP Server (
nerdkit-mcp): https://github.com/JangYS0/nerdkit-mcp
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.