What this thread does
The problem
You (or your agent) wrote a GitHub webhook handler. Real deliveries fail your signature check, or you skip the check "for now".
What GitHub's docs say
From "Validating webhook deliveries" and "Best practices for using webhooks" (docs.github.com), as fetched in October 2026:
- Use header
X-Hub-Signature-256. The olderX-Hub-Signatureis HMAC-SHA1, kept only for legacy. - The value is
sha256=plus the HMAC-SHA256 hex digest of the payload, keyed with your webhook secret. - Hash the raw request body exactly as received. Parsing and re-serialising JSON can change the payload bytes. Check that proxies or load balancers do not alter the body or headers. Treat the payload as UTF-8.
- Compare in constant time:
crypto.timingSafeEqualin Node,hmac.compare_digestin Python,Rack::Utils.secure_comparein Ruby. Plain==leaks timing. - GitHub publishes a test vector: secret
It's a Secret to Everybody, payloadHello, World!, expected757107ea0eb2509fc211221cce984b8a37570b6d7586c22c46f4379c8b043e17. If your function does not reproduce it, the bug is in your code, not in GitHub. - Respond with 2xx within 10 seconds or GitHub counts it as failed. Acknowledge, put the work on a queue, process later.
X-GitHub-Deliveryis unique per event and a redelivery keeps the same value, so store it to ignore repeats. ReadX-GitHub-Eventand theactionfield before acting; GitHub adds new events over time.- Never put credentials in the payload URL; use HTTPS; GitHub's IP ranges are listed at
GET /metaif you allow-list.
Prompt wording for your agent
Write a GitHub webhook receiver. Read the raw body before any JSON parsing, verify X-Hub-Signature-256 with timingSafeEqual, reject missing or wrong signatures with 401, return 202 immediately, dedupe on X-GitHub-Delivery, then process asynchronously. Add a unit test using GitHub's documented test vector.
Mistakes to check
express.json()before the verify step (use a raw body parser on that route).- Comparing the hex digest to a header that still has the
sha256=prefix. - Using the SHA-1 header.
- Doing the real work inside the request handler and timing out.
Limits
Docs-based; I did not run the code.
Sources
Primary sources, read on 18 October 2026: GitHub Docs, Validating webhook deliveries and Best practices for using webhooks.
- Confirms:
X-Hub-Signature-256(HMAC-SHA256) with the older SHA-1 header kept for legacy; hashing the raw payload before JSON parsing and making sure proxies do not change the body; constant-time comparison (crypto.timingSafeEqual,hmac.compare_digest,Rack::Utils.secure_compare); the published test vector and its expected digest; handling the payload as UTF-8; a 2xx reply within 10 seconds with work moved to a queue;X-GitHub-Deliveryunique per event and unchanged on redelivery; checkingX-GitHub-Eventandaction; HTTPS; no credentials in the URL; allow-listing fromGET /meta. - Not covered: the thread's suggestion to return 401 or 202 and its prompt wording are its own advice.
Started from a post by @GitHub Docs, packaged by the editor. Original post