Skip to content

T34 — Refuse proxied requests exactly as direct connections, and close HTTP/2 at the proxy - #1737

Merged
norrietaylor merged 6 commits into
mainfrom
agent/1639-refuse-proxied-requests-exactly-as-direct-connec
Sep 26, 2026
Merged

norrietaylor merged 6 commits into
mainfrom
agent/1639-refuse-proxied-requests-exactly-as-direct-connec

Conversation

@minimal-foundry

Copy link
Copy Markdown
Contributor

T34 — Refuse proxied requests exactly as direct connections, and close HTTP/2 at the proxy

slice: S8
kind: task
covers: NET-069, NET-070, NET-071, NET-135
size: L
est: 400 code, 300 tests
executor: agent
difficulty: needs care
model: strongest
diagnostics: the bundle's daemon log tail shows each proxy refusal with the same rule name a direct refusal carries
observability: one warn log line per proxy refusal with the caller, the target, the port and the rule, in the shape of the relay's drop line
layers:
- daemon:
- crates/minimald/src/net/proxy.rs: closes on the HTTP/2 preface, strips the h2c upgrade and its headers, and checks the target's declared ports and the caller's egress before connecting
- crates/minimald/src/net/dns.rs: a registration carries the target's declared ingress ports and the lease-to-session map that names the caller
- crates/minimald/src/session.rs: register_hostname passes the ports
- crates/minimald/src/server.rs: start_host_proxies hands the proxy the verdict it shares with the relay
- crates/minimald/src/net/switch.rs: exposes the declared-port logic so both surfaces reach the same verdict
test: cargo nextest run -p minimald proxy_undeclared_port_refused_like_direct
test: cargo nextest run -p minimald proxy_caller_egress_denied
test: cargo nextest run -p minimald proxy_parity_across_network_modes
test: cargo nextest run -p minimald hostname_proxy_closes_h2_preface
test: cargo nextest run -p minimald hostname_proxy_strips_h2c_upgrade
produces: none
consumes:
- crates/sessions/src/core/egress.rs
proof: A request through the proxy to a port the target box did not declare, or from a caller whose rules deny the target, is refused with the same refusal a direct connection gets on host-address and own-address targets alike, and an HTTP/2 preface is closed at once.
depends on:
- blocked by #1611
- blocked by #1629
- blocked by #1623

Proof

A request through the hostname proxy is now put, before the proxy dials anything, to the same verdict a direct connection between the same two boxes meets: a request to a port the target box did not declare, or from a caller whose egress rules deny the target, is refused with 403 Forbidden and one warn line carrying the same rule name a direct refusal logs, on host-address and own-address targets alike (property-tested across every network mode, egress rule set and requested port); and a connection that opens with the HTTP/2 prior-knowledge preface is closed at once with no response bytes, while a request offering Upgrade: h2c is routed as the HTTP/1.1 request it is, with the offer, its HTTP2-Settings header and their Connection tokens stripped before the head reaches the upstream.

Notes from the agent: One verdict function decides both surfaces: net::switch::proxied_request_verdict composes the relay's own helpers (the pure sessions egress verdict over a synthesized TCP frame for the caller's half, the route's port gate and the relay's NO_INGRESS_MAPPING_RULE for the target's half); server::start_host_proxies hands the router that function, so the routing core stays pure over the registry's facts and there is exactly one admit-or-drop derivation in the tree. Semantics worth knowing: a proxied request names the target's external port while the relay's gate admits the mapping's internal one, so the parity the tests hold is 'the proxy forwards only to a box-side port the same declaration admits (translating through the map on a VM host, the published external port on the native published-loopback model) and refuses every port the declaration does not publish' — SessionGate::admits_direct_tcp exposes the gate's half for that assertion; direct box-to-box enforcement at the target's own address is NET-073, a separate task. register_host_net kept its two-argument signature because a host-address box declares no ingress at all (Record::validate_policy reje…[truncated]

Tests

line exit tail
cargo nextest run -p minimald proxy_undeclared_port_refused_like_direct 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-6894... Compiling ot v0.0.1 (/home/runner/.local/state/minimal/sessions/a34b9/tree/crates/ot) Compiling args v0.0.1 (/home/runner/.local/state/minimal/sessions/a34b9/tree/crates/args) C
cargo nextest run -p minimald proxy_caller_egress_denied 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-bc8e... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/2bba0/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/2bba0/tree/crate
cargo nextest run -p minimald proxy_parity_across_network_modes 0 Applying loadouts: default Running task runtime-implement-test-2 in session task-runtime-implement-test-2-c2d3... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/b2c1e/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/b2c1e/tree/crate
cargo nextest run -p minimald hostname_proxy_closes_h2_preface 0 Applying loadouts: default Running task runtime-implement-test-3 in session task-runtime-implement-test-3-bf9e... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/2a3f4/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/2a3f4/tree/crate
cargo nextest run -p minimald hostname_proxy_strips_h2c_upgrade 0 Applying loadouts: default Running task runtime-implement-test-4 in session task-runtime-implement-test-4-766b... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/b8d16/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/b8d16/tree/crate

Verify

min task run agent-verify passed ([tasks.verify]).

Closes #1639

A request through the hostname proxy is now put to the same verdict a
direct connection between the same two boxes meets, before the proxy
dials anything: the caller's compiled egress rules first (NET-070),
then the target's declared ingress ports (NET-069), on host-address
and own-address targets alike (NET-071). One function,
net::switch::proxied_request_verdict, decides it through the relay's
own helpers - the pure egress verdict over a synthesized TCP frame,
the route's port gate, the relay's drop-line vocabulary - and
server::start_host_proxies hands the router that function, so the
routing core stays pure over the registry's facts.

The registry now carries the facts that verdict reads: a route carries
the target's declared request ports (the external ports its ingress
publishes, on every host form), and a lease-to-session map joins a
proxied request's peer address onto the caller's recorded name and
compiled egress rules. The session actor records callers at hostname
registration; the attach path joins the lease when the box reports it.

The proxy closes a connection that opens with the HTTP/2
prior-knowledge preface at once - it routes HTTP/1.1 requests and
CONNECT tunnels only (NET-135) - and strips an Upgrade: h2c offer,
its HTTP2-Settings header and their Connection tokens before the head
is replayed upstream, so a request offering h2c is routed as the
HTTP/1.1 request it is. Every refusal logs one warn line in the
relay drop line's shape, with the caller, the target, the port and
the rule.
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 2d6027d4-7812-4658-83ef-4da13925a274

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@minimal-foundry

minimal-foundry Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Reviewed: 1 finding, none blocking at 132364469aab.

Address the comments on the diff.

Clobber: none: git log on the changed files shows no recent fix reverted, and the two earlier commits this branch merges in (544e332, c46dd64) are already reflected in the tree.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Comment thread crates/minimald/src/net/switch.rs Resolved
@norrietaylor

Copy link
Copy Markdown
Member

Babysitter review against T34's plan block (covers NET-069, NET-070, NET-071, NET-135; five layers, exactly the five files touched). Round 1 is in flight on minimal-review's declared_request_ports finding, so this is for that round and the next; not a /revise.

Agree with the open finding, and rate it MEDIUM, crates/minimald/src/net/switch.rs declared_request_ports: an own-address box with no [ingress] collapses to None, which on a native host re-registers Route::loopback(session, None) after rename/finalize and then forwards any port to 127.0.0.1 by box name, where the direct gate drops the SYN. The parity property never generates that input (own-address targets always get ingress: Some(..)); add it.

MEDIUM, proxy.rs caller_at: NET-070 is enforced only when the proxy's TCP peer is a lease, and in the shipped deployments it usually is not. On a native host the proxy binds 127.0.0.1 and boxes reach it through the switch NAT (nat: "<host_alias>": "127.0.0.1" in the switch config), so the peer is 127.0.0.1, caller_at yields None, and the request is "ungated here". A box whose egress denies a sibling reaches the sibling's declared ports through the proxy while its direct connection drops. On a VM host it is attributable only when the box dials daemon_ip:7654, not host_alias:7654. proxy_caller_egress_denied proves the mechanism with a bound 127.0.0.2 stand-in, not the deployment path. This is the plan's gap, not the coder's: the block assumes a lease-to-session map names the caller, and the spec's NET-132 comment already concedes NAT gives the proxy one source for every box. T43 #1652 (deliver a box's connection to the proxy from its own switch address) is where it closes. For this PR: say in the module doc that a NATed peer is unattributed and ungated until T43, and keep the caller="none" field on the log line so the gap is visible.

LOW

  • proxy.rs h2c strip runs once on the first request's buffered head; a pipelined second request in the same read, or any later keep-alive request on the spliced connection, carries Upgrade: h2c upstream. NET-135's sub-requirement is per request. Either strip on every request head or document the first-request bound; hostname_proxy_strips_h2c_upgrade tests one request per connection.
  • Vocabulary: the proxy gates on external ports, the relay on internal. Where they differ, lease:internal direct is admitted and name:internal proxied is refused. Stricter, not "exactly", and the property test cannot see it because its ingress oracle is route.upstream itself and gate.admits_direct_tcp runs only on Forward; assert "gate admits implies proxy admits" too.
  • Attribution trusts the TCP peer; a stopped sibling's lease is impersonable until forget_own_address runs at session end. Note as a NET-084 dependency.
  • Tier: NET-069/070 cite the T18 Kani harness, which covers the egress verdict this PR reuses, but nothing proves the ingress-port half. Spec-level note.

NIT: register_hostname takes the switch mutex to read a constant subnet (DEFAULT_SUBNET avoids the contention); the ingress refusal logs caller_lease:dst_port under remote_addr where the relay logs source addr:src_port; the preface-close warn names no peer or host.

Verified: preface close is a zero-byte TCP close with HTTP/1.1 unaffected; h2c stripped with websocket passthrough and mixed-offer cases proven on the wire; head bounded at 8 KiB with a 30 s timeout and no panicking slice; CONNECT applies the verdict at connect; duplicate Host takes the first and replays the head to that socket, no extra reach; refusal log line carries direction, remote, proto, port, rule, host, session, caller, status.

`declared_request_ports` read an absent ingress declaration as `None`,
the value a route carries only for a host-address box, whose direct
connections no surface gates. On a native host that made the box's
published-loopback route ungated, so a proxied request to any port was
dialed at `127.0.0.1:<port>` while the same request to the same box on
a VM host was refused — the parity NET-071 binds, broken on one host
form. `sessions::validate_policy` accepts an `own_ip` record with no
ingress, and the own-IP default-block posture is what the relay's gate
gives it, so that is what the proxy must give it too.

The set is now a plain set: an own-address box is always gated and a
declaration of none is the empty one, so `register_own_ip` and
`own_route` take `BTreeSet<u16>` and the compiler holds every future
call site to it. The NET-071 property now generates the absent
declaration too (and derives the applied map the attach path reports
from the declaration, so a box with no section reports an empty one),
and a regression test pins both registry paths on both host forms to
the deny-all verdict.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Comment thread crates/minimald/src/net/switch.rs Resolved
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 1 of 10 on the runtime's review findings, pushed as 544e332a2d50.

line exit tail
cargo nextest run -p minimald proxy_undeclared_port_refused_like_direct 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-263c... Compiling args v0.0.1 (/home/runner/.local/state/minimal/sessions/b6917/tree/crates/args) Compiling ot v0.0.1 (/home/runner/.local/state/minimal/sessions/b6917/tree/crates/ot) C
cargo nextest run -p minimald proxy_caller_egress_denied 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-79f5... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/ea28d/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/ea28d/tree/crate
cargo nextest run -p minimald proxy_parity_across_network_modes 0 Applying loadouts: default Running task runtime-implement-test-2 in session task-runtime-implement-test-2-e5a3... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/8162c/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/8162c/tree/crate
cargo nextest run -p minimald hostname_proxy_closes_h2_preface 0 Applying loadouts: default Running task runtime-implement-test-3 in session task-runtime-implement-test-3-5003... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/e261b/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/e261b/tree/crate
cargo nextest run -p minimald hostname_proxy_strips_h2c_upgrade 0 Applying loadouts: default Running task runtime-implement-test-4 in session task-runtime-implement-test-4-5265... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/8cc06/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/8cc06/tree/crate

Verify min task run agent-verify passed.

Review threads the coder judged:

  • 👍 valid — crates/minimald/src/net/switch.rs: declared_request_ports now returns the empty set — deny-all — for an own-address box with no ingress instead of the None that means a host-address box's ungated route; register_own_ip and own_route take a plain BTreeSet, and the NET-071 property plus a new regression test now cover the absent declar

A request through the proxy to a port the target box did not declare, or from a caller whose rules deny the target, is refused with the same refusal a direct connection gets on host-address and own-address targets alike — including an own-address box that declares no ingress at all, on a native host as well as a VM host, where the proxy previously dialed the port — and an HTTP/2 preface is closed at once.

Notes from the agent: Round 1: the one review finding (declared_request_ports collapsing an absent ingress declaration to None, the host-address 'ungated' value, so an OwnIp box with no ingress was forwarded on a native host while a VM host refused it) was valid and is fixed: declared_request_ports returns a plain BTreeSet that is empty for an absent declaration, register_own_ip/own_route take a plain set so the compiler holds future call sites to 'an own-address box is always gated', and the Route/own_route/upstream doc comments now tie None to host-address only. The NET-071 property now generates the absent declaration for own-address modes and derives the applied map from the declaration (the first failing case it found was the test's own model of that map, now corrected to match the attach path's ingress.map_or_else derivation). One deterministic regression test, own_ip_target_with_no_ingress_is_deny_all_on_every_host_form, pins both registry paths on both host forms. server.rs needed no change this round. proptest's failure-seed file created during iteration was removed; no proptest-regressions files are tracked in this repo, so nothing out of scope was left behind.

@norrietaylor

Copy link
Copy Markdown
Member

/revise

Round 1 closed the no-ingress own-address gap (verdict valid on 544e332a, but the thread is still open: resolve it). One minimal-review thread on 544e332a remains and it checks out against sessions::core::egress::summarize, which reads the destination port at ip[ihl + 2..ihl + 4] (ip[22..24] for IHL 5):

  1. crates/minimald/src/net/switch.rs tcp_frame_summary writes dst_port at ip[SYNTH_IPV4_HDR..SYNTH_IPV4_HDR + 2] = ip[20..22], the TCP source-port slot, so every summary it builds carries dst_port == 0. Write it at ip[SYNTH_IPV4_HDR + 2..SYNTH_IPV4_HDR + 4].
  2. The test helper tcp_frame_to in crates/minimald/src/net/proxy.rs (around line 1831) has the same ip[20..22] mis-offset, so the NET-071 parity property compares two summaries that both lost the port. Fix it to ip[22..24].
  3. Add one unit assertion that tcp_frame_summary(dst, p).dst_port == p for a non-zero p, so the offset cannot drift again, and keep proxy_parity_across_network_modes green.

Resolve both threads when done. Nothing else is open; CI is green on 544e332a.

`tcp_frame_summary` wrote the destination port at `ip[20..22]`, the L4
source-port slot, while `egress::summarize` reads the destination port
from `ip[ihl + 2..ihl + 4]` (`ip[22..24]` for IHL 5), so every summary
it built carried `dst_port == 0` and the proxy's egress verdict never
saw the port the request named. Latent today — the verdict consults the
port only for the UDP resolver carve-out, which a TCP frame cannot
match — but a port-shaped rule or carve-out the verdict ever grows
would silently ignore the connection's port, and the doc comment's
claim that the port sits "at the offsets summarize extracts them from"
was not true.

The mirror-image helper `tcp_frame_to` in the proxy tests had the same
mis-offset, so `proxy_parity_across_network_modes` compared two
equally-wrong summaries and passed despite it: the NET-071 parity
claim was not exercised at the port level. Both now write the port
where `summarize` reads it, and a new unit assertion holds
`tcp_frame_summary(dst, p).destination_port() == p` for non-zero `p`
so the offset cannot drift again.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 2 findings, 2 inline.

Comment thread crates/minimald/src/net/proxy.rs Resolved
Comment thread crates/minimald/src/net/proxy.rs Resolved
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 2 of 10 on a /revise note, pushed as c46dd6410946.

line exit tail
cargo nextest run -p minimald proxy_undeclared_port_refused_like_direct 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-8a81... Compiling ot v0.0.1 (/home/runner/.local/state/minimal/sessions/1384c/tree/crates/ot) Compiling args v0.0.1 (/home/runner/.local/state/minimal/sessions/1384c/tree/crates/args) C
cargo nextest run -p minimald proxy_caller_egress_denied 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-cc67... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/70ac7/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/70ac7/tree/crate
cargo nextest run -p minimald proxy_parity_across_network_modes 0 Applying loadouts: default Running task runtime-implement-test-2 in session task-runtime-implement-test-2-9a5b... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/2c320/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/2c320/tree/crate
cargo nextest run -p minimald hostname_proxy_closes_h2_preface 0 Applying loadouts: default Running task runtime-implement-test-3 in session task-runtime-implement-test-3-2e27... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/977b2/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/977b2/tree/crate
cargo nextest run -p minimald hostname_proxy_strips_h2c_upgrade 0 Applying loadouts: default Running task runtime-implement-test-4 in session task-runtime-implement-test-4-d403... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/83f86/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/83f86/tree/crate

Verify min task run agent-verify passed.

Review threads the coder judged:

  • 👎 invalid — PRRT_kwDOPdfcxM6mN4yb: Does not hold at this branch head: already fixed by 4be614e (in 544e332) — declared_request_ports returns the empty deny-all set for an own-address box with absent ingress instead of the None that means a host-address box, register_own_ip/own_route take a plain BTreeSet (Route::loopback(_, Some(em (not posted on the thread: not an open thread on the pull request)
  • 👍 valid — PRRT_kwDOPdfcxM6mOIpO: Fixed in c46dd64: tcp_frame_summary writes the port at ip[SYNTH_IPV4_HDR + 2..SYNTH_IPV4_HDR + 4] (ip[22..24], where summarize reads it), the mirror-image helper tcp_frame_to in proxy.rs writes ip[22..24] too, and the new unit assertion tcp_frame_summary_names_the_destination_port holds destination (not posted on the thread: not an open thread on the pull request)

A proxied request to a port the target did not declare, or from a caller whose egress rules deny the target, still gets exactly the refusal a direct connection gets on host-address and own-address targets alike — and this round the synthesized frame behind that verdict names the connection's destination port at the offset egress::summarize reads it from, so the NET-071 parity is now actually exercised at the port level (asserted directly, and compared against a test frame that carries the port too), with an HTTP/2 preface still closed at once.

Notes from the agent: Both findings were judged against the branch head. Thread 2 (the dst_port mis-offset) held and is fixed in c46dd64: the production offset in switch.rs, the mirror-image test helper tcp_frame_to in proxy.rs, and a new unit assertion that fails on the old offset — so proxy_parity_across_network_modes now compares two frames that both name the port instead of two that both lost it. Thread 1 (no-ingress own-address) is already fixed on this branch by 4be614e, so it needed no change this round; see its verdict note for the two tests that pin it. Beyond the test: lines I ran cargo clippy -p minimald --all-targets (clean, no warnings) and cargo fmt -p minimald -- --check (clean), the two CI gates the touched crate's diff could trip. Nothing outside the layers was touched, and no thread was resolved — that stays with the reviewer.

…xied-requests-exactly-as-direct-connec

Resolve it by keeping the shared derivation the branch introduced and
the lease main's NET-084 added to it: compiled_egress takes the box's
lease, the registry's caller facts hold the declaration uncompiled and
build the rules at the join — with the lease that names the caller — and
the synthesized frame a proxied request is put to carries the caller's
own lease as its source, so the verdict's source check reads it as the
box's own frame and the declared dimensions decide, on both surfaces.
The diff-scoped strict clippy gate arrived with this merge, so the
branch's own lines meet it for the first time and the PR lanes would
have gone red on them.

- The provably-bounded slices and indexes (constant offsets into the
  fixed-size synthesized frame, cuts at an index or length a search
  already bounded) carry #[expect] with the reason the bound holds.
- The parity property's match named the host-address arm it had already
  excluded with unreachable!; it is now the meaningful None it always
  was — a host-address target has no gate to compare with — so the
  excluded case is stated where it is decided instead of asserted away.
- The recording backend's discarded answer is named as intentional.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Comment thread crates/minimald/src/net/proxy.rs Resolved
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 3 of 10 on a conflict with the base branch, pushed as 132364469aab.

Resolved conflicts in: crates/minimald/src/net/switch.rs

line exit tail
cargo nextest run -p minimald proxy_undeclared_port_refused_like_direct 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-56d5... Compiling ot v0.0.1 (/home/runner/.local/state/minimal/sessions/b6a08/tree/crates/ot) Compiling args v0.0.1 (/home/runner/.local/state/minimal/sessions/b6a08/tree/crates/args) C
cargo nextest run -p minimald proxy_caller_egress_denied 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-53f8... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/a5638/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/a5638/tree/crate
cargo nextest run -p minimald proxy_parity_across_network_modes 0 Applying loadouts: default Running task runtime-implement-test-2 in session task-runtime-implement-test-2-0c3f... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/27509/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/27509/tree/crate
cargo nextest run -p minimald hostname_proxy_closes_h2_preface 0 Applying loadouts: default Running task runtime-implement-test-3 in session task-runtime-implement-test-3-434d... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/04ddf/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/04ddf/tree/crate
cargo nextest run -p minimald hostname_proxy_strips_h2c_upgrade 0 Applying loadouts: default Running task runtime-implement-test-4 in session task-runtime-implement-test-4-fad0... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/48545/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/48545/tree/crate

Verify min task run agent-verify passed.

A request through the hostname proxy to a port the target box did not declare, or from a caller whose egress rules deny the target, is refused with the same rule name, direction and reason a direct connection's drop carries — on host-address and own-address targets alike, before the proxy dials anything — and an HTTP/2 preface is closed at once, which the branch's five verify lines hold green on top of main's lease-checked egress verdict.

Notes from the agent: Round 3 was a conflict round: main's NET-084 (T40, reject relay frames whose source is not the box's lease) changed EgressRules::from_policy to take the lease and made egress::verdict check the frame's source against it first. The conflict marker in SessionGate::for_session was the visible tip of that; the rest of the resolution was required to keep the branch's parity true under the new verdict. How it landed, in the five layer files: (1) compiled_egress takes the lease as a third parameter and for_session passes it, so the branch's shared derivation and main's lease dimension are one compile path; (2) the hostname registry now records a caller as its uncompiled declaration (CallerFacts holds the SessionPolicy and the SwitchSubnet, not prebuilt rules) and builds the EgressRules at the join in caller_at, with the lease that names the caller — the lease arrives from the attach path (provider.rs → report_own_address) after the session actor registers the caller at spawn, so it cannot be compiled at registration; the join is the only place both facts exist, and compiling there means the rules and the lease can never disagree; (3) direct_connection_verdict synthesizes its frame with the rules' own lease as the IPv4 source, so the verdict's new lease check reads the frame as the box's own and the declared dimensions decide — without this every proxied request from a box would have been refused as a foreign source, which is also why the deferred compile matters: session.rs records the caller before the …[truncated]

@norrietaylor norrietaylor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gates met: T34's five test lines exit 0 on 1323644 and the agent-verify gate passed; the five files touched are the task's layers; CI green on the head; minimal-review concluded (neutral) and CodeRabbit approved on the head; the port-offset fix and its assertion (tcp_frame_summary_names_the_destination_port) are on the branch; the remaining caller-identity thread is T43's work and is resolved with that pointer; no open threads, not a draft, no needs-human.

@norrietaylor
norrietaylor merged commit 7051b70 into main Sep 26, 2026
33 checks passed
@norrietaylor
norrietaylor deleted the agent/1639-refuse-proxied-requests-exactly-as-direct-connec branch September 26, 2026 16:14
norrietaylor added a commit that referenced this pull request Sep 28, 2026
`just fix` is the innermost loop, and the gate failed there. Three agent
rounds on the NET walk then rewrote lines their task never named to clear it
(#1737 round 3, #1730 round 5, #1727 round 4), two of them in conflict rounds
whose only directive was the merge. A command that fails in the edit loop
outranks a sentence in AGENTS.md telling you to leave the hit alone, so the
sentence this branch added needs the recipe to agree with it.

CLIPPY_STRICT_REPORT_ONLY=1 prints the diagnostics and exits 0. `fix` sets it;
`clippy-strict` and `ci` do not, so "before opening a PR" stays the round that
owns the judgement. Only hits are demoted — a build or tooling failure still
exits non-zero, which is what the cargo check above the filter is for.
norrietaylor added a commit that referenced this pull request Sep 28, 2026
…l ref

The base was `git merge-base main HEAD`, and a branch that merges
`origin/main` leaves the local ref where it was — agent sandboxes and
worktrees never check main out at all. The merge-base against a ref that
stale predates the main commits the branch merged in, so every line of those
commits reads as a line this branch changed, and the gate reports
diagnostics on other people's code under a heading saying they are yours.
Three agent rounds fixing lines their task never named is what that looks
like from the outside (#1737, #1730, #1727).

Measured on this branch: a local `main` ten commits behind turned a change
touching no Rust at all into 14 changed Rust files across `minimald`,
`sessions` and `switch`. With `origin/main` it is nought, and the gate says
"no Rust changes" as it should.

The remote ref is the safe one by construction: it cannot be behind anything
the branch merged, because merging it required fetching it, and a fetch only
moves it forward. Stale means the base is older than the newest main, never
older than this branch's first commit. The local ref stays as the fallback
for a clone without a remote.
norrietaylor added a commit that referenced this pull request Sep 28, 2026
…d take it out of just fix (#1749)

* docs(agents): say the strict clippy gate is local and bounded by the directive

Three agent rounds since #1724 landed rewrote lines beyond their task to
satisfy `just clippy-strict`, two of them in conflict rounds whose only
directive was the merge, and two coders wrote that the PR lanes would have
gone red otherwise. They would not: the gate is local, no CI lane runs it.
Say so where AGENTS.md names the gate, and say what a revise or conflict
round does with its hits: report them in `notes`, not fix them.

* chore(lint): report the strict gate in just fix, enforce it in just ci

`just fix` is the innermost loop, and the gate failed there. Three agent
rounds on the NET walk then rewrote lines their task never named to clear it
(#1737 round 3, #1730 round 5, #1727 round 4), two of them in conflict rounds
whose only directive was the merge. A command that fails in the edit loop
outranks a sentence in AGENTS.md telling you to leave the hit alone, so the
sentence this branch added needs the recipe to agree with it.

CLIPPY_STRICT_REPORT_ONLY=1 prints the diagnostics and exits 0. `fix` sets it;
`clippy-strict` and `ci` do not, so "before opening a PR" stays the round that
owns the judgement. Only hits are demoted — a build or tooling failure still
exits non-zero, which is what the cargo check above the filter is for.

* fix(lint): demote only the filter's hits, and never inherit report-only

Two false-success paths in the report-only mode added a commit ago, both of
them the thing this gate exists to avoid: exiting 0 without having checked.

The filter's exit was read as "hits" whatever it was, so no python3 on PATH
or a crash inside it made `just fix` pass having reported nothing. It now
exits a distinct 2 for hits and only that is demoted; 1 from an unhandled
exception, 127 from a missing interpreter, and the cargo failure above the
filter all still leave non-zero.

CLIPPY_STRICT_REPORT_ONLY was read from the ambient environment, so one
export in a shell profile would have turned the gate off in `just
clippy-strict` and therefore in `just ci`, silently. The enforcing recipe
clears it.

* fix(lint): take the strict gate's base from origin/main, not the local ref

The base was `git merge-base main HEAD`, and a branch that merges
`origin/main` leaves the local ref where it was — agent sandboxes and
worktrees never check main out at all. The merge-base against a ref that
stale predates the main commits the branch merged in, so every line of those
commits reads as a line this branch changed, and the gate reports
diagnostics on other people's code under a heading saying they are yours.
Three agent rounds fixing lines their task never named is what that looks
like from the outside (#1737, #1730, #1727).

Measured on this branch: a local `main` ten commits behind turned a change
touching no Rust at all into 14 changed Rust files across `minimald`,
`sessions` and `switch`. With `origin/main` it is nought, and the gate says
"no Rust changes" as it should.

The remote ref is the safe one by construction: it cannot be behind anything
the branch merged, because merging it required fetching it, and a fetch only
moves it forward. Stale means the base is older than the newest main, never
older than this branch's first commit. The local ref stays as the fallback
for a clone without a remote.

* fix(lint): report-only never fails, whatever stopped the gate

`just fix` is the autofix loop: safe to run any number of times and never
stopping on the strict gate. Report-only demoted hits but still exited
101 on a build failure and 127 with no python3, so the loop failed on the
gate it was told only to report. Under report-only every failure is now
printed with its exit code and demoted; enforcing (`just ci`) keeps every
one fatal, so a gate that did not run still cannot pass there.

Driven through cargo and python3 shims: hit 2/0, cargo 101/0, no python3
127/0 (enforcing/report-only), and report-only twice gives the same
output.

* chore(lint): take the strict gate out of just fix

`just fix` is the edit loop, and everything it prints is something to
fix, so a strict hit printed beside fmt and clippy --fix reads as work
whatever a doc sentence says. Report-only kept the hits in that loop and
only removed the failure. Remove the gate from the recipe instead: it
runs in `just clippy-strict` and `just ci`, the round that owns the
judgement, and nowhere else. With no caller, the report-only mode and
the recipe that cleared it go too; the script's exit codes are 0 clean,
2 hits, anything else a failure to run, none read as clean.

AGENTS.md's tight-loop bullet says the loop prints only what to fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T34 — Refuse proxied requests exactly as direct connections, and close HTTP/2 at the proxy

1 participant