fix(state): guard hex2bin against invalid hex strings in malformed query parameters#8250
Closed
wietsewarendorff wants to merge 1 commit into
Closed
fix(state): guard hex2bin against invalid hex strings in malformed query parameters#8250wietsewarendorff wants to merge 1 commit into
wietsewarendorff wants to merge 1 commit into
Conversation
3 tasks
Member
|
Hi @wietsewarendorff — thanks for spotting and reporting this! I've opened #8255 with a slightly different shape (single regex pre-check + extra test for the even-length non-hex branch). You're credited via |
soyuka
added a commit
to soyuka/core
that referenced
this pull request
Jun 5, 2026
When a query string contains unclosed brackets with multibyte or non-hex bytes (e.g. `?y%5B%C2%9D=`), parse_str() mangles the hex-encoded key into a value hex2bin() cannot decode, triggering an E_WARNING that Symfony's debug error handler converts into a 500. Pre-check the key shape and pass mangled keys through verbatim. Closes api-platform#8250 Co-authored-by: Wietse Warendorff <313525+wietsewarendorff@users.noreply.github.com>
Contributor
Author
soyuka
added a commit
that referenced
this pull request
Jun 5, 2026
Co-authored-by: Wietse Warendorff <313525+wietsewarendorff@users.noreply.github.com> Closes #8250
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.
Summary
When a query string contains unclosed brackets with multibyte characters (e.g., ?y%5B=), parse_str() mangles the parameter name into a non-hex string. The subsequent hex2bin() call then fails with "Hexadecimal input string must have an even length", crashing the request.
Change
This fix validates keys are valid hex (even length, only 0-9a-f) before decoding. Mangled keys from malformed input are preserved as-is, preventing the crash while maintaining all valid parameter handling.
Tests
/src/State/Tests/RequestParser: included a new entry in the dataprovider to assert fix, green