DEV Community

Ujjwal Dubey
Ujjwal Dubey

Posted on

Verify Every Webhook: Signature Checks for the Form, Payment and Booking Tools a Small US Business Uses

Small-business automations often start with a webhook from a form builder, payment tool or booking app. Many are set up without checking the request actually came from that vendor. As an AI automation agency working with US small business stacks, we treat verification as step one, not a later hardening task.

1. Use the vendor's signing secret

Most vendors sign each webhook with an HMAC of the raw body. The exact header name differs, so read their docs.

import hmac, hashlib

def verify(raw_body: bytes, header_sig: str, secret: str) -> bool:
    expected = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, header_sig)
Enter fullscreen mode Exit fullscreen mode

Verify against the raw bytes, before any JSON parsing changes whitespace.

2. Reject old requests

If the vendor sends a timestamp, refuse anything older than a few minutes. That blocks replays of a captured request.

3. Store event IDs

Keep the vendor's event ID and ignore repeats. Vendors retry on timeouts, and you do not want two CRM leads or two thank-you texts.

4. Respond fast, work later

Return a 200 quickly after verification and queue the real work. Slow handlers cause vendor retries.

5. Keep secrets out of no-code fields

If part of the flow runs in a no-code tool, put the secret in its credentials store, not in a visible text step.

6. Log rejections

A sudden run of failed signatures often means a rotated secret nobody updated.

Ujjwal Dubey, NxFlowAI, serving US businesses remotely from Mumbai. For where this fits in a project, see the audit we run before any build.

Top comments (0)