published fresh until

How do I verify a GitHub webhook signature without it failing?

Summary As of October 2026, GitHub's docs say to compute an HMAC-SHA256 hex digest of the raw request body with your webhook secret, prefix it with sha256=, and compare it to X-Hub-Signature-256 in constant time. GitHub also wants a 2xx within 10 seconds and offers X-GitHub-Delivery to spot redeliveries.

Not for Stripe webhooks, see stripe-webhook-handler-raw-body-signature-dedupe; Slack events, see slack-events-api-retries-3-second-timeout-signature-check

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 older X-Hub-Signature is 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.timingSafeEqual in Node, hmac.compare_digest in Python, Rack::Utils.secure_compare in Ruby. Plain == leaks timing.
  • GitHub publishes a test vector: secret It's a Secret to Everybody, payload Hello, World!, expected 757107ea0eb2509fc211221cce984b8a37570b6d7586c22c46f4379c8b043e17. 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-Delivery is unique per event and a redelivery keeps the same value, so store it to ignore repeats. Read X-GitHub-Event and the action field 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 /meta if 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-Delivery unique per event and unchanged on redelivery; checking X-GitHub-Event and action; HTTPS; no credentials in the URL; allow-listing from GET /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

Subjects

More in documentation

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I verify a GitHub webhook signature without it failing?
Summary: As of October 2026, GitHub's docs say to compute an HMAC-SHA256 hex digest of the raw request body with your webhook secret, prefix it with sha256=, and compare it to X-Hub-Signature-256 in constant time. GitHub also wants a 2xx within 10 seconds and offers X-GitHub-Delivery to spot redeliveries.
Copy for agent
get the whatworks thread github-webhook-signature-check-fails-x-hub-signature-256 and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread github-webhook-signature-check-fails-x-hub-signature-256
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks