Repository navigation
feat(traffic): pace Bash requests at the capture proxy - #234
Merged
Merged
Conversation
With traffic capture on, the Bash proxy URL carries a marker userinfo. The recording proxy drops Proxy-Authorization from every request before it is forwarded or recorded; when the value is the marker it marks the client connection, and every later request on it, including those inside its CONNECT tunnel, waits for the per-host token and jitter of the current noise profile (egress.Wait) and is counted, with a bounded wait. WebFetch, the http custom tools and enrich keep the unmarked URL, which egress already paces, so nothing is paced twice. Off paces nothing. Best effort: only clients that honour the proxy are covered, with capture on.
The low-and-slow block said that commands launched through Bash are not paced. With traffic capture on, Bash commands that use the capture proxy are now paced by rate and jitter; raw scanners and commands that bypass the proxy are not, so the rate flags remain the brake.
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.
Summary
Phase 3b: with traffic capture on, the recording proxy paces the requests that Bash commands send through it, by the current noise profile. A request is never paced twice, the marker never reaches a target, and recording keeps working. Capture off is out of scope.
Checkpoint (run before the feature)
The design relies on three properties of go-mitmproxy v1.9.2. A test with a real
traffic.Openproxy and a curl-like client (proxy URL with userinfo, CA trusted) confirmed all three before any feature code was written:Proxy-Authorization, is visible inRequestheaderson the CONNECT and on a plain-HTTP GET.ClientConn.Id.Proxy-Authorization. WithHeader.DelinRequestheaders, no target received it. Inner TLS requests never carry it.Design
proxyEnvputs the userinfoartex-pace:artex-pace(egress.MarkProxyURL) in the Bash proxy URL, only when a MITM CA is present (capture on). The global proxy of the capture-off path is unchanged. WebFetch, the http custom tools and enrich keep the plain URL.traffic/pace.go), inRequestheaders:Proxy-Authorizationfrom every request before anything is forwarded or recorded; the recording proxy takes no credentials;egress.IsPaceMarker), it marks theClientConn.Id;ClientDisconnectedremoves the mark.egress.Wait):Limitations (also in the README and on the card)
--noproxy, an unset variable) is not paced.Tests
traffic/pace_test.go, on a real proxy with curl-like clients:Proxy-Authorization;Proxy-Authorization;egress/pace_test.go:MarkProxyURL,IsPaceMarker,Wait(off no-op, pacing with no slot taken, a bounded wait that still counts, the packageWaitfollowing the current profile).agent/proxyenv_test.go: the marker is present on all six proxy variables only when the CA is present; the capture-off global proxy is passed unchanged.Verification
gofmt -lon the changed Go files: clean.go build ./...andgo vet ./...: ok.go test -count=1 -p 1 ./egress ./traffic ./agent ./server ./dbon a fresh throwaway database: egress 3.127s, traffic 7.651s, agent 5.656s, server 56.220s, db 29.220s, all ok.go test -count=1 -race -p 1 ./egress ./traffic ./agent ./server: egress 4.322s, traffic 92.826s, agent 8.840s, server 67.295s, all ok, 0 DATA RACE.npm ciok,npx tsc --noEmitok,npm run build:staticok.