fix(promql): prevent panic in trimStringByBytes on invalid UTF-8#17735
Merged
beorn7 merged 1 commit intoprometheus:mainfrom Jan 27, 2026
Merged
fix(promql): prevent panic in trimStringByBytes on invalid UTF-8#17735beorn7 merged 1 commit intoprometheus:mainfrom
beorn7 merged 1 commit intoprometheus:mainfrom
Conversation
3d18641 to
0560eae
Compare
Add bounds check to prevent index out of range panic when trimStringByBytes receives a string containing only UTF-8 continuation bytes (0x80-0xBF). Previously, the loop would decrement size below 0 when no valid rune start byte was found, causing a panic. A malicious query string with only continuation bytes could crash the Prometheus server via the ActiveQueryTracker before the query was parsed or validated. Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
0560eae to
65f8482
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.
Add bounds check to prevent index out of range panic when
trimStringByBytesreceives a string containing only UTF-8 continuation bytes (0x80-0xBF). Previously, the loop would decrement size below 0 when no valid rune start byte was found, causing a panic.A malicious query string with only continuation bytes could crash the Prometheus server via the
ActiveQueryTrackerbefore the query was parsed or validated.Which issue(s) does the PR fix:
Does this PR introduce a user-facing change?