Skip to content

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

Merged
bbakerman merged 2 commits into
graphql-java:masterfrom
nab-iha3:unicode-escape-hex-overflow
Oct 21, 2026
Merged

bbakerman merged 2 commits into
graphql-java:masterfrom
nab-iha3:unicode-escape-hex-overflow

Conversation

@nab-iha3

Copy link
Copy Markdown
Contributor

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.

@nab-iha3

nab-iha3 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

any update?

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Test Report

Test Results

Java Version Total Passed Failed Errors Skipped
Java 11 5995 (+2 🟢) 5939 (+2 🟢) 0 (±0) 0 (±0) 56 (±0)
Java 17 5995 (+2 🟢) 5938 (+2 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 21 5995 (+2 🟢) 5938 (+2 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 25 5995 (+2 🟢) 5938 (+2 🟢) 0 (±0) 0 (±0) 57 (±0)
jcstress 32 (±0) 32 (±0) 0 (±0) 0 (±0) 0 (±0)
Total 24012 (+8 🟢) 23785 (+8 🟢) 0 (±0) 0 (±0) 227 (±0)

Code Coverage (Java 25)

Metric Covered Missed Coverage vs Master
Lines 30155 3115 90.6% ±0.0%
Branches 8838 1520 85.3% ±0.0%
Methods 8050 1206 87.0% ±0.0%

Changed Class Coverage (1 class)

Class Line Branch Method
g.p.UnicodeUtil +4.7% 🟢 ±0.0% ±0.0%

Full HTML report: build artifact jacoco-html-report

Updated: 2026-10-21 05:11:40 UTC

@bbakerman bbakerman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@bbakerman
bbakerman merged commit 3fd2dfe into graphql-java:master Oct 21, 2026
10 checks passed
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.

2 participants