Skip to content

Fix ArrayIndexOutOfBoundsException in SearchQueryUtils.getFields() - #51543

Merged
pedroigor merged 2 commits into
keycloak:mainfrom
sguilhen:fix-50228-search-query-escape
Aug 10, 2026
Merged

Fix ArrayIndexOutOfBoundsException in SearchQueryUtils.getFields()#51543
pedroigor merged 2 commits into
keycloak:mainfrom
sguilhen:fix-50228-search-query-escape

Conversation

@sguilhen

@sguilhen sguilhen commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Closes #50228

Pons3006 and others added 2 commits August 7, 2026 11:25
Add bounds checks before accessing chars[i+1] in both field-name and
value parsing loops to prevent ArrayIndexOutOfBoundsException on
malformed search queries with trailing backslashes. Unterminated escape
sequences now throw ModelValidationException with a descriptive message.

Closes keycloak#50228

Signed-off-by: Ponshankar <mail4ponz@gmail.com>
Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
Copilot AI balanced review requested due to automatic review settings August 7, 2026 14:33
@sguilhen
sguilhen requested a review from a team as a code owner August 7, 2026 14:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Prevents malformed search queries with trailing escape characters from causing out-of-bounds access.

Changes:

  • Validates escape sequences before accessing the next character.
  • Adds regression tests for malformed and boundary-case queries.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
SearchQueryUtils.java Rejects unterminated escape sequences safely.
SearchQueryUtilsTest.java Covers malformed and boundary inputs.

@sguilhen
sguilhen requested a review from pedroigor August 7, 2026 14:36
@pedroigor
pedroigor merged commit bc4418d into keycloak:main Aug 10, 2026
92 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SearchQuery.getFields() exceptions

4 participants