#256 checked tenant-chosen addresses before connecting. Two gaps remained, plus a third found while mapping this:
DNS rebinding: HTTP clients resolved the name again when they connected.
Redirects: only the first URL was checked, and every redirect was followed.
Git never resolved the name at all.check_git_url checks only syntax and hostname rules, so https://evil.example/x.git with DNS pointing at 10.x or 169.254.169.254 was cloned from the internal host. This is the path that is live in production.
Change
compliance_core::guarded_net (new net feature, included in axum):
guarded_client_builder(guard) gives reqwest a DNS resolver that is the guard. It returns only approved addresses (every answer must pass), so the connection goes exactly where the check said and there is no second lookup to win. It also:
uses a redirect policy that re-checks every hop's scheme and host, with IP literals classified here because reqwest connects to those without asking the resolver;
follows at most 5 redirects, and a refusal names the hop;
sets no_proxy(), because a proxy would resolve names itself.
resolve_approved() does the same for raw TCP callers.
Lookup is a trait, so tests use a stub resolver, not live DNS.
Git, "check before clone" (your pick; Jev leaned A too, but with low confidence 0.44):
GitOps::check_remote resolves and requires public addresses right before every clone, and on every fetch too: it re-reads origin, since DNS can change after the clone.
libgit2 redirects are off (RemoteRedirect::None).
A refused clone leaves no empty checkout behind.
The unused GitOps::test_access is removed.
The remaining window (near-zero-TTL rebinding between our lookup and libgit2's) is documented in the code and tracked in #320.
Now guarded:
the Gitea tracker, whose base URL is the tenant's git host;
the DAST orchestrator (crawler, recon, attack agents), the pentest tool registry and the cookie analyzer's no-redirect client;
the TLS analyzer and the four ICS probes, which now connect to the approved IP (probe findings name the address actually probed).
Deliberately unguarded:
The soft-PLC WebVisu DAST uses NetGuard::allow_private(), because it scans a container the platform itself started; schemes and the redirect cap still apply.
GitLab, GitHub, Jira, OSV, NVD and the controls backend are operator-set or fixed hosts.
Not coverable here: the DAST/pentest browser is an external Chrome that resolves and redirects on its own, so it needs network isolation: #321. DAST and pentest are off in production.
Docs: the "Where a scan may connect" section explains pinning, redirects and the git behaviour.
Verification
cargo fmt --check and clippy -D warnings pass on all CI targets, plus compliance-dast.
every_answer_must_be_public: mixed and metadata answers are refused, and literals are classified without a lookup.
a_rebinding_name_never_reaches_the_private_address: a stub answers public first and private second, and a local server listens on the private address. The server gets 0 hits, the resolver is called exactly once, and once the name answers private it is refused with "not a public address".
the_resolver_is_what_connects: positive control; with allow_private, the stubbed name really does reach the server.
redirect_hops_are_checked_and_named: hops to the metadata address, 10.x, mongo:27017, .internal, ftp:// and file:// are each refused, and the error names the hop; the cap is enforced.
a_client_stops_at_a_refused_hop_and_at_the_cap: a real 302 to ftp:// is refused with the hop named, and a redirect loop stops after exactly 5 followed hops.
New git tests: the metadata address is refused before connecting and leaves no checkout; a fetch re-checks a stored origin that now points at 10.0.0.5.
Real binary:
A target https://localtest.me/org/repo.git (public DNS pointing at ::1) fails with "localtest.me resolves to ::1, which is not a public address". It was cloned before this change.
github.com/dtolnay/itoa clones and scans normally.
A rescan takes the fetch path (re-check, fast-forward, "no new commits").
Mongo suites (credentials, lifecycle, werkbank_api, tenant_isolation) pass. One werkbank_api run failed when the local Mongo container crashed on its file-descriptor limit; it passed on rerun.
MVP-0.9 of #253, the last MVP-0 item. Closes #294.
## Problem
#256 checked tenant-chosen addresses *before* connecting. Two gaps remained, plus a third found while mapping this:
1. **DNS rebinding:** HTTP clients resolved the name again when they connected.
2. **Redirects:** only the first URL was checked, and every redirect was followed.
3. **Git never resolved the name at all.** `check_git_url` checks only syntax and hostname rules, so `https://evil.example/x.git` with DNS pointing at `10.x` or `169.254.169.254` was cloned from the internal host. **This is the path that is live in production.**
## Change
- **`compliance_core::guarded_net`** (new `net` feature, included in `axum`):
- `guarded_client_builder(guard)` gives reqwest a DNS resolver that **is** the guard. It returns only approved addresses (every answer must pass), so the connection goes exactly where the check said and there is no second lookup to win. It also:
- uses a redirect policy that re-checks every hop's scheme and host, with IP literals classified here because reqwest connects to those without asking the resolver;
- follows at most 5 redirects, and a refusal **names the hop**;
- sets `no_proxy()`, because a proxy would resolve names itself.
- `resolve_approved()` does the same for raw TCP callers.
- `Lookup` is a trait, so tests use a **stub resolver**, not live DNS.
- **Git, "check before clone"** (your pick; Jev leaned A too, but with low confidence 0.44):
- `GitOps::check_remote` resolves and requires public addresses right before every clone, and on every fetch too: it re-reads `origin`, since DNS can change after the clone.
- libgit2 redirects are off (`RemoteRedirect::None`).
- A refused clone leaves no empty checkout behind.
- The unused `GitOps::test_access` is removed.
- The remaining window (near-zero-TTL rebinding between our lookup and libgit2's) is documented in the code and tracked in **#320**.
- **Now guarded:**
- the Gitea tracker, whose base URL is the tenant's git host;
- the DAST orchestrator (crawler, recon, attack agents), the pentest tool registry and the cookie analyzer's no-redirect client;
- the TLS analyzer and the four ICS probes, which now connect to the approved IP (probe findings name the address actually probed).
- **Deliberately unguarded:**
- The soft-PLC WebVisu DAST uses `NetGuard::allow_private()`, because it scans a container the platform itself started; schemes and the redirect cap still apply.
- GitLab, GitHub, Jira, OSV, NVD and the controls backend are operator-set or fixed hosts.
- **Not coverable here:** the DAST/pentest browser is an external Chrome that resolves and redirects on its own, so it needs network isolation: **#321**. DAST and pentest are off in production.
- **Docs:** the "Where a scan may connect" section explains pinning, redirects and the git behaviour.
## Verification
- `cargo fmt --check` and clippy `-D warnings` pass on all CI targets, plus `compliance-dast`.
- Tests pass: core 90, agent 355, werkbank-exec 9, control-map 28, compliance-dast 63.
- **New `guarded_net` tests:**
- `every_answer_must_be_public`: mixed and metadata answers are refused, and literals are classified without a lookup.
- `a_rebinding_name_never_reaches_the_private_address`: a stub answers public first and private second, and a local server listens on the private address. The server gets **0 hits**, the resolver is called **exactly once**, and once the name answers private it is refused with "not a public address".
- `the_resolver_is_what_connects`: positive control; with `allow_private`, the stubbed name really does reach the server.
- `redirect_hops_are_checked_and_named`: hops to the metadata address, `10.x`, `mongo:27017`, `.internal`, `ftp://` and `file://` are each refused, and the error names the hop; the cap is enforced.
- `a_client_stops_at_a_refused_hop_and_at_the_cap`: a real 302 to `ftp://` is refused with the hop named, and a redirect loop stops after exactly 5 followed hops.
- **New git tests:** the metadata address is refused before connecting and leaves no checkout; a fetch re-checks a stored `origin` that now points at `10.0.0.5`.
- **Real binary:**
- A target `https://localtest.me/org/repo.git` (public DNS pointing at `::1`) **fails with "localtest.me resolves to ::1, which is not a public address"**. It was cloned before this change.
- `github.com/dtolnay/itoa` clones and scans normally.
- A rescan takes the fetch path (re-check, fast-forward, "no new commits").
- Mongo suites (`credentials`, `lifecycle`, `werkbank_api`, `tenant_isolation`) pass. One `werkbank_api` run failed when the local Mongo container crashed on its file-descriptor limit; it passed on rerun.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
#256 checked a tenant-chosen address before connecting. That left two gaps:
the client resolved the name again when connecting (DNS rebinding), and
redirects were never checked. The git path never resolved the name at all, so
a public-looking host pointing at 10.x or the metadata address was cloned.
- `compliance_core::guarded_net` (feature `net`):
- `guarded_client_builder` gives reqwest a resolver that *is* the guard: it
returns only approved addresses, so the connection goes where the check
said. It also re-checks every redirect hop (at most 5; a refusal names the
hop) and sets no_proxy.
- `resolve_approved` does the same for raw TCP callers.
- `Lookup` is a trait, so tests use a stub resolver instead of live DNS.
- Git: `GitOps::check_remote` resolves and requires public addresses right
before every clone, and again on every fetch (it re-reads origin). libgit2
redirects are off. A refused clone leaves no empty checkout behind. The
unused `test_access` is removed. Full pinning for git is #320 (chosen
deliberately).
- Gitea tracker (its base URL is the tenant's git host), the DAST orchestrator,
the pentest tool registry and the cookie analyzer use guarded clients. The
TLS analyzer and the ICS probes connect to the approved IP.
- The soft-PLC WebVisu DAST scans a platform-started container, so it uses an
allow-private guard. The browser (external Chrome) cannot be pinned from
here: #321.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang
merged commit 40c7557349 into main2026-09-21 20:26:44 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
MVP-0.9 of #253, the last MVP-0 item. Closes #294.
Problem
#256 checked tenant-chosen addresses before connecting. Two gaps remained, plus a third found while mapping this:
check_git_urlchecks only syntax and hostname rules, sohttps://evil.example/x.gitwith DNS pointing at10.xor169.254.169.254was cloned from the internal host. This is the path that is live in production.Change
compliance_core::guarded_net(newnetfeature, included inaxum):guarded_client_builder(guard)gives reqwest a DNS resolver that is the guard. It returns only approved addresses (every answer must pass), so the connection goes exactly where the check said and there is no second lookup to win. It also:no_proxy(), because a proxy would resolve names itself.resolve_approved()does the same for raw TCP callers.Lookupis a trait, so tests use a stub resolver, not live DNS.GitOps::check_remoteresolves and requires public addresses right before every clone, and on every fetch too: it re-readsorigin, since DNS can change after the clone.RemoteRedirect::None).GitOps::test_accessis removed.NetGuard::allow_private(), because it scans a container the platform itself started; schemes and the redirect cap still apply.Verification
cargo fmt --checkand clippy-D warningspass on all CI targets, pluscompliance-dast.guarded_nettests:every_answer_must_be_public: mixed and metadata answers are refused, and literals are classified without a lookup.a_rebinding_name_never_reaches_the_private_address: a stub answers public first and private second, and a local server listens on the private address. The server gets 0 hits, the resolver is called exactly once, and once the name answers private it is refused with "not a public address".the_resolver_is_what_connects: positive control; withallow_private, the stubbed name really does reach the server.redirect_hops_are_checked_and_named: hops to the metadata address,10.x,mongo:27017,.internal,ftp://andfile://are each refused, and the error names the hop; the cap is enforced.a_client_stops_at_a_refused_hop_and_at_the_cap: a real 302 toftp://is refused with the hop named, and a redirect loop stops after exactly 5 followed hops.originthat now points at10.0.0.5.https://localtest.me/org/repo.git(public DNS pointing at::1) fails with "localtest.me resolves to ::1, which is not a public address". It was cloned before this change.github.com/dtolnay/itoaclones and scans normally.credentials,lifecycle,werkbank_api,tenant_isolation) pass. Onewerkbank_apirun failed when the local Mongo container crashed on its file-descriptor limit; it passed on rerun.🤖 Generated with Claude Code
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p