Repository navigation
egress: a request admitted before a fence trip cannot outlive it - #505
Merged
Merged
Conversation
…utlive DropTunnels DropTunnels closed only connections already tracked, so a CONNECT or SOCKS5 request whose policy check passed just before the trip finished its dial afterwards, got tracked and spliced on a fenced node, and a forwarded plain-HTTP response kept streaming. Each request now takes the proxy's drop scope before its policy check: track refuses a connection whose scope DropTunnels ended, and a forwarded request is cancelled with it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the window left open by the fence egress fix in #501.
A fence trip (
DropTunnels) closed only the connections already tracked. Two kinds of request slipped through on a fenced node:Either way a replicated claim kept a live outside connection after a peer could have adopted it.
The fix gives the proxy a drop scope, a context that
DropTunnelsends and replaces under the connection lock. Each request takes the scope before its policy check:trackrefuses, and closes, a connection whose scope has ended.Intercepted inner requests need nothing new: closing their tracked tunnel cancels them.
Cost: one mutex-guarded read per proxied request or tunnel. A forwarded plain-HTTP request also pays one cancellable context and one
AfterFuncregistration. CONNECT splices are unchanged after tracking.Test: a streaming forward ends at
DropTunnels; a tunnel whose scope predates the drop is refused and closed; a later one is accepted. With the scope checks removed, the test fails ("a forwarded stream outlived DropTunnels"). Gates: sandboxd unit tests,-raceon egress/outbound, golangci-lint 0 issues on linux and darwin, asl 0.