Fix out-of-bounds read for truncated percent-escape in opaque host - #37203
Open
shaggyinsomniac wants to merge 1 commit into
Open
Fix out-of-bounds read for truncated percent-escape in opaque host#37203shaggyinsomniac wants to merge 1 commit into
shaggyinsomniac wants to merge 1 commit into
Conversation
Member
|
Please sign the DCO. |
The opaque-host percent-escape validation guard reads input.codePointAt(i + 2) after only checking 'input.length() - i < 2', so an input such as 'foo://%4' throws StringIndexOutOfBoundsException instead of reporting a validation error. Fix the bounds guard to require two code points after '%' and check ASCII hex digits rather than ASCII digits, matching the URL spec, where invalid percent-escapes in opaque hosts are validation errors, not failures. Signed-off-by: Sagar Chanchal <Sagarr2112@gmail.com>
shaggyinsomniac
force-pushed
the
whatwg-opaque-host-oob
branch
from
August 27, 2026 13:11
ea72824 to
7f77900
Compare
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.
Fixes #37201
Description
The opaque-host percent-escape validation guard reads
input.codePointAt(i + 2)after only checkinginput.length() - i < 2, so an input such asfoo://%4throwsStringIndexOutOfBoundsExceptioninstead of reporting a validation error.The guard now requires two code points after
%and checks ASCII hex digits rather than ASCII digits, matching the URL spec and the existing code comment: invalid percent-escapes in opaque hosts are validation errors, not failures — the host%4is accepted.Test coverage
parseOpaqueHostTruncatedPercentEscape()— parsesfoo://%4/foo://%4xwith validation enabled, asserts the resulting host and that validation errors were reportedmainwithStringIndexOutOfBoundsExceptionand passes with this change; the full:spring-web:testsuite (3,919 tests) passes