MVP-0.9 · Pin resolved addresses and validate redirect hops (DNS rebinding, SSRF follow-up to #256) #294

Closed
opened 2026-09-20 21:15:12 +00:00 by sharang · 0 comments
Owner

Follow-up to #256, which added compliance_core::net_guard and enforces it at every point where a tenant chooses where the scanner connects. That check happens before the request; this issue closes the window between the check and the connection.

Goal

A target that passes the guard must also be what it claimed when the bytes actually flow. Two gaps remain:

  • DNS rebinding / TOCTOU. check_resolved resolves a hostname and requires every answer to be public, but the HTTP client resolves the name again when it connects. A name whose record flips between a public address and 169.254.169.254 passes the check and then connects to the metadata service.
  • Redirects. A public URL may answer 302 http://pruefwerk-mongo:27017/ (or to a private address), and the client follows it. Only the first hop is currently checked.

What to change

  • Pin the address: resolve once through the guard, then connect to that address. In reqwest this is ClientBuilder::resolve/resolve_to_addrs for the checked host, or a custom dns::Resolve that runs the guard and returns only the addresses it approved.
  • Validate every redirect hop with redirect::Policy::custom: re-run NetGuard::check_url plus the address check on each Attempt, and stop rather than follow when it fails. Cap the hop count.
  • Apply both to every client that fetches a tenant-chosen URL: the DAST crawler and its tools (compliance-dast), the pentest browser/HTTP tools, and any agent-side fetch of a target URL. A shared constructor (net_guard::guarded_client()) is preferable to repeating the policy per call site.
  • The ICS probe connects to a host/port directly rather than through reqwest, so it needs the resolved address pinned into the TcpStream connect rather than re-resolving.

Acceptance

  • A test host whose DNS answer alternates public/private cannot be scanned: the connection is refused, not merely logged.
  • A redirect to a private address, an internal name or a non-HTTP scheme is refused, and the refusal names the hop.
  • Redirect chains are capped and the cap is covered by a test.
  • Unit tests use a stub resolver, so no test depends on live DNS.

Notes

Raised during the review of #256 and filed for the Production MVP milestone by the user's decision ("we will tackle it as it comes"). Part of #253 · MVP-0 safety baseline.

Follow-up to #256, which added `compliance_core::net_guard` and enforces it at every point where a tenant chooses where the scanner connects. That check happens *before* the request; this issue closes the window between the check and the connection. ## Goal A target that passes the guard must also *be* what it claimed when the bytes actually flow. Two gaps remain: - **DNS rebinding / TOCTOU.** `check_resolved` resolves a hostname and requires every answer to be public, but the HTTP client resolves the name again when it connects. A name whose record flips between a public address and `169.254.169.254` passes the check and then connects to the metadata service. - **Redirects.** A public URL may answer `302 http://pruefwerk-mongo:27017/` (or to a private address), and the client follows it. Only the first hop is currently checked. ## What to change - Pin the address: resolve once through the guard, then connect to **that** address. In reqwest this is `ClientBuilder::resolve`/`resolve_to_addrs` for the checked host, or a custom `dns::Resolve` that runs the guard and returns only the addresses it approved. - Validate every redirect hop with `redirect::Policy::custom`: re-run `NetGuard::check_url` plus the address check on each `Attempt`, and stop rather than follow when it fails. Cap the hop count. - Apply both to every client that fetches a tenant-chosen URL: the DAST crawler and its tools (`compliance-dast`), the pentest browser/HTTP tools, and any agent-side fetch of a target URL. A shared constructor (`net_guard::guarded_client()`) is preferable to repeating the policy per call site. - The ICS probe connects to a host/port directly rather than through reqwest, so it needs the resolved address pinned into the `TcpStream` connect rather than re-resolving. ## Acceptance - A test host whose DNS answer alternates public/private cannot be scanned: the connection is refused, not merely logged. - A redirect to a private address, an internal name or a non-HTTP scheme is refused, and the refusal names the hop. - Redirect chains are capped and the cap is covered by a test. - Unit tests use a stub resolver, so no test depends on live DNS. ## Notes Raised during the review of #256 and filed for the Production MVP milestone by the user's decision ("we will tackle it as it comes"). Part of #253 · MVP-0 safety baseline.
sharang added this to the Production MVP milestone 2026-09-20 21:15:12 +00:00
sharang added the enhancementsecurity labels 2026-09-20 21:15:12 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: platform/pruefwerk#294