Every developer who has integrated Stripe or GitHub webhooks knows the loop:
trigger an event, squint at logs, guess what the payload looked like, tweak the
handler, trigger again.
Hosted inspectors fix that, but your payloads (often with customer data) sit on
someone else's server. So I built Hookpit, a self-hostable webhook
inspector with replay and mock responses.
What it does
- One click gives you a capture URL; requests show up live
- The raw body is stored exactly as sent
- Replay any request to your own app, editing it first
- Mock responses: make the URL behave like a fake API, with path patterns,
placeholders like
{{uuid}}, a configurable delay, and binary bodies - Per-IP rate limiting on replay and capture, with 429 and
Retry-After
Four things I learned
1. Don't let the framework "help" with bodies. Express parses JSON and
throws away the original bytes. For an inspector (and for signature checks) you
need the raw body, so I disabled the parser on the capture route and wrote a
test with deliberately odd JSON.
2. Replay is an SSRF machine unless you stop it. Replay makes your server
fetch a URL a user typed. Type http://169.254.169.254/ on a cloud host and
you may read the instance's credentials. I blocked private and reserved
addresses (including IPv6-wrapped IPv4 like ::ffff:127.0.0.1), refused
redirects, and checked the address inside the DNS lookup used for the real
connection, so DNS rebinding can't swap it afterwards.
3. Mocks let users make your server say anything. That means stored XSS
(an HTML mock served from your origin), header injection (%0d%0a in a query
string ending up in a header), and template tricks ({{constructor}}). My
answers: force Content-Security-Policy: sandbox on every mock response, never
template headers, allow only plain property lookups in bodies, and cap how much
a template can expand.
4. Prove your tests can fail. For each protection I temporarily broke it and
watched the tests go red: 13 failures with SSRF protection off, 15 with header
validation off, 4 with prototype access allowed. A test that has never failed
might not test anything.
A bonus bug that only my laptop could find
CI was green, but docker compose up failed on my Apple Silicon Mac:
better-sqlite3 has no prebuilt binary for Node 20 on ARM Linux, so it tried to
compile and the slim image had no compiler. GitHub's runners are x86, so CI
could never see it. Fix: a build stage with the toolchain, copying only the
result into a slim final image.
The open-source part
Within days of posting the first good-first-issues, two strangers sent pull
requests, and both are merged: rate limiting, and binary mock bodies. I ran each
branch locally before merging. Reviewing taught me as much as writing the code:
I asked for a small test-cleanup fix in one, and in the other I found a gap in
the limiter (creating many endpoints sidesteps the per-endpoint limit), which is
now a public issue.
Try it
bash
git clone https://github.com/Aliweb789/hookpit.git
cd hookpit
docker compose up --build

Top comments (12)
The SSRF section is the part I'll steal: checking the address inside the DNS lookup used for the real connection, not just before it, is the detail most write-ups skip — DNS rebinding makes the pre-check version almost theater. And "prove your tests can fail" is a great habit; 13 red tests with the protection off is a much stronger claim than "I have tests for it." The better-sqlite3 ARM story is painfully relatable too — CI being x86-only is exactly how those bugs hide. Nice build!
Thanks, glad it was useful!
It was — that DNS-lookup detail is the kind of thing I'd have missed. Good luck with the inspector, the replay + mocks combo sounds genuinely useful for debugging webhooks.
Worth testing around "stored exactly as sent": a capture URL is a disk-fill primitive, because
dd if=/dev/zero bs=1M count=2048 | curl -X POST --data-binary @- <capture-url>writes 2 GB to your volume per request from anyone who has the URL, and a 1 MB body sent withContent-Encoding: gzipexpands a thousandfold before your code sees a byte. Cap at the socket and return 413, and meter stored bytes per endpoint — the SSRF guards and the storage guard fail in completely different ways.Thanks, this is the kind of test I wanted. I ran both against the real app setup:
Per-request size and gzip: capped. express.raw has a 1 MB limit, and it applies to the decompressed stream. A 2 MB body got 413, and a 199 KB gzip that inflates to 200 MB also got 413.
Stored bytes per endpoint: you're right, this isn't metered. 200 × 1 MB requests were all stored, and there's no retention. The rate limit bounds speed, not total size.
So the socket guard works but the storage guard doesn't exist yet. I'm adding a per-endpoint cap on request count and total bytes that drops the oldest captures, rather than rejecting new ones, so live deliveries aren't lost. Tracking it here: #6 (comment)
Thanks for separating the two failure modes, that framing shaped the fix.
Update: this is fixed and merged. Each endpoint now keeps its newest 1000 requests and up to 50 MB (both configurable), deleting the oldest rather than refusing new deliveries. Aliweb789/hookpit#29 · feat: bound storage per endpoint…
One honest footnote: my own new tests caught a second bug right after. Two requests in the same millisecond could be listed in swapped order. That's fixed too: #30 · fix: stable order for requests…
The remaining gap is a global cap, because creating endpoints is still unlimited (#24). Thanks again for the prompt.
50 MB per endpoint only bounds it while endpoint count is bounded — 20k endpoints is still a terabyte, and #24 is exactly that dimension. A per-account byte budget with LRU across endpoints applies your own rule one level up without rejecting live deliveries. Count the evictions per endpoint and expose the number, otherwise the first symptom of dropping oldest is a support ticket about a missing webhook.
The raw-body point is the one that bites in production: once a framework parses the payload you have lost the exact bytes the signature was computed over, and no amount of re-checking the secret will fix it. I like the test discipline too — deliberately breaking each protection and watching the test go red is the only way I trust a replay tool, since replay is exactly where a helpful debugging feature becomes an SSRF hole. In our EDI work we do the same with captured partner payloads: store them byte-for-byte, replay against a staging handler, and never let replay reach a real production endpoint.
Thanks, the EDI workflow you describe is the one I had in mind: store the
payload as received, replay against staging, keep replay away from production.
One honest caveat on "byte-for-byte": Hookpit stores bodies as UTF-8 text, so
it's exact for normal JSON and text, but a payload with non-UTF-8 bytes
(Latin-1 EDI, for example) won't round-trip exactly yet. That's a known gap and
it's tracked here: github.com/Aliweb789/hookpit/issue...
Your last point made me realise there's a related gap: replay blocks private
and metadata addresses, but nothing stops you pointing it at a real public
production URL. An allow-list of permitted replay hosts would give you the
"never reaches production" rule you describe. I'll open an issue for it.
This is the rare build-in-public post where the security section is the actual product, not a footnote. The SSRF detail is what sold me — checking the address inside the DNS lookup used for the real connection, instead of validating a hostname and then resolving it again later, is exactly the rebinding trap most replay tools walk straight into, and catching ::ffff:127.0.0.1 shows you tested the sneaky cases, not just the textbook ones.
One thing I kept thinking about while reading the replay section: you store the raw body exactly as sent, which is the right call for signature checks, but the moment someone edits a payload before replaying, a Stripe-style signature stops verifying. Do you re-sign on replay, strip the signature header, or leave that as the user's problem to notice? And on the rate-limit gap you found in review — creating many endpoints sidestepping the per-endpoint limit — did you end up adding a per-IP global cap alongside it, or is that still the open issue?
The "prove your tests can fail" habit is worth stealing too. 13 red tests with SSRF protection off is a much stronger claim than "tests pass."
Thanks, Abdullah, this is a great read of the article, and both questions are fair.
Signatures on replay: right now I forward the original headers as they were, signature header included, and don't re-sign or strip anything. So replaying an unedited request still verifies, and editing the body makes the signature fail, which is arguably useful for testing your handler's rejection path, but it isn't something the UI explains. The better answer is probably an option on the replay panel: keep the original signature, strip it, or re-sign with a secret you supply (Stripe-style first, since it's well documented). Signature verification is on the roadmap, and I'd build re-signing alongside it. I opened github.com/Aliweb789/hookpit/issue... for exactly this, thanks to your question.
Rate limit: still open. The per-endpoint limit shipped, and the global per-IP cap plus limiting endpoint creation is tracked here: github.com/Aliweb789/hookpit/issue.... I'd rather say it's a known gap than pretend the limiter is complete.
And thanks for the note on the tests. Breaking each protection on purpose and seeing it fail was the most convincing check I did.
serving mocks from a separate hostname is a nice second layer on top of the CSP sandbox. then a missed header still can't reach the dashboard's cookies