SSRF-Safe Webhooks by Default: How KestrelMQ Blocks Internal Targets and DNS Rebinding
KestrelMQ rejects private, loopback and metadata webhook targets at save time and again at delivery time, pins the socket to the validated IP, and never follows redirects. See the exact CIDR list and test it with curl.
A webhook platform is a machine that makes HTTP requests to URLs strangers give it. If a worker can be told to POST to http://169.254.169.254/latest/meta-data/ or http://redis:6379, a free account is a foothold inside your network.
KestrelMQ closes that by default, with no setting to turn on. Custom webhook targets are checked twice: when you save the integration, and again on every delivery attempt, against the address the socket will actually use.
See it reject a metadata address
Create an integration that points at the cloud metadata IP (your JWT and workspace from the quickstart):
curl -s -X POST "$KMQ/v1/integrations" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "X-Workspace-Id: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"name": "ssrf probe",
"channel": "WEBHOOK",
"provider": "CUSTOM_WEBHOOK",
"credentials": { "url": "http://169.254.169.254/latest/meta-data/" }
}' | jq{
"type": "https://errors.kestrelmq.dev/unprocessable-content",
"title": "Unprocessable Content",
"status": 422,
"detail": "Webhook URL rejected: Target host \"169.254.169.254\" resolves to a blocked (private, loopback, link-local or reserved) address",
"instance": "/v1/integrations",
"timestamp": "2026-12-01T10:15:00.000Z"
}Repeat with each of these and you get the same 422:
for URL in \
"http://127.0.0.1:6379/" \
"http://[::1]/" \
"http://[::ffff:7f00:1]/" \
"http://10.0.0.5/" \
"http://100.64.0.1/" \
"http://user:pass@example.com/" \
"file:///etc/passwd"; do
printf '%-34s ' "$URL"
curl -s -X POST "$KMQ/v1/integrations" \
-H "Authorization: Bearer $ACCESS_TOKEN" -H "X-Workspace-Id: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "$(jq -n --arg u "$URL" '{name:"probe",channel:"WEBHOOK",provider:"CUSTOM_WEBHOOK",credentials:{url:$u}}')" \
| jq -r '.detail'
doneThe last two fail on shape rather than address: Target URL must not contain embedded credentials and Target must use the http:// or https:// scheme.
What is blocked
Every address a hostname resolves to is checked, and one blocked answer rejects the target, so an attacker cannot hide a private record behind a public one. IPv4-mapped, NAT64 and 6to4 IPv6 addresses are unwrapped and the embedded IPv4 address is judged. Anything that does not parse is rejected (fail closed).
| Family | Range | Why |
|---|---|---|
| IPv4 | 0.0.0.0/8 | "This network" |
| IPv4 | 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 | RFC 1918 private |
| IPv4 | 100.64.0.0/10 | Carrier-grade NAT |
| IPv4 | 127.0.0.0/8 | Loopback |
| IPv4 | 169.254.0.0/16 | Link-local, cloud metadata |
| IPv4 | 192.0.0.0/24 | IETF protocol assignments |
| IPv4 | 198.18.0.0/15 | Benchmarking |
| IPv4 | 224.0.0.0/4, 240.0.0.0/4 | Multicast and reserved |
| IPv6 | ::/96 | Unspecified, loopback ::1, IPv4-compatible |
| IPv6 | ::ffff:0:0/96 | IPv4-mapped: embedded IPv4 is re-checked |
| IPv6 | 64:ff9b::/96 | NAT64: embedded IPv4 is re-checked |
| IPv6 | 2002::/16 | 6to4: embedded IPv4 is re-checked |
| IPv6 | fc00::/7 | Unique local |
| IPv6 | fe80::/10, fec0::/10 | Link-local and deprecated site-local |
| IPv6 | ff00::/8 | Multicast |
The IPv4-mapped row is the classic bypass: ::ffff:127.0.0.1 is loopback, but a check that only looks at IPv6 ranges sees an address outside all of them.
Why checking once at save time is not enough
Validation at save time alone fails for three reasons: DNS answers change (public today, private tomorrow), redirects can point a public URL at http://10.0.0.5/, and a hostile DNS server can return a public IP for the validation lookup and an internal one, with a zero TTL, for the connection lookup. So KestrelMQ validates again in the worker, immediately before connecting, and then connects to exactly what it validated.
Pinning the socket to the validated IP
Checking the DNS answer is not enough if the HTTP client then performs its own lookup: that second lookup is the rebinding window. The worker resolves the hostname once, validates every address, and hands the socket a lookup function that can only answer with those addresses:
function createPinnedLookup(addresses: { address: string; family: 4 | 6 }[]) {
return (_hostname, options, callback) => {
const candidates =
options.family === 4 || options.family === 6
? addresses.filter((a) => a.family === options.family)
: addresses;
if (candidates.length === 0) return callback(Object.assign(new Error("No pinned address"), { code: "ENOTFOUND" }), "", 0);
if (options.all) return callback(null, candidates);
callback(null, candidates[0].address, candidates[0].family);
};
}
// https.request({ hostname, port, lookup: createPinnedLookup(validated), servername: hostname, ... })The request keeps the original hostname, so TLS SNI, certificate verification and the Host header stay correct. That is why pinning at the socket layer beats rewriting the URL to a bare IP.
Redirects, schemes, ports, response size
- Redirects are never followed. A
3xxis just a non-success response, so a public URL cannot bounce a delivery tohttp://169.254.169.254/. httpandhttpsare accepted; every other scheme (file:,gopher:,ftp:) is rejected, and so is any URL with embeddeduser:pass@credentials.- There is no port allow-list. Internal services often live on odd ports (
6379,5432,9200), but the address block-list already covers where they live. Add egress rules if you also want to restrict ports. - Response capture is capped at 256 KiB (262,144 bytes) and each attempt times out after 10 seconds, which also limits slow-loris style abuse.
- Credentials and PII in stored attempts are masked.
Local development: the one flag
Testing against localhost is legitimate in development. Self-hosted instances can set:
ALLOW_PRIVATE_WEBHOOK_TARGETS=trueThis skips the address block-list but still pins DNS, and the worker logs a warning when it is on. Production refuses to start with it: environment validation fails with ALLOW_PRIVATE_WEBHOOK_TARGETS=true is not permitted when NODE_ENV=production (SSRF protection).
Defense in depth
Application checks should not be the only wall. Run workers in a network segment whose egress rules deny RFC 1918 ranges and the metadata address, enforce IMDSv2 (or equivalent) on cloud hosts, and test with hostile fixtures: http://2130706433 style literals, a name returning one public and one private record, a name that flips between lookups, and a public URL that redirects to 169.254.169.254.
Next step
Run the curl probe loop above against your instance, then read how at-least-once delivery works to see where this worker sits in the pipeline and how outbound requests are signed. The deployment-level controls are in the security and RBAC docs and the security overview.
FAQ
Does KestrelMQ block webhook URLs that point at internal addresses?
Yes, by default. A custom webhook URL that resolves to a private, loopback, link-local or reserved address, such as 169.254.169.254, is rejected with 422 when you create the integration, and re-validated every time the worker delivers. Self-hosted dev setups can opt out with ALLOW_PRIVATE_WEBHOOK_TARGETS, which production startup refuses.
How does KestrelMQ stop DNS rebinding?
The worker resolves the hostname once, rejects the target if any returned address is blocked, then connects only to those validated addresses through a pinned socket lookup. The original hostname is kept for TLS SNI, certificate verification and the Host header, so there is no second DNS lookup to flip.
Does KestrelMQ follow redirects, restrict ports or require https?
It never follows HTTP redirects, so a public URL cannot bounce a delivery to an internal address. It accepts http and https, rejects other schemes and URLs with embedded credentials, and does not enforce a port allow-list. Use egress rules to restrict ports.
Is an egress firewall enough on its own?
No. A network egress policy is an excellent second layer, but application-level checks give clear errors at save time and protect deployments where the firewall is misconfigured. Use both.
Run guaranteed webhook delivery on your own infrastructure
KestrelMQ is MIT-licensed and boots with a single Docker Compose file. Follow the quickstart or start in the hosted dashboard.