Fix normalizeURI bypass for binary $request#17
Merged
Conversation
- Return invalidMarker when $request has no spaces — previously the SplitN early-return handed the raw blob back to the caller, skipping every normalizePath guard (length cap, utf8 check, control-byte and \x escape checks) and letting binary land in the uri label - This surfaced in prod after 0.1.2: gatesrv kept logging label_value_too_long for topsrv_nginx_4xx_requests_total on riderhelp with samples like "\x06\x00\x00\x003_xgDcA\x00..." even though the agent reported version=0.1.2; the giveaway was no "/:invalid" bucket ever appearing in VM for that instance - Add regression cases (the riderhelp TLS-handshake sample, empty string, single token) to TestNormalizeURI so the early-return cannot regress unnoticed
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
normalizeURInow returnsinvalidMarkerwhen$requesthas no spaces; previously theSplitNearly-return handed the raw blob back to the caller, skipping everynormalizePathguard (length cap, utf8 check, control-byte and\x-escape checks) and letting binary land in theurilabel.label_value_too_longfortopsrv_nginx_4xx_requests_totalonriderhelpeven withversion="0.1.2". Samples were TLS-handshake bytes like\x06\x00\x00\x003_xgDcA\x00...and no/:invalidbucket ever appeared in VM — the giveaway thatnormalizePathwas never being reached.Test plan
GOEXPERIMENT=jsonv2 go test ./internal/topsrv/nginx/— passes, including new regression cases (the prod TLS-handshake sample, empty string, single token).v0.1.3, watch goreleaser publish.riderhelp:systemctl restart topsrvafter auto-update picks up 0.1.3, confirmgatesrv_push_validation_failed_total{project="vmkteam",reason="label_value_too_long"}stops climbing and/:invalidbucket starts populating intopsrv_nginx_4xx_requests_total.