← Integration Engineering
Integration Engineering

Anyone Can Send a Request to Your Webhook URL

6 Oct 2026·4 min read

To receive webhooks, your URL has to be public. So anyone can send it a request, like a fake "payment succeeded". The first job of a webhook handler is checking who sent the message.

Rule 1: verify the signature first

You and the provider share a secret. The provider mixes it with the message body and sends the result, the signature, in a header. You do the same mixing on your side. If it matches, keep going. If not, reject it. On GitHub the header is X-Hub-Signature-256:

const crypto = require('node:crypto');

function isFromGitHub(rawBody, signatureHeader, secret) {
  if (!signatureHeader) return false;
  const expected =
    'sha256=' + crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
  const a = Buffer.from(expected);
  const b = Buffer.from(signatureHeader);
  // timingSafeEqual throws if the lengths differ, so check that first
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}
Example sketch in Node.js, tested against GitHub’s test values. Use the exact raw body you received, and a constant-time compare, never a plain ==.

Three more habits

  • Reply fast. GitHub asks for a reply within 10 seconds. A slow reply counts as a failure, and providers that retry send it again. Save the event in a queue, reply 200, and do the work later.
  • Expect the same event twice. Save each event ID, and skip one you have seen before.
  • Do not trust the order. Before you overwrite, check the record’s own version or last-updated time, so old data does not replace new.
Do this in 60 secondsOpen one webhook handler. Is signature check the very first thing it does? Search for == near the signature, and swap it for a constant-time compare.
Today’s AI angleMany webhooks now reach an AI agent. An unverified one lets a stranger give your agent instructions. Verify first, and treat the content as data, not orders.
Anyone Can Send a Request to Your Webhook URL · Ali Huzaifa