x/text/language: count '_' alongside '-' in ParseAcceptLanguage guard#66
x/text/language: count '_' alongside '-' in ParseAcceptLanguage guard#66tonghuaroot wants to merge 1 commit into
Conversation
The BCP 47 scanner aliases '_' to '-' in scanner.init (internal/language/parse.go), so an attacker can replace every '-' with '_' to bypass the 1000-dash guard added in CL 442235 (the CVE-2022-32149 fix) and re-trigger the O(N^2) gobble path on attacker-controlled Accept-Language input. Count both separators in the guard. Fixes golang/go#79684
|
This PR (HEAD: 701c4da) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/text/+/783500. Important tips:
|
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/783500. |
|
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/783500. |
|
Message from Roland Shoemaker: Patch Set 2: Code-Review+2 Please don’t reply on this GitHub thread. Visit golang.org/cl/783500. |
The BCP 47 scanner aliases '' to '-' in scanner.init at
internal/language/parse.go lines 104-111, so a payload built
with '' as the separator bypasses the 1000-dash guard at
language/parse.go:169 (the CVE-2022-32149 fix landed in CL
442235) and re-triggers the O(N^2) gobble path on
attacker-controlled Accept-Language input. Count both
separators in the guard.
Reproduction summary:
100k tokens with '_' separator: 1.35 s parse time
Same 100k tokens with '-': 49.9 us (guard fires)
Amplification: ~27,000x
See golang/go#79684 for the full reproducer with go.mod,
main.go, and measurement output.
Test:
TestParseAcceptLanguageUnderscoreGuard in language/parse_test.go
asserts errTagListTooLarge is returned when 1001 '_' separators
are present.
Filed per the upstream invitation from the Go Security Officers:
the original security@golang.org report was determined to be not
a security issue, with an invitation to file as an upstream
change.
Fixes golang/go#79684