<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ali</title>
    <description>The latest articles on DEV Community by ali (@ali_cf6b5e18547f5a5fbd326).</description>
    <link>https://dev.to/ali_cf6b5e18547f5a5fbd326</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4270565%2Fa1552ade-d6cb-42ae-9893-b8204f04315e.jpg</url>
      <title>DEV Community: ali</title>
      <link>https://dev.to/ali_cf6b5e18547f5a5fbd326</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ali_cf6b5e18547f5a5fbd326"/>
    <language>en</language>
    <item>
      <title>I built a webhook inspector with replay and mocks, and almost shipped three security bugs</title>
      <dc:creator>ali</dc:creator>
      <pubDate>Sat, 28 Nov 2026 10:46:11 +0000</pubDate>
      <link>https://dev.to/ali_cf6b5e18547f5a5fbd326/i-built-a-webhook-inspector-with-replay-and-mocks-and-almost-shipped-three-security-bugs-29ll</link>
      <guid>https://dev.to/ali_cf6b5e18547f5a5fbd326/i-built-a-webhook-inspector-with-replay-and-mocks-and-almost-shipped-three-security-bugs-29ll</guid>
      <description>&lt;p&gt;Every developer who has integrated Stripe or GitHub webhooks knows the loop:&lt;br&gt;
trigger an event, squint at logs, guess what the payload looked like, tweak the&lt;br&gt;
handler, trigger again.&lt;/p&gt;

&lt;p&gt;Hosted inspectors fix that, but your payloads (often with customer data) sit on&lt;br&gt;
someone else's server. So I built &lt;strong&gt;Hookpit&lt;/strong&gt;, a self-hostable webhook&lt;br&gt;
inspector with replay and mock responses.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyrxrxrsk2o5be0lgc643.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyrxrxrsk2o5be0lgc643.jpg" alt="Hookpit dashboard with a captured Stripe-style webhook" width="800" height="562"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One click gives you a capture URL; requests show up live&lt;/li&gt;
&lt;li&gt;The raw body is stored exactly as sent&lt;/li&gt;
&lt;li&gt;Replay any request to your own app, editing it first&lt;/li&gt;
&lt;li&gt;Mock responses: make the URL behave like a fake API, with path patterns,
placeholders like &lt;code&gt;{{uuid}}&lt;/code&gt;, a configurable delay, and binary bodies&lt;/li&gt;
&lt;li&gt;Per-IP rate limiting on replay and capture, with 429 and &lt;code&gt;Retry-After&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Four things I learned
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Don't let the framework "help" with bodies.&lt;/strong&gt; Express parses JSON and&lt;br&gt;
throws away the original bytes. For an inspector (and for signature checks) you&lt;br&gt;
need the raw body, so I disabled the parser on the capture route and wrote a&lt;br&gt;
test with deliberately odd JSON.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Replay is an SSRF machine unless you stop it.&lt;/strong&gt; Replay makes your server&lt;br&gt;
fetch a URL a user typed. Type &lt;code&gt;http://169.254.169.254/&lt;/code&gt; on a cloud host and&lt;br&gt;
you may read the instance's credentials. I blocked private and reserved&lt;br&gt;
addresses (including IPv6-wrapped IPv4 like &lt;code&gt;::ffff:127.0.0.1&lt;/code&gt;), refused&lt;br&gt;
redirects, and checked the address inside the DNS lookup used for the real&lt;br&gt;
connection, so DNS rebinding can't swap it afterwards.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Mocks let users make your server say anything.&lt;/strong&gt; That means stored XSS&lt;br&gt;
(an HTML mock served from your origin), header injection (&lt;code&gt;%0d%0a&lt;/code&gt; in a query&lt;br&gt;
string ending up in a header), and template tricks (&lt;code&gt;{{constructor}}&lt;/code&gt;). My&lt;br&gt;
answers: force &lt;code&gt;Content-Security-Policy: sandbox&lt;/code&gt; on every mock response, never&lt;br&gt;
template headers, allow only plain property lookups in bodies, and cap how much&lt;br&gt;
a template can expand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Prove your tests can fail.&lt;/strong&gt; For each protection I temporarily broke it and&lt;br&gt;
watched the tests go red: 13 failures with SSRF protection off, 15 with header&lt;br&gt;
validation off, 4 with prototype access allowed. A test that has never failed&lt;br&gt;
might not test anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  A bonus bug that only my laptop could find
&lt;/h2&gt;

&lt;p&gt;CI was green, but &lt;code&gt;docker compose up&lt;/code&gt; failed on my Apple Silicon Mac:&lt;br&gt;
&lt;code&gt;better-sqlite3&lt;/code&gt; has no prebuilt binary for Node 20 on ARM Linux, so it tried to&lt;br&gt;
compile and the slim image had no compiler. GitHub's runners are x86, so CI&lt;br&gt;
could never see it. Fix: a build stage with the toolchain, copying only the&lt;br&gt;
result into a slim final image.&lt;/p&gt;

&lt;h2&gt;
  
  
  The open-source part
&lt;/h2&gt;

&lt;p&gt;Within days of posting the first good-first-issues, two strangers sent pull&lt;br&gt;
requests, and both are merged: rate limiting, and binary mock bodies. I ran each&lt;br&gt;
branch locally before merging. Reviewing taught me as much as writing the code:&lt;br&gt;
I asked for a small test-cleanup fix in one, and in the other I found a gap in&lt;br&gt;
the limiter (creating many endpoints sidesteps the per-endpoint limit), which is&lt;br&gt;
now a public issue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
git clone https://github.com/Aliweb789/hookpit.git
cd hookpit
docker compose up --build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>opensource</category>
      <category>security</category>
      <category>tools</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
