DEV Community

Jason Y. (dev_in_the_fog)
Jason Y. (dev_in_the_fog)

Posted on

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 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 — raw authenticatorData byte 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, never https://example.com)
  • Byte 32 (1B): flags bitmask:
    • 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-endian signCount

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:

  1. 16-byte aaguid (identifies the authenticator vendor/model)
  2. 2-byte big-endian credentialIdLength + credentialId
  3. CBOR-encoded COSE Key (alg: -7 for ES256/P-256, alg: -257 for 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):

Top comments (0)