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 