Skip to content

docs: update HMAC-SHA256 webhook spec to match reference implementation - #1382

Merged
EmmaLouise2018 merged 2 commits into
adcontextprotocol:mainfrom
EmmaLouise2018:fix/webhook-hmac-spec
Mar 11, 2026
Merged

EmmaLouise2018 merged 2 commits into
adcontextprotocol:mainfrom
EmmaLouise2018:fix/webhook-hmac-spec

Conversation

@EmmaLouise2018

Copy link
Copy Markdown
Contributor

Summary

The HMAC-SHA256 webhook authentication section is missing several details that the @adcp/client reference implementation already requires. This causes interoperability issues — implementers following the spec produce code that doesn't match what the reference client libraries actually do.

Changes

Updates the HMAC-SHA256 section in docs/building/implementation/webhooks.mdx to document:

  • X-ADCP-Timestamp header — Unix timestamp in seconds for replay protection (5-minute window)
  • sha256= signature prefix — the signature format is sha256={hex_digest}, not bare hex
  • Signed message format — {unix_timestamp}.{rawBody}, not just rawBody
  • Constant-time comparison — timingSafeEqual to prevent timing attacks
  • Raw body verification — guidance that implementations MUST verify against the exact HTTP body bytes, not re-serialized JSON
  • Publisher signing example — previously only a receiver example was shown
  • Express raw body capture — practical guidance for the most common Node.js framework

Why this matters

The current spec says HMAC-SHA256(secret, rawBody) with a bare hex signature and no timestamp. The @adcp/client JS reference implementation does sha256=HMAC-SHA256(secret, "{timestamp}.{rawBody}") with a sha256= prefix and a 5-minute replay window. This mismatch has caused real interop failures between orchestrators and sales agents — see:

Reference

The @adcp/client JS library test suite defines the expected behavior:
https://github.com/adcontextprotocol/adcp-client/blob/main/test/webhook-signature-verification.test.js

// From the reference implementation tests:
const message = `${timestamp}.${JSON.stringify(payload)}`;
const hmac = crypto.createHmac('sha256', webhookSecret);
hmac.update(message);
const signature = `sha256=${hmac.digest('hex')}`;

The HMAC-SHA256 section was missing several details that the @adcp/client
reference implementation already requires:

- Timestamp-based replay protection (X-ADCP-Timestamp header, 5-minute window)
- Signature format: sha256= prefix before hex digest
- Signed message format: {unix_timestamp}.{rawBody}
- Constant-time comparison for signature verification
- Raw body verification guidance (critical for cross-language interop)

These details are already implemented in @adcp/client (JS) test suite:
https://github.com/adcontextprotocol/adcp-client/blob/main/test/webhook-signature-verification.test.js

Also adds explicit guidance that implementations MUST sign the same
serialization sent on the wire, to prevent mismatches between signing
and verification when different JSON serializers produce different output.
@EmmaLouise2018
EmmaLouise2018 merged commit ab2e10a into adcontextprotocol:main Mar 11, 2026
7 checks passed
EmmaLouise2018 added a commit to EmmaLouise2018/adcp that referenced this pull request Mar 11, 2026
…/fix/webhook-hmac-spec"

This reverts commit ab2e10a, reversing
changes made to 9709f09.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant