Blog

Webhook Security: Check the Event Before Changing the Order

Follow a payment notification, a genuine retry, and an altered message to define webhook verification, duplicate-safe processing, and the managed WAF boundary.

Secure a payment webhook by verifying the provider's signed notification, checking that it authorizes the intended order change, and making repeated delivery safe. A genuine notification may arrive more than once. Your application should recognize that repetition without shipping another order, granting another entitlement, or issuing another refund.

A webhook is a notification one system sends to another system's web address when an event occurs. For an IT manager approving a payment integration, the acceptance question is concrete: which incoming messages may change an order, and what happens when the same payment is reported again?

Authenticate the message before trusting its contents

HTTPS protects the connection. The receiver also needs to verify the notification using the provider's documented authentication method. GitHub's webhook validation guidance, for example, describes a signature calculated from the message body and a shared secret. The receiver checks that signature before processing the delivery. This helps establish authenticity and detect changes to the signed content, provided the secret remains protected.

Use the provider's maintained verification library where available. Preserve the exact bytes it expects: Stripe requires the original request body, its signature header, and the correct endpoint secret. Parsing a structured message and rebuilding it can change those bytes even when the displayed values look identical. A failed check should stop order-changing work while the responsible team investigates the configuration or message.

The protocol details differ. GitHub signs the body; Stripe's scheme also authenticates a delivery timestamp. Follow the actual provider's rules instead of adding an arbitrary timestamp check to a field that its signature does not protect. OWASP's webhook guidance explains this distinction and the separate roles of replay protection and duplicate handling.

Give the gateway and application the checks they can perform

Network Box USA's managed Web Application Firewall (WAF) service provides request inspection, application policy, tuning, reporting, and traffic validation. Include the webhook route in that managed scope. The useful outcome is a reachable integration with maintained request protection and a defined way to investigate blocked deliveries.

Ask the gateway and application operators to agree the callback hostname and path, expected request method, required headers, payload limits, and supported source restrictions. GitHub's webhook best practices recommend maintaining any source-address allowlist as its delivery addresses change. Such a list limits where requests arrive from; the receiver still needs message verification.

Confirm the controls available in the actual WAF deployment. The general service description does not establish a payment-provider integration or signature-verification capability. The application team owns signing-secret handling, payment and order checks, duplicate-safe processing, and recovery of unfinished work unless separately agreed. Preserve the signed body through the complete delivery path.

If a legitimate notification is blocked, investigate the matching rule and request with both operators. Scope any correction to the required route and behavior. Sending callbacks straight to an unprotected application address would remove the intended gateway boundary; our origin-access guide explains how to check alternate paths.

Follow three deliveries for one order

Consider Maple Office Supply, a hypothetical retailer. Its IT manager, Nina, is approving an integration between its payment provider and warehouse system. Assume the chosen provider signs payment notifications and may retry deliveries. The following sequence is an acceptance exercise, not a customer incident.

First delivery: a genuine successful payment

The application verifies the notification, identifies the correct merchant account and order, and checks the provider's payment state against the order's expected amount and currency. It records the accepted event and creates one durable fulfillment task carrying the order's unique fulfillment reference. In this example, the warehouse accepts that fulfillment reference only once, including when two requests arrive together.

These business checks matter alongside authentication. OWASP's payment-integration guidance recommends verifying payment state and matching the amount, currency, and order. A valid event about another merchant or an unfinished payment should not authorize this order's release. Stripe's fulfillment guide illustrates retrieving the Checkout Session, checking its payment status, and recording fulfillment. Use the corresponding supported checks for the actual provider.

Second delivery: the same event after a lost acknowledgement

Suppose the first delivery was recorded successfully, but the provider did not receive the acknowledgement. It sends the event again. This can be normal retry behavior, not an attack.

Nina's acceptance result is one order release. The receiver verifies the new delivery and recognizes that the event was already accepted. It returns the provider's appropriate success response without creating another fulfillment task. If the original task is unfinished, its recorded work remains available for recovery. If the warehouse may already have acted but its reply was lost, reconcile the fulfillment reference before resubmitting.

This behavior is called idempotency: repeating the request does not repeat the intended business effect. Stripe's fulfillment guidance explicitly accounts for repeated and simultaneous calls. The application and warehouse must coordinate their records and duplicate controls so two workers cannot both release the same order. A unique event record alone is insufficient if separate genuine events can refer to the same payment; the fulfillment operation needs its own payment or order identity.

Third delivery: an altered copy of the message

An attacker changes the order reference in a captured signed body but retains the original signature. Signature verification fails, and no fulfillment work begins. An unchanged captured message presents a different problem: its signature can remain valid. Where the provider supports an authenticated timestamp, apply its freshness check, and retain duplicate-safe processing for messages still within the accepted window.

Nina now has three expected outcomes: one fulfillment task, a successful acknowledgement without another task, and a rejected forgery. Legitimate retries remain usable without becoming additional orders.

Accept the whole transaction, including recovery

Have the application and warehouse teams demonstrate those cases with provider-supported test events and harmless orders. Include simultaneous deliveries and interruption between accepting an event and completing fulfillment. Confirm that recovery finishes the intended work once. Retain event identifiers, verification outcomes, and processing status in appropriate logs; keep signing secrets and sensitive payment contents out of routine diagnostic records.

Also agree how the integration handles delayed or out-of-order notifications. OWASP recommends consulting the provider's current object state where a notification may be stale. Do not let an older message silently reverse a newer order decision.

Before approving production use, give the gateway operator the callback paths, expected delivery behavior, and application-owner contact. Contact our team to review the managed WAF portion of that design. Arrange sensitive integration evidence through an agreed secure channel.