learning-it by example

Back to the video

Webhooks Done Right: Signatures, Retries and Replays

Anyone can POST to your webhook URL. Four questions to ask of every message: forged, changed, old or repeated?

Video #306 ยท Forward deployed engineer interviews

Steps in the video

  1. 0:00 Anyone can send a webhook to your URL, so check four things
  2. 0:34 The idea
  3. 1:13 Setup
  4. 1:42 Sign and package
  5. 2:06 The receiver
  6. 2:40 Retries and dead letters
  7. 3:06 Attack it
  8. 4:09 What this does not show
  9. 4:46 Mistakes to avoid
  10. 5:10 My take and next steps
  11. 5:34 Recap

Files

  • deliver.py (20 lines)
  • run.py (47 lines)
  • webhook.py (37 lines)

Download the code (zip)

Tested with

Python 3.12.15

What this does not show

No network: the line is a function and the clock is a number. The secret is made up and the signing is simplified (the Standard Webhooks scheme also signs the message id). The seen list is in memory and never expires. A request with a missing header raises an error instead of a 401. Sources are vendor pages, not the specification.

Sources

Learning IT by Example.