Implementing Token Binding

1. Understanding Token Binding Concepts

ConceptDetail
GoalTie token to client cryptographic key — stolen token unusable elsewhere
MechanismToken includes cnf claim referencing public key / cert
ProofClient signs request or completes TLS handshake with bound key
SpecsRFC 8473 (TLS), RFC 7800 (cnf), DPoP (RFC 9449)

2. Implementing Proof-of-Possession Tokens

Example: DPoP header (RFC 9449)

// Client signs a JWT with its private key per request
const dpopProof = await new SignJWT({
  htu: "https://api.example.com/orders",
  htm: "GET",
  jti: crypto.randomUUID(),
  iat: Math.floor(Date.now()/1000)
})
.setProtectedHeader({ alg: "ES256", typ: "dpop+jwt", jwk: publicJwk })
.sign(privateKey);

fetch("/orders", {
  headers: {
    "Authorization": "DPoP " + accessToken,
    "DPoP": dpopProof
  }
});

3. Using TLS Token Binding

AspectDetail
SpecRFC 8471/8472/8473 LIMITED
StatusChrome removed support; DPoP/mTLS preferred today
ReplacementDPoP, mTLS-bound tokens (RFC 8705)

4. Preventing Token Theft

LayerDefense
StorageHttpOnly cookies, OS secure storage
TransportHTTPS + HSTS + cert pinning
BindingDPoP, mTLS-bound tokens
DetectionAnomaly detection (IP/device changes)
LifetimeShort-lived access tokens

5. Implementing Device-Bound Tokens

ApproachDetail
Device keyGenerated in TPM / Secure Enclave
AttestationWebAuthn / Android Key Attestation proves key non-exportable
Token claimcnf: { "jkt": "<thumbprint>" }
DBSC NEWDevice Bound Session Credentials (Chrome experimental)

6. Using Channel Binding

Binding TypeDetail
tls-server-end-pointHash of TLS server cert
tls-uniqueTLS Finished message
tls-exporterRFC 9266, modern replacement for tls-unique
UseSASL, SCRAM, Kerberos GSS-API

7. Implementing Token Binding in OAuth

MethodSpecStatus (2026)
mTLS-bound tokensRFC 8705Enterprise, FAPI
DPoPRFC 9449Recommended for SPAs/mobile
PoP keysRFC 7800 (cnf)Underlying mechanism

8. Validating Token Binding

StepAction
1Extract cnf claim (e.g., jkt thumbprint)
2Read presented key (DPoP JWK, mTLS cert)
3Compute SHA-256 thumbprint, compare constant-time
4Verify proof signature over htu/htm/iat/jti
5Check jti freshness (anti-replay window)

9. Handling Token Binding Errors

ErrorCause
invalid_dpop_proofBad signature or wrong htu/htm
use_dpop_nonceServer requires nonce — retry with provided nonce
invalid_tokenjkt thumbprint mismatch
Replay detectedjti seen recently → reject

10. Understanding Token Binding vs Certificate Pinning

AspectToken BindingCert Pinning
BindsToken to client keyClient trust to server cert
LayerApplication (OAuth)Transport (TLS)
Protects againstToken theft / replayMitM, rogue CAs
Where usedAPI authMobile / IoT clients