language: limit TextUnmarshaler tag complexity - #68
Open
carrerasdarren-cell wants to merge 1 commit into
Open
Conversation
The BCP 47 parser has inherent quadratic time complexity. Tag.UnmarshalText still passed JSON, XML, and direct text input to it without the limit already used by ParseAcceptLanguage. Reject inputs with more than 1000 total dash and underscore separators before parsing. Count both spellings because the scanner accepts both as tag separators, and add regression coverage for each form. Fixes golang/go#80160.
Contributor
|
This PR (HEAD: 5d4f72b) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/text/+/805000. Important tips:
|
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.
The BCP 47 tag parser has inherent quadratic time complexity.
ParseAcceptLanguage bounds that work, but Tag.UnmarshalText still passes
untrusted JSON, XML, and direct text input to the parser without a
complexity limit.
Reject inputs with more than 1000 total dash and underscore separators
before parsing. Count both spellings because the scanner accepts each as
a tag separator. Add regression coverage for both forms.
A 320 kB reproduction with 32,000 invalid subtags dropped from 71-77 ms
to under 1 ms. The complete x/text test suite, focused race tests, and
go vet pass.
Fixes golang/go#80160.