INFINITE UPSIDE

Technology and operations

How Can You Tell Whether a Webhook Is Genuine?

A familiar event name is easy to copy. The signature is a way to check the message, not a promise that processing it will be simple.

A store’s integration receives a message saying an order has been paid. The message arrives at the usual URL and contains an order number in the expected format. Those details are helpful for routing, but they do not prove who sent it. Anyone who can reach a public endpoint may be able to send a request that looks convincing.

Webhook signature verification checks a received message against authentication information supplied by the provider. In a shared-secret scheme, the receiving service computes a value from the message and its secret, then compares that value with the signature in the request. The exact construction is provider-specific. A valid check can help establish that the signed content was not altered and came from a party with the relevant signing secret; it does not establish that the business event is new, timely or ready to apply.

The GitHub webhook validation guide describes one concrete scheme using an HMAC-SHA256 signature and the original request body. Other providers may sign a timestamp or other fields, use different headers, or offer asymmetric signatures. Follow the actual provider’s documentation and supported libraries rather than borrowing a fragment from an unrelated integration.

A delivery is a request, not a person at the door

A webhook is an automated message sent when a provider reports an event. A payment processor might report a payment-status change; a code-hosting service might report a repository event. The receiver exposes an endpoint so the provider can deliver the request without a person opening the application.

Picture a fictional inventory service that receives a shipment notification. The request includes an event identifier, a payload and a signature header. The service reads the original body, validates the signature using its configured secret and provider’s specified algorithm, then decides whether the event is relevant. Only after authentication should untrusted content be allowed to trigger business processing.

If verification fails, the receiver should avoid applying the event. Record a safe diagnostic, return the response appropriate to the provider’s integration contract and investigate. An error can arise from a wrong secret, altered body, mismatched algorithm or incorrect header; it is not automatically proof of an attacker. Equally, a familiar customer name inside the body does not justify accepting an invalid signature.

Why the exact bytes matter

The signature is calculated over a specified input. In GitHub’s documented example, that input includes the original request body. A framework may parse JSON into an object, reorder keys or change whitespace when it serializes the object again. The resulting text can describe the same information to a person while having different bytes. A signature for the original body will not necessarily match a signature calculated over the rebuilt version.

Consider the two JSON strings {"a":1,"b":2} and {"b":2,"a":1}. A program may treat them as equivalent objects for some purposes, but their bytes differ. This is an illustration, not a signature test vector. The verification step must use the input specified by the provider, not a human judgment that the data looks equivalent.

That requirement affects application plumbing. Check whether middleware consumes or transforms the body before the verification code sees it. A reverse proxy, content encoding, character handling or test tool may also change what is received. Keep the verification path compatible with the framework’s documented way of accessing the original bytes. After a successful check, parse and validate the expected fields for the business operation.

Do not log entire payloads merely to debug a mismatch. They may contain personal information, confidential order data or other sensitive material. A request identifier, verification outcome, timestamp and a carefully limited diagnostic can be enough to find a pattern without copying customer data into another system.

The secret belongs on the receiving side, not in the message

In GitHub’s shared-secret example, both sender and receiver know a secret configured for the webhook. The signature uses that secret without requiring the sender to include the secret itself in each request. The receiver needs access to the same secret to calculate its expected value. Anyone who obtains the secret may be able to produce signatures that pass the same check, so its storage and access deserve attention.

Use a high-entropy secret and the provider’s intended configuration process. Store it in an appropriate protected secret store or environment configuration, restrict who and what can read it, and avoid putting it into source files, sample payloads, screenshots or routine logs. A webhook secret is not the same credential as a user’s password, an API key for outgoing requests or a database password. Inventory them separately.

Plan a rotation before the old value is lost or exposed. Providers differ in whether they support an overlap period, multiple active secrets, signed delivery retries or other transition mechanisms. If both old and new values must be accepted briefly, define the window, monitor use of the old value and remove it when the transition is complete. Do not assume the provider offers overlap or leave an old secret valid indefinitely because a calendar reminder was missed.

Some providers use public-key signatures rather than a shared secret. In that design the receiver validates with an appropriate public key instead of possessing the sender’s private signing key. Key discovery, rotation and the signed input still need the provider’s exact instructions. A shared-secret checklist should not be treated as an implementation guide for every signature system.

A valid signature is not a fresh event

Suppose a genuine paid-order event was delivered twice because the sender retried after a timeout. Both deliveries could have a valid signature. If the receiver creates a shipment twice merely because each request authenticates, the signature did its job and the business workflow still failed.

Use the provider’s stable event identifier and the integration’s idempotency design to detect an event that has already been applied. A separate guide to idempotency keys explains why retries and duplicate effects need their own treatment. Store the processing result in a way that handles concurrent deliveries and failures between receiving an event and completing work; a simple in-memory list can disappear on restart and may not coordinate multiple workers.

Order is another independent concern. Providers may not guarantee that events arrive in the order they occurred. A later delivery can describe an earlier state, even when every signature is valid. Compare the event’s version or authoritative current state using the provider’s documented semantics, and avoid assuming that the most recently received packet is the latest business fact. The webhook ordering guide walks through that problem.

Some providers include a signed timestamp and recommend rejecting requests outside a tolerance. That can help limit replay exposure when implemented according to that provider’s scheme, but it is not a replacement for deduplication. Retries, clock drift and legitimate delivery delays require a deliberately chosen policy. GitHub’s HMAC example should not be assumed to provide the timestamp semantics of another service.

When the test passes but production does not

Start by comparing configuration, not customer records. Is the production endpoint receiving the correct provider header? Is it using the secret for the correct endpoint and environment? Was the request body changed by middleware before verification? Are test and production credentials being confused? GitHub’s guide specifically identifies incorrect secrets, headers, algorithms and modified payloads as common causes of failed verification.

Use the provider’s documented test vector or a controlled non-production delivery where available. A test that calculates and checks a signature with the same wrong input can be misleading: both sides of the test may repeat the same mistake. Include a case with the correct bytes and key, a changed body, a missing signature and a wrong key. Ensure the implementation uses the provider’s recommended comparison method; GitHub recommends a timing-safe comparison for its example.

Also test the response and retry behavior. The sender may retry after a timeout even if the receiving service completed an action. The receiver may need to acknowledge receipt and process work separately, but the right response timing and status depend on the provider’s documented contract. Simulate a crash after receipt and before completion in a safe environment, then verify that recovery neither loses the event nor repeats the external effect.

Treat a rise in failed signatures as a signal to investigate, not a reason to disable verification. A provider-side configuration change, secret rotation or body-handling bug may explain it. Preserve enough safe evidence to compare events across the delivery and receiving systems, and involve the appropriate security or integration owner if the pattern is unexplained.

Separate the checks on purpose

An operational review can use four questions. First, did the message authenticate under the provider’s exact scheme? Second, does the payload have the expected structure and refer to an entity the application recognizes? Third, has this event or requested effect already been processed? Fourth, is the state transition still valid given newer information? Each answer protects against a different failure.

Add a fifth question for consequential actions: what happens if the service stops between recording the event and carrying out the action? The answer may involve a durable queue, transactional records or an explicit reconciliation process, depending on the system. A signature alone cannot make a database update and a third-party shipment one atomic operation.

The strongest integration is not the one with the most impressive-looking header. It is the one whose team can explain what was authenticated, what was accepted, what happened afterward and how to recover if the next step failed.

Explore Infinite Upside

For Vijay Sheth’s personal accounts, read Infinite Upside: Building Wealth With Room to Live, published by Sheth Capital, Inc.

Find your edition · Chapter companion

ABOUT THE CONTRIBUTOR

Luna Lim

DIRECTOR OF FINANCIAL RESEARCH & EDITORIAL STRATEGY

SHETH CAPITAL, INC.

Luna Lim writes about business, investing, and the judgment behind financial decisions. She joined PCH Exotics Inc. as Director of Operations in 2022, working across La Jolla and Miami. Today, she reports directly to Vijay Sheth at Sheth Capital, Inc., bringing an operator’s perspective to the ideas she covers.

Based in Pacific Beach, California, Luna is curious about the people behind the numbers: what they’re building, how they weigh uncertainty, and what makes a risk worth taking. Her articles for Infinite Upside follow those questions through the details, with clear explanations and a feel for how decisions play out in everyday business.

More from Luna Lim

The Infinite Upside store