Skip to content

fix: stop splitting query parameters on semicolons - #797

Closed
Yanhu007 wants to merge 1 commit into
gorilla:mainfrom
Yanhu007:fix/query-semicolon-parser-differential
Closed

fix: stop splitting query parameters on semicolons#797
Yanhu007 wants to merge 1 commit into
gorilla:mainfrom
Yanhu007:fix/query-semicolon-parser-differential

Conversation

@Yanhu007

Copy link
Copy Markdown

Summary

Fixes #781

findFirstQueryKey splits query-parameter pairs on both & and ;. Since Go 1.17, net/url.ParseQuery only splits on &, per the URL Living Standard.

This parser differential can enable:

  • Web cache poisoning via query-parameter cloaking
  • Broken access control when applications use both net/url and mux.Vars for parsing

Change

// Before — splits on both & and ;
if i := bytes.IndexAny(foundKey, "&;"); i >= 0 {

// After — only splits on & (matching Go stdlib and URL Living Standard)
if i := bytes.IndexByte(foundKey, '&'); i >= 0 {

Tests

All existing tests pass (go test ./...), including Test_findFirstQueryKey which validates against url.ParseQuery.

findFirstQueryKey splits query-parameter pairs on both '&' and ';'.
Since Go 1.17, net/url.ParseQuery only splits on '&', per the URL
Living Standard. The mismatch creates a parser differential that can
enable web cache poisoning and broken access control when mux is
used alongside net/url.

Only split on '&' to align with Go's standard library and the URL
Living Standard.

Fixes gorilla#781
@Yanhu007

Copy link
Copy Markdown
Author

Duplicate of #798, closing this one.

@Yanhu007 Yanhu007 closed this Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Semicolon unduly acts as separator for query parameters (thereby creating a parser differential)

1 participant