Commit Graph
2 Commits
Author SHA1 Message Date
DashCaddy Polish Loop 5382d832d9 fix(fleet): SSRF hardening — hostname validation + DNS rebinding + probe-by-IP (DC-068) [glm-grade=A]
CI / Security audit (push) Canceled after 0s
CI / Test & Lint (push) Canceled after 0s
bug: POST /api/v1/fleet/hosts (DC-108) accepted any string as the
hostname field and the followup GET /fleet/status flow composed it
verbatim into a probe URL. An authenticated dashboard operator could
register 127.0.0.1 or 169.254.169.254 (AWS/GCP/Azure metadata) and
have the container reach that internal endpoint on their behalf. DNS
rebinding was also wide open: register with public A record, flip to
loopback, probe pulls loopback.

fix: 4 layers of defense

1. New fleet-validation.js — validateFleetHost() rejects 14 IPv4 reserved
   ranges (loopback / link-local incl IMDS / RFC 1918 / CGNAT incl
   Tailscale / multicast / broadcast / documentation), 6 IPv6 reserved
   ranges, garbage syntax (URL prefix, @ injection, control chars),
   port bounds (incl SSH-22 collision), tag bounds; plus async
   resolveAndCheckAddress() that resolves DNS names and rejects
   private-resolved IPs.

2. routes/fleet.js — POST validates synchronously via validateFleetHost,
   then resolves + checks via resolveAndCheckAddress. Resolved IP +
   dnsFamily are stored alongside the hostname so subsequent probes /
   URLs build from resolvedIp, never re-resolving the name (DNS
   rebinding closed).

3. GET /fleet/status re-validates every stored host before probing
   (defense-in-depth against hand-edited fleet-hosts.json) and
   categorizes hosts as validation_failed vs probe-able. Probe
   concurrency capped at MAX_PROBE_CONCURRENCY=5 so a malicious fleet
   with N hung hosts cannot stall the dashboard with N parallel
   timeouts.

4. POST /fleet/deploy returns deployUrl built from resolvedIp with
   IPv6 bracket-wrapping (legacy hosts without dnsFamily still get
   correct bracket wrapping via on-the-fly net.isIP check).

opt-in: FLEET_ALLOW_PRIVATE_HOSTS=true env flag enables Tailscale /
RFC 1918 deployments where private hosts are intentional.

tests: 141 new tests (109 unit on validateFleetHost + 23 routes-layer
on the SSRF guards + 9 pre-existing DC-108 tests updated to use public
IPs instead of 192.168.x / 10.x). 2277 / 2277 pass on DNS2.

manual verification: GLM-5.3 judge round 1 = A (4 tool calls, 49s,
ship). IPv4-mapped IPv6 edge case ::ffff:127.0.0.1 caught correctly
via net.isIP + delegated IPv4 check.
2026-08-18 13:16:44 -07:00
Krystie 503de258b8 [grade=pending] QA sprint: commit 103 at-risk files from multi-agent sprint work
Committed by Hermes autonomous QA sprint 2026-08-13.
These files were modified during the Aug 12 sprint but never committed.
2026-08-12 17:34:10 -07:00