Source: https://solidhooks.com/guides/webhook-verification-mistakes

# Webhook verification mistakes that let forged events through

Most forged webhooks pass a signature check that runs without errors and would accept a request from anyone. Here are six ways that happens, and the fix for each.

Checked 16 Nov 2026.

## 1. An empty secret still "verifies"

HMAC with an empty key still produces a signature, and anyone who knows the scheme can compute the same one. A blank secret setting gives you a check that every attacker passes.

This bug turned up more than once in 2026. When Discourse's Patreon webhook secret was blank, attackers could sign requests with HMAC-MD5 and an empty key, then create, change or delete pledge data ([CVE-2026-26078](https://github.com/discourse/discourse/security/advisories/GHSA-frx4-wg35-4r68)). In new-api, the Stripe webhook secret defaulted to an empty string, and forged events credited free quota. That [advisory](https://github.com/QuantumNous/new-api/security/advisories/GHSA-xff3-5c9p-2mr4) says the Stripe Go SDK's `webhook.ConstructEventWithOptions` doesn't reject an empty secret.

In August, Symfony made three webhook parsers refuse an empty secret ([PR #65763](https://github.com/symfony/symfony/pull/65763)). It left alone nine parsers that skip verification when no secret is set, because "they never pretend to have checked anything". On 9 Nov, Svix's PHP library started throwing on an empty secret ([v2.10.0](https://github.com/svix/svix-webhooks/releases/tag/v2.10.0)).

Fix it by refusing to start when the secret is empty. Never default a secret to `""`.

## 2. Comparing signatures with ==

A normal string compare can stop at the first byte that differs, and that timing leaks. The [OWASP webhook cheat sheet](https://cheatsheetseries.owasp.org/cheatsheets/Webhook_Security_Cheat_Sheet.html) says never to use `==`, and the [Standard Webhooks spec](https://github.com/standard-webhooks/standard-webhooks/blob/main/spec/standard-webhooks.md) warns it can turn your endpoint into a signing oracle. Use `crypto.timingSafeEqual` or `hmac.compare_digest` on buffers of the same length.

## 3. Verifying a parsed body

The provider signed the exact bytes it sent. If your framework parses the JSON and you serialise it again, whitespace, key order or encoding can change, and the signature no longer matches. Read the raw body on the webhook route before any parser runs, verify it, then parse it.

javascript

```
import { createHmac, timingSafeEqual } from 'node:crypto';
 
const secret = process.env.WEBHOOK_SECRET;
if (!secret) throw new Error('WEBHOOK_SECRET is not set');
 
// rawBody is a Buffer, read before any JSON parser runs.
export function isValid(rawBody, signatureHex) {
  const expected = createHmac('sha256', secret).update(rawBody).digest();
  const given = Buffer.from(String(signatureHex ?? ''), 'hex');
  return given.length === expected.length && timingSafeEqual(given, expected);
}
```

When `isValid` returns false, answer `401` and stop.

## 4. Trusting only the first signature

During a secret rotation, Standard Webhooks senders put several signatures in one header, separated by spaces. Accept the request if any `v1` entry matches. OWASP also says to accept only the scheme you expect and ignore the rest, which blocks downgrade attacks.

## 5. Turning off the timestamp check

Stripe's libraries allow five minutes by default, and [Stripe's docs](https://docs.stripe.com/webhooks) warn that a tolerance of `0` disables the recency check entirely. Keep the default and keep your server clock in sync. Some providers, GitHub among them, sign no timestamp, so deduplicate on the event id instead. For the outage case, see [replaying webhooks after an outage](https://solidhooks.com/guides/replay-webhooks-after-outage).

## 6. Telling the caller why it failed

A message like "timestamp too old" tells an attacker what to adjust. Return a plain `401` and log the real reason where only you can read it.

## Test it

Before you ship, and after any change to the handler, check that:

- With the secret unset, the app refuses to start.
- A signature made with an empty key gets `401`.
- A changed body gets `401`.
- A stale timestamp gets `401`, if the scheme signs one.
- The same event sent twice is processed once.

## Where SolidHooks helps

SolidHooks verifies each source as requests arrive. For providers such as Stripe, GitHub and Resend you send only the secret, and while their built-in verifier is selected, the API rejects any attempt to change the signing scheme. A failed check gets an opaque `401`. The reason is stored on the rejected event, and `POST /v1/sources/{id}/test-signature` explains why a captured request fails. Under a flood, the rejected log is a sample, not every request.

It can't fix the check inside your own app. Verify SolidHooks' [delivery signatures](https://solidhooks.com/docs/delivery-signatures) at your endpoint too, or anyone who finds the URL can post to it. A `noop` source verifies nothing. Once an event passes, still treat the payload as untrusted input ([why signed payloads aren't safe agent input](https://solidhooks.com/guides/webhook-payload-untrusted-ai-agents)).

## FAQ

### Can an empty webhook secret let attackers forge signatures?

Yes, if your code still computes the HMAC. Anyone can compute a keyed hash with an empty key, so the forged request carries a valid signature. Refuse to start when the secret is empty.

### Why shouldn't I compare webhook signatures with ==?

It can return at the first byte that differs, which leaks timing. Use a constant-time compare such as `crypto.timingSafeEqual` on buffers of equal length.

### What should a failed signature check return?

A `401` with a generic message. Log the specific reason privately. SolidHooks does the same at ingest and stores the reason on the rejected event.

## Get started

The Hobby plan is free for 10,000 deliveries a month. Create a source with a provider preset and send it your secret. See [verification](https://solidhooks.com/docs/verification).
