Server-only boundary
Verification belongs at the server request boundary. Browser code cannot safely hold webhook secrets, receive the original server request, or provide durable replay protection. Disable framework body parsing for the webhook route or retain the exact bytes before parsing; re-serialized JSON is not equivalent. Enforce HTTPS at the edge, request size and time limits, one expected media type, allowed methods, and rate limits before cryptographic work. Do not log headers or body on failure.Planned usage
The stored planned webhook example reads an already bounded raw body, verifies it, reserves the event ID, validates the typed event, and acknowledges only after durable handoff.Verification sequence
- require exactly the released signature and timestamp header representation;
- parse without duplicate components or ambiguous whitespace;
- reject a timestamp outside the configured past and future tolerance;
- resolve the recipient’s exact secret or public-key version from trusted config;
- construct the released signed payload from timestamp and exact raw bytes;
- verify the allowed algorithm using constant-time comparison where relevant;
- parse JSON only after signature success and reject duplicate keys;
- validate the event against the exact schema ID and release manifest;
- atomically reserve recipient and event ID in replay storage;
- enqueue or persist the verified event before returning success.