Skip to content

Expire MITM passthrough after one minute - #306

Merged
BaaRai merged 2 commits into
BaaRai:mainfrom
Protonmatter:protonmatter/mitm-passthrough-ttl
Nov 17, 2026
Merged

BaaRai merged 2 commits into
BaaRai:mainfrom
Protonmatter:protonmatter/mitm-passthrough-ttl

Conversation

@Protonmatter

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • TestPassthroughMarkExpires.
  • TestMaybePassthroughFlagsHostOnce.

A host that cannot be intercepted is tunneled until the mark expires, then interception is tried again.

@BaaRai BaaRai left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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 RequestError says 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 BaaRai left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

@BaaRai
BaaRai merged commit 8ae53f7 into BaaRai:main Nov 17, 2026
5 checks passed
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.

2 participants