Skip to content

handle oversized hex in unicode brace-escapes as syntax error - #4477

Open
nab-iha3 wants to merge 1 commit into
graphql-java:masterfrom
nab-iha3:unicode-escape-hex-overflow
Open

nab-iha3 wants to merge 1 commit into
graphql-java:masterfrom
nab-iha3:unicode-escape-hex-overflow

Conversation

@nab-iha3

Copy link
Copy Markdown

Parsing an untrusted query with an oversized braced unicode escape throws an internal exception instead of a syntax error:

"\uD83D\u{fffffffff}"  -> java.lang.NumberFormatException at UnicodeUtil.java:53
"\u{fffffffff}"        -> graphql.AssertException: There must be a resource bundle key called InvalidUnicode.invalidHexString

the grammar allows { Hex+ } with any number of digits (EscapedUnicode : Hex Hex Hex Hex | '{' Hex+ '}'), so a value that overflows int reaches Integer.parseInt in parseAndWriteUnicode. the leading escape path catches the NumberFormatException but builds the error with InvalidUnicode.invalidHexString, a key that is missing from every Parsing bundle, so it fails with an AssertException; the trailing-surrogate path (line 53) has no catch at all and leaks the raw NumberFormatException. both should be a normal InvalidSyntaxException.

wrap the trailing parse the same way the leading one is wrapped and add the missing message key to the en/de/nl bundles.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant