Repository navigation
Expire MITM passthrough after one minute - #306
Conversation
A host that cannot be intercepted is tunneled until the mark expires, then interception is tried again.
BaaRai
left a comment
There was a problem hiding this comment.
Thanks for adding an expiry to passthrough marks, a stale bypass is a real risk.
1. TestReplayPassthroughHostIsNotIntercepted fails on this head.
replay_test.go:206: err = <nil>, want the target's own certificate to be rejected
The test still seeds tr.pass.Store("localhost", struct{}{}) (traffic/replay_test.go:202). The new tunneling treats any value that is not a time.Time as expired and deletes it (traffic/traffic.go:475-478), so the proxy intercepts the host. The same test passes on the merge base 6337341.
Fix: make the test rely on what tunneling() means, not on the map's value type: create the mark the way the code does (an unexpired time.Now().Add(passthroughTTL)) and assert tr.tunneling("localhost") before the replay. Same for TestReplayRecordedHelper (traffic/replay_test.go:252).
2. replayRecorded ignores the expiry. It still uses t.pass.Load (traffic/replay.go:89), so an expired mark is still reported as "not recorded" although the proxy would intercept that host again. Fix: use t.tunneling(hostOnly(host)).
3. Cost of the TTL. For a host whose MITM always fails, the first request after each expiry fails again: one lost request per host per minute, where before it was one per process. Please confirm that trade-off and document it next to passthroughTTL (traffic/traffic.go:466), or add back-off.
4. Messages that are now wrong.
- The log line says "requests still proceed" (traffic/traffic.go:462), but the request that triggered it has failed, and so will the first one after each expiry.
- The comment on
RequestErrorsays flagged hosts are passed through "so future requests to it succeed instead of dying" (traffic/traffic.go:440-443). That is now true for one minute only. Please update both.
…the window costs. Replay was still honoring a stale bypass, and a host whose interception always fails now loses one request per minute instead of one per process.
BaaRai
left a comment
There was a problem hiding this comment.
Thanks, all four points are addressed: the tests seed a real unexpired mark and assert tunneling(), replayRecorded uses tunneling(), the overlapping messages say what actually happens to the triggering request, and the TTL cost is documented next to the constant.
Summary
Test plan
TestPassthroughMarkExpires.TestMaybePassthroughFlagsHostOnce.