GitHub webhook deliveries are checked with an HMAC SHA-256 signature
Answer: You can use a webhook secret to verify that a webhook delivery is from GitHub. Create a secret token for a webhook. Store the token securely on your server. Validate incoming webhook payloads against the token.
The header
Each delivery has a signature header. The hash signature always starts with sha256=. GitHub uses an HMAC hex digest to compute the hash. The hash signature is generated using your webhook's secret token and the payload contents.
Checking the digest
Calculate a hash using your secret token. Then compare the hash that GitHub sent with the expected hash that you calculated. The hmac module implements the HMAC algorithm as described by RFC 2104. The key is a bytes or bytearray object giving the secret key. When comparing a hexdigest to an externally supplied digest, use the compare_digest function instead of the == operator. The example calls compare_digest on expected_signature and signature_header.
See also
Claims
- id: C1 claim: The signature header is X-Hub-Signature-256. source: S1 evidence: "value of the
X-Hub-Signature-256header."
- id: C2 claim: The hash signature always starts with sha256=. source: S1 evidence: "The hash signature always starts with
sha256=."
- id: C3 claim: GitHub uses an HMAC hex digest to compute the hash. source: S1 evidence: "uses an HMAC hex digest to compute the hash."
- id: C4 claim: Python recommends compare_digest instead of ==. source: S2 evidence: "compare_digest
function instead of the==` operator"
Sources
- [S1] Validating webhook deliveries. GitHub Docs. https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries . License: CC-BY-4.0. Accessed 2026-11-16.
- [S2] hmac — Keyed-Hashing for Message Authentication. Python docs. https://docs.python.org/3/library/hmac.html . License: PSF-2.0. Accessed 2026-11-16.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: GitHub Docs, Validating webhook deliveries, CC-BY-4.0 (https://raw.githubusercontent.com/github/docs/main/LICENSE). Copyright GitHub, Inc.; Python docs, hmac — Keyed-Hashing for Message Authentication, PSF-2.0 (https://docs.python.org/3/license.html). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: GitHub Docs, Validating webhook deliveries, CC-BY-4.0 (https://raw.githubusercontent.com/github/docs/main/LICENSE). Copyright GitHub, Inc.; Python docs, hmac — Keyed-Hashing for Message Authentication, PSF-2.0 (https://docs.python.org/3/license.html).
Cite this
iinventedlight. 2026. "GitHub webhook deliveries are checked with an HMAC SHA-256 signature." iinventedlight Library, iil:note:ztefwydv, version of 2026-11-16. https://iinventedlight.com/library/notes/github-webhook-signatures/. License: CC-BY-4.0.
@misc{iil_note_ztefwydv,
author = {{iinventedlight}},
title = {{GitHub webhook deliveries are checked with an HMAC SHA-256 signature}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-16},
url = {https://iinventedlight.com/library/notes/github-webhook-signatures/},
note = {Permanent ID iil:note:ztefwydv. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/github-webhook-signatures.md.