Repository navigation
fix(webhooks): deliver agent and App webhooks only to public addresses - #2188
Merged
Merged
Conversation
samxu01
force-pushed
the
fix/webhook-public-address-guard
branch
from
October 15, 2026 00:02
92ba7c1 to
f77f0fe
Compare
Adds an open-destination mode to backend/services/outboundUrlGuard.ts, next
to fetchTextFromAllowedHost, for URLs whose destinations cannot be listed in
advance.
- postToPublicAddress allows http(s) only. It resolves the host itself and
refuses unless every address the host resolves to is allowed. It connects
to the address it checked, using a pinned lookup on the http(s) request, so
a second DNS answer cannot substitute another. Every redirect hop is
resolved and checked again: 307/308 keep the method and body, 301/302/303
continue as a GET, at most 5 hops. A 10s deadline and a 1 MB response cap
apply.
- classifyAddress holds the ranges:
- reserved: unspecified, link-local (including the metadata endpoint),
multicast, broadcast and 240/4.
- private: loopback, RFC 1918, CGNAT, IPv6 unique-local.
- IPv4-mapped and NAT64 forms are classified by the IPv4 address they
carry.
- metadata.google.internal is refused by name.
- OUTBOUND_WEBHOOK_ALLOW_PRIVATE_ADDRESSES=true admits private ranges for a
local or self-hosted setup, following the existing *_ALLOW_UNVERIFIED
convention. It is off by default, and reserved ranges stay refused.
- Callers: agent push webhook delivery (agentEventService) and App
installation webhooks (appService). AppService.deliverWebhook had no
callers anywhere and is removed rather than guarded.
Tests: outboundUrlGuard.publicAddress (100), appService.webhookGuard (5), and
a refusal arm in agentEventService.lifecycle that runs the real guard.
Connection arms use a local receiver on 127.0.0.1 reached through .test names
that system DNS cannot resolve, so an arriving request proves the pinned
address was used.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UPw8eqDcnT3Q6yPxVqpAC1
samxu01
force-pushed
the
fix/webhook-public-address-guard
branch
from
October 15, 2026 00:34
f77f0fe to
e49999d
Compare
lilyshen0722
commented
Oct 15, 2026
lilyshen0722
left a comment
Contributor
Author
There was a problem hiding this comment.
Review at e49999d (eng lead, code and security gate). One commit on current main, 0 behind.
Checked:
- Address classification (
classifyAddress):- IPv4 reserved: 0/8, link-local 169.254/16 (the metadata address included), multicast and 240/4.
- IPv4 private: 10/8, CGNAT 100.64/10, loopback, 172.16/12 and 192.168/16.
- IPv6 is classified through the URL parser's canonical form, so IPv4-mapped (
::ffff:) and NAT64 (64:ff9b::/96) addresses are judged as the IPv4 address they embed. Loopback, unique-local, link-local and multicast are refused, and an unparsable address reads as reserved.
- Name and DNS:
metadata.google.internalis refused by name, with and without the trailing dot. Every DNS answer must be allowed, not just the first. - Pinning:
requestPinnedconnects to the checked address through a customlookup, while TLS still verifies the certificate against the URL's hostname. A second DNS answer can't swap the destination between check and connect. - Redirects: at most 5, each re-resolved and re-checked. A 301, 302 or 303 downgrades to a GET without the body, and a 307 or 308 keeps the method. One 10-second deadline spans every hop, and the response body is capped at 1 MB.
- Self-host flag:
OUTBOUND_WEBHOOK_ALLOW_PRIVATE_ADDRESSES=trueadmits private ranges only. Reserved ranges and the metadata name stay refused. It's off by default and documented in.env.example. - Callers: agent push webhooks (
agentEventService) and App installation webhooks (appService.deliverWebhookByInstallation) both deliver throughpostToPublicAddress. The deleteddeliverWebhookhas no remaining references, and no other backend code sends a request straight to a stored webhook URL. - CI: all checks are green, and the two cancelled runs were superseded by passing ones. No CodeQL alerts are open on the PR's merge ref.
- Tests at this head: 61 backend suites touching the guard, App webhooks, agent events and the skills catalog pass (838 tests).
agentsRuntime.rateLimitTierspasses alone and serially (3), and lint shows 0 errors on the three changed services.
Non-blocking notes:
- On a cross-host redirect,
X-Commonly-Signatureis still sent, and a 307 or 308 also forwards the body. Neither leaks a secret, since the header is an HMAC of the payload and the receiver chose the redirect. Dropping the signature when the origin changes would still be tidy. - A few special-purpose IPv4 ranges classify as public: 192.0.0.0/24, benchmarking 198.18.0.0/15, the TEST-NETs, and the deprecated IPv6 site-local fec0::/10. None routes to cluster-internal addresses here. Worth adding if the table is touched again.
GATE: PASS
samxu01
pushed a commit
that referenced
this pull request
Oct 21, 2026
…d the webhook runtime doc (TASK-005) ADR-004 says the kernel never POSTs to a driver and delivers at least once. Push shipped in #73 (2026-04-02), twelve days before the ADR, and every install with config.runtime.webhookUrl is pushed to. A failed push stays pending and nothing sends it again: the requeue acts only on delivered rows, the stranded-pending sweep covers in-process agents only, and the GC deletes the row after the retention, 168 h by default. Nor is push at most once: a 307 or 308 replays the same POST within one attempt, up to six requests in all. - ADR-004: conformance entry C4, plus an inline marker at each of the six sentences it contradicts and at the rejected push alternative. C4 names the two changes push has had since #73: #822 and #2188. - ADR-006: pointers at the two non-goals that repeat the claim. The second also called webhookSecret unused; it signs each push. - WEBHOOK_RUNTIME.md: the 30-minute failed-close it described applies only to in-process agents. A failed push is never sent again, and a redirect can replay one, so a receiver dedupes on X-Commonly-Delivery. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: wren <[email protected]> Agent-Model: claude/claude-opus-5-5/max
samxu01
pushed a commit
that referenced
this pull request
Oct 22, 2026
…d the webhook runtime doc (TASK-005) ADR-004 says the kernel never POSTs to a driver and delivers at least once. Push shipped in #73 (2026-04-02), twelve days before the ADR, and every install with config.runtime.webhookUrl is pushed to. A failed push stays pending and nothing sends it again: the requeue acts only on delivered rows, the stranded-pending sweep covers in-process agents only, and the GC deletes the row after the retention, 168 h by default. Nor is push at most once: a 307 or 308 replays the same POST within one attempt, up to six requests in all. - ADR-004: conformance entry C4, plus an inline marker at each of the six sentences it contradicts and at the rejected push alternative. C4 names the two changes push has had since #73: #822 and #2188. - ADR-006: pointers at the two non-goals that repeat the claim. The second also called webhookSecret unused; it signs each push. - WEBHOOK_RUNTIME.md: the 30-minute failed-close it described applies only to in-process agents. A failed push is never sent again, and a redirect can replay one, so a receiver dedupes on X-Commonly-Delivery. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: wren <[email protected]> Agent-Model: claude/claude-opus-5-5/max
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Agent push webhooks and App installation webhooks POST to a URL their owner registered. Neither delivery checked where that URL resolved. Both now go through a new open-destination mode of the outbound guard.
postToPublicAddress(inbackend/services/outboundUrlGuard.ts, next tofetchTextFromAllowedHost)dns.promises.lookup, all answers. Every answer must be allowed, so a name with one public and one private record is refused. Address literals are checked directly.metadata.google.internalis refused by name before any lookup.lookupon thehttp/httpsrequest. A second DNS answer cannot move it, and TLS still verifies the certificate against the URL's hostname.fetchdoes), at most 5 hops.classifyAddress(the ranges)0.0.0.0/8,169.254.0.0/16(incl.169.254.169.254),224.0.0.0/4,240.0.0.0/4(incl.255.255.255.255),::, the IPv4-compatible::/96,fe80::/10,ff00::/8, anything unparseable127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,100.64.0.0/10,::1,fc00::/7IPv4-mapped (
::ffff:a.b.c.d, in dotted and hex spellings) and NAT64 (64:ff9b::/96) addresses are classified by the IPv4 address they carry.Dev and self-host
Local webhook receivers are a real case:
commonly agent register --webhook <url>stores whatever URL is given. I looked for an existing convention and followed the*_ALLOW_UNVERIFIEDflags (=== 'true', off by default).OUTBOUND_WEBHOOK_ALLOW_PRIVATE_ADDRESSES=trueadmits the private class..env.exampleand indocs/architecture/WEBHOOK_RUNTIME.md.commonly agent connect, is unaffected: the CLI polls the instance and forwards to localhost itself.Callers
agentEventService.deliverEventViaWebhook:fetchis replaced bypostToPublicAddress. A refusal lands in the existing catch, which logs it, and the event is not acked.AppService.deliverWebhookByInstallation:axios.postis replaced bypostToPublicAddress. A non-2xx reply is reported as{ success: false, reason: 'HTTP <n>', statusCode }.AppService.deliverWebhookhad no callers in backend, frontend or CLI, and no tests. It is removed rather than guarded. With it gone,appServiceno longer importsaxios.docs/security-patterns.mdnow describes both modes and when to use each.Tests
Run on Node 22.
outboundUrlGuard.publicAddress.test.js, new, 100 tests.classifyAddresstable: public, private and reserved, including the edges of every IPv4 block, IPv4-mapped (dotted and hex) and NAT64 forms, the IPv4-compatible block, and a zone id.Refusals with the flag unset (the default):
Every refusal arm asserts that no
http/httpsrequest was made. In those arms the request functions throw instead of connecting, so even a broken guard can't reach the network.Connections, against a local receiver on 127.0.0.1 (flag on), reached through
.testnames that system DNS can't resolve, so a request arriving proves the pinned address was used:file:URL are refused after exactly one request;appService.webhookGuard.test.js, new, 5 tests.agentEventService.lifecycle.test.jspostToPublicAddressand still terminates asacked.Regression: every suite that loads a changed module passes (67 suites, 955 tests), plus
service/apps.test.js.Mutation check. 17 arms, each landing once at a named line. Every arm goes red, and the suite count (4) and test total (176) stay constant in every arm:
fe80::/10treated as publiclookup)Lint: 0 errors on the three changed
.tsfiles. The address arithmetic uses division and range comparisons rather than bitwise operators, so nono-bitwiseoverride is needed.tsc --noEmit -p tsconfig.build.jsonis clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01UPw8eqDcnT3Q6yPxVqpAC1