Native Attestation

Description

Native attestation is a DRM-like mechanism that proves an API request originated from an official Claude Code binary. The system works by embedding a cch=00000 placeholder string in the HTTP attribution header at the TypeScript layer, which Bun's native Zig HTTP stack then overwrites in-place with a computed hash before the request leaves the process. The server side verifies this token to confirm the request came from a real Claude Code client rather than a third-party tool or replay.

The implementation in constants/system.ts (getAttributionHeader) constructs the full x-anthropic-billing-header containing cc_version, cc_entrypoint, and conditionally the cch=00000 placeholder when the NATIVE_CLIENT_ATTESTATION build feature flag is enabled. The critical design decision is that the placeholder is the same length as the final hash value, so Bun's Zig layer can perform an in-place byte replacement without changing Content-Length or triggering buffer reallocation. The actual hash computation lives outside the TypeScript source -- in bun-anthropic/src/http/Attestation.zig -- where the Zig HTTP stack intercepts serialized request body bytes, finds the placeholder pattern, and overwrites it with the computed attestation token.

The attestation header also coexists with other attribution fields. A cc_workload field was later added for QoS routing (e.g., routing cron-initiated requests to a lower-priority pool). The code comments note that cc_workload is safe with respect to both fingerprint computation (computed from message chars + version only) and cch attestation (placeholder overwritten in serialized body bytes after the header string is built), and that the server's _parse_cc_header tolerates unknown extra fields so old API deploys silently ignore new additions.

Key claims

Relations

Sources

src-20260409-2e2e605ea18f src-20260410-attestation-a: src/constants/system.ts lines 59-95