In this article
Equivalent parsed JSON can have different signed bytes; reconstructing the payload after parsing is not the original-body verification contract.
Preserve the received material before JSON parsing
The GitHub validation guide demonstrates verifying the original request body before parsing its JSON. Whitespace, escaped characters and line endings can change during reconstruction even when application fields remain equivalent. A proposed receiver therefore preserves raw body material at the framework boundary. Parsing can still happen after validation, but a serializer cannot reconstruct evidence of the exact representation that arrived merely from the resulting object.
Match the digest contract and payload format
The delivery header reference defines X-Hub-Signature-256 as an HMAC digest over the request body using the webhook secret. It also describes JSON and URL-encoded payload delivery formats. The signed material is the delivered body, not whichever nested field an application later extracts. An editorial integration record should include the selected content type and signature scheme. Do not compare a raw hexadecimal digest directly with an undecoded prefixed header as if they were identical representations.
Keep text decoding from silently changing the body
GitHub’s troubleshooting guidance covers UTF-8 payloads, Unicode and modification by proxies or load balancers. A receiver that performs character replacement, newline normalization or JSON pretty-printing before verification has changed its verification input. A proposed local fixture can preserve one Unicode payload in several transport representations and identify exactly where a framework converts bytes to text. The goal is to explain a mismatch, not to relax verification until a modified payload passes.
Compare valid digest representations deliberately
The Node.js crypto reference defines timingSafeEqual over byte-backed inputs and requires equal byte lengths. Different lengths produce an error, while surrounding code still needs its own careful handling. A proposed verifier first validates the header’s structure and decodes the documented digest representation, then compares like-for-like bytes using the chosen runtime’s supported primitive. Malformed input should become an authentication failure rather than an uncaught application exception or an ordinary string-comparison shortcut.
Separate authenticated bytes from event processing
A valid body HMAC establishes the documented authenticity and integrity check; it does not decide the meaning of an event action or whether downstream work was already completed. Preserve parsed-event interpretation separately after validation. Contract fixtures can cover original and modified bodies, while request correlation distinguishes a tracing value from cryptographic evidence. This article describes verification of public protocol examples and creates no webhook endpoint, secret or delivery.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.