agent-governance-toolkit icon indicating copy to clipboard operation
agent-governance-toolkit copied to clipboard

WebhookApprover SSRF guard is partial (loopback, private ranges, DNS rebinding)

Open imran-siddique opened this issue 4 months ago • 3 comments

Summary

WebhookApprover.ValidateEndpoint (added in #3363) is advertised as an SSRF control, but its blocklist is partial. It blocks cloud metadata IPs and link-local ranges, but does not block:

  • localhost / 127.0.0.0/8 (loopback)
  • RFC 1918 private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
  • IPv6 loopback (::1) and unique-local (fc00::/7)
  • DNS rebinding (a hostname that resolves to a blocked address at request time, since validation and the actual request can resolve separately)

Because the webhook endpoint is operator-configured, the immediate risk is low. But the method presents itself as a security boundary, so the gap is worth closing so operators do not over-trust it.

Context

  • Introduced by #3363 (feat(dotnet): add approval chain parity).
  • File: agent-governance-dotnet/.../WebhookApprover.cs, ValidateEndpoint.
  • Flagged during review of #3363; approved as non-blocking with this follow-up.

Proposed fix

  1. Extend the blocklist to loopback, all RFC 1918 / IPv6 unique-local ranges, and 0.0.0.0.
  2. Resolve the host and validate every resolved IP, then pin the connection to a validated address (or re-validate on connect) to defeat DNS rebinding.
  3. Add tests covering loopback, a private-range host, and a rebinding-style host that resolves to a blocked IP.
  4. Until the guard is comprehensive, document in the WebhookApprover XML docs exactly which ranges are and are not blocked, so it is not mistaken for a complete SSRF defense.

Acceptance

  • ValidateEndpoint rejects loopback, private, and IPv6 unique-local targets.
  • Connection binds to a validated resolved address, or re-validates at connect.
  • Tests cover the above, including a rebinding case.

imran-siddique avatar Jul 20 '26 02:07 imran-siddique

🟡 Contributor Check: MEDIUM

Check Result
Profile MEDIUM
Credential LOW
Overall MEDIUM

Automated check by AGT Contributor Check.

github-actions[bot] avatar Jul 20 '26 02:07 github-actions[bot]

Not reachable from main yet, so there is no deployed exposure. WebhookApprover exists only on #3363, which means this can be widened in that PR rather than carried as follow-up debt.

Confirmed still present on the current #3363 head by running ValidateEndpoint directly. Alongside the cases listed above, two others pass validation: the unspecified address 0.0.0.0, and the IPv4-mapped form [::ffff:127.0.0.1].

The mapped-address one seems worth calling out because it survives the obvious fix. IsLinkLocal reaches the IPv4 branch via bytes.Length == 4, so a 16-byte mapped address skips it entirely. A loopback or RFC 1918 check written the same way would have the same blind spot unless addresses are normalized before comparison.

On rebinding: that one is structural rather than a missing entry. ValidateEndpoint runs in the constructor while the request is issued later against _endpoint, so the two resolutions are independent no matter how complete the blocklist becomes. Pinning the connection to a validated address, or revalidating at connect time, is the part a blocklist cannot cover.

Knapp-Kevin avatar Jul 29 '26 00:07 Knapp-Kevin

Closing this. @Knapp-Kevin confirmed WebhookApprover is not reachable from main: it exists only on #3363, so there is no deployed exposure and no follow-up debt to carry.

The right place to widen the guard is #3363 before it merges, covering loopback and 127.0.0.0/8, RFC 1918, ::1 and fc00::/7, 0.0.0.0, the IPv4-mapped form, and re-resolving at request time for rebinding. Carrying it as a separate issue mainly risks the PR merging while this sits open.

imran-siddique avatar Aug 15 '26 21:08 imran-siddique