[ MSP, APIs & integrations ]

Webhook authentication, signatures and replay protection

Verify webhook bytes before trusting the payload, then control replay with a provider-specific delivery identity and retention policy.

By the EmailAuth research team · 3 min read

[ Key points ]

  • Verify webhook bytes before trusting the payload, then control replay with a provider-specific delivery identity and retention policy.
  • A body signature does not authenticate arbitrary delivery headers; separate authenticity, replay handling and permission for downstream actions.
On this page

A webhook endpoint is an externally reachable input boundary. A plausible JSON body is not proof that the provider sent it, and a valid signature does not necessarily prove that it is new. Separate transport protection, payload authentication and replay handling in both the design and its tests.

Verify the provider's actual signing scheme

Use HTTPS and the provider's documented signature algorithm. Retain the raw request body for signature verification before parsing or normalizing it. Store the secret in an approved secret system and avoid printing it in logs. If verification fails or the required header is missing, reject the input without applying its requested effect.

GitHub's webhook validation guide documents an HMAC SHA-256 signature in X-Hub-Signature-256 and recommends a secure comparison rather than ordinary equality. This is a concrete reference implementation boundary. Other providers may sign timestamps, selected headers or a different canonical string, so do not transfer the GitHub recipe unchanged.

Treat freshness and identity separately

GitHub's webhook best practices recommend using X-GitHub-Delivery to identify deliveries and note that a requested redelivery retains the original delivery ID. Keep a deduplication record scoped to the relevant subscription or installation. Redelivery should repair processing, not create a second ticket or change.

A body-only signature does not authenticate arbitrary delivery headers. An attacker replaying captured signed bytes with a changed unsigned delivery ID can evade ID-only deduplication. An unsigned timestamp is likewise not evidence of freshness. Treat delivery-ID guidance as one control with this trust boundary, not a cryptographic replay guarantee. Do not invent a GitHub signed-timestamp header. Where a provider signs a timestamp, validate it according to the provider's documented tolerance and canonicalization rules. Where it does not, delivery identity and controlled deduplication are important but have limits: an event replayed after identity retention expires may no longer be recognizable. Set and document retention with that risk in mind.

Compare two replay situations

Suppose the original GitHub delivery has a valid body signature and an already-processed delivery ID. A requested redelivery retains that ID, allowing the receiver to find its recorded state and avoid repeating the effect. Now suppose captured signed body bytes arrive with a different unsigned delivery ID. Body verification can still succeed because that header is outside the signed body; ID-only deduplication is not sufficient cryptographic proof of freshness. These are hypothetical reasoning cases, not executed attacks or provider deliveries.

For a cooperating sender whose documented scheme authenticates an event identity and timestamp together with the payload, test tampering, genuinely signed expired timestamps, future timestamps outside the allowed tolerance and repeated identities. Do not invent such a scheme for a provider that does not offer it. No custom envelope, signing key or replay test is supplied here. Exact-body fingerprints may help investigate repeats, but identical payloads can also represent distinct legitimate events; define business identity and acceptance rules rather than indiscriminately discarding all equal bodies.

Limit the consequence of an accepted event

After verification, validate event type, action, schema and tenant mapping. Bind the trusted subscription to the intended tenant rather than accepting an arbitrary tenant ID from the body. Queue accepted work with a stable identity and keep configuration changes behind their normal approval boundary. An authenticated webhook can report an event without being authorized to change DNS.

Record verification outcome, delivery identity, received time and a safe evidence reference while minimizing payload retention. Stop processing when tenant association or signature status is ambiguous. Recovery should replay a retained verified event through the same guarded path, not bypass validation to clear a queue. This guide does not verify an EmailAuth webhook integration or any real provider delivery.

[ Takeaway ]

A body signature does not authenticate arbitrary delivery headers; separate authenticity, replay handling and permission for downstream actions.

[ By role ]

What this means for you

Choose your role for practical next steps.

IT / Mail Admin

Test exact bytes

Signature checks fail when canonicalization is guessed.

Next steps

  1. Preserve raw bodies.
  2. Test tampering.
  3. Exercise concurrent duplicates.

CISO / SecOps

Bound trust and retention

Replay controls need durable scope and lifecycle.

Next steps

  1. Review secret rotation.
  2. Approve identity retention.
  3. Verify tenant binding.

Founder / Non-technical

Separate receipt from authority

Authenticated events still need a controlled business workflow.

Next steps

  1. Define allowed event effects.
  2. Reject unverified integration claims.
  3. Assign replay-risk ownership.

[ FAQs ]

Frequently asked questions

Should JSON be parsed before signature verification?

Preserve and verify the raw bytes using the provider-defined signing procedure before trusting parsed content.

What header does GitHub use for SHA-256 signatures?

X-Hub-Signature-256, under the documented webhook secret scheme.

Does a valid signature establish freshness?

No. A body-only signature leaves arbitrary headers and local timestamps unauthenticated; changed unsigned metadata can bypass naive replay checks.

Does GitHub redelivery change the delivery ID?

Its documentation says a requested redelivery retains the original X-GitHub-Delivery value.

Does GitHub acquire signed timestamps from this example?

No. Only the provider’s actual documented signed fields can support that check; an unsigned timestamp does not establish freshness.

Why retain delivery IDs?

To recognize repeated delivery attempts within a defined retention window.

Can a verified event authorize DNS changes?

Only if a separate authorized workflow grants that action; signature validity alone is insufficient.

Does this guide supply a signing key or executed replay test?

No. Its two replay situations are hypothetical. Use approved secrets and test the real documented signing boundary separately.

[ Sources ]

Sources

  1. GitHub validating webhook deliveries

    Sections Validating webhook deliveries

  2. GitHub webhook best practices

    Sections Use a webhook secret · Respond within 10 seconds · Use the X-GitHub-Delivery header

  3. OWASP Authorization Cheat Sheet

    Sections Enforce Least Privileges · Deny by Default · Validate the Permissions on Every Request · Create Unit and Integration Test Cases for Authorization Logic

[ Glossary ]

Glossary

HMAC
A message authentication code computed with a shared secret and hash function.
Replay
Resending an earlier valid event to provoke repeated processing.

Enterprise provenance

Why top financial institutions and governments retired their email security dashboards.

Traditional email authentication platforms sell you a dashboard and ask your engineers to do the labour. In high-stakes environments, manual oversight means delayed enforcement, configuration drift and unmonitored shadow domains.

EmailAuth is the agentic email provenance platform. Our agents enforce p=reject, keep third-party senders aligned and move your domains to full RFC 9989 compliance, the new DMARC standard,, with human-in-the-loop auditability.

Governments Large enterprises Tier-1 financial institutions

SaaS · Dedicated tenancy · Air-gapped on-prem · BYOK encryption

Knowledge Base