fix: prevent UTF-8 panic in chunker and URL injection in Hermes plugin - #969
Merged
Merged
Conversation
| } | ||
| b'%' if i + 2 < bytes.len() => { | ||
| let hex = &s[i + 1..i + 3]; | ||
| b'%' if i + 3 <= bytes.len() => { |
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
CRITICAL (init.rs): Hermes plugin tool.py did not URL-encode and uid=10000(hermes) gid=10000(hermes) groups=10000(hermes) parameters in GET/DELETE query strings, allowing path/query injection via crafted parameter values. Added urllib.parse.quote() calls. MAJOR (chunker.rs): split_long_text() sliced by byte index without checking UTF-8 char boundaries, causing panics on multi-byte text (emoji, CJK). Added floor_char_boundary() polyfill (MSRV-compatible since str::floor_char_boundary needs Rust 1.91+, we support 1.85+). Also improved url_decode() readability in types.rs: changed condition from 'i + 2 < bytes.len()' to explicit 'i + 3 <= bytes.len()' for clarity (semantically equivalent, but more readable intent). Tests: - test_split_long_text_multibyte_utf8: emoji + CJK splitting - test_floor_char_boundary: boundary detection edge cases - test_url_decode_basic/trailing_percent/utf8: encoding edge cases
ajianaz
force-pushed
the
fix/p0-critical-url-encoding-utf8-panic
branch
from
August 9, 2026 15:11
cda9657 to
df678a4
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.
What
Fix 3 issues found by cora v0.13.0 scan — 1 CRITICAL + 2 MAJOR severity.
Why
init.rs(Hermes plugin)namespaceandidparams not URL-encoded in GET/DELETE query strings — path/query injection via crafted valueschunker.rssplit_long_text()sliced by byte index without UTF-8 boundary check — panic on emoji, CJK, or any multi-byte texttypes.rsurl_decode()used&s[i+1..i+3]string slicing by byte index — panic if indices land inside a multi-byte charChanges
crates/uteke-cli/src/init.rs— URL injection fiximport urllib.parseto embedded Hermes plugin Pythonf"/forget?id={mid}"→f"/forget?id={urllib.parse.quote(mid)}"f"/stats?namespace={namespace}"→f"/stats?namespace={urllib.parse.quote(namespace)}"crates/uteke-core/src/chunker.rs— UTF-8 panic fixfloor_char_boundary()polyfill (MSRV 1.85.0 compatible —str::floor_char_boundaryneeds 1.91+)split_long_text()slice points now clamp to valid char boundaries before indexingtest_split_long_text_multibyte_utf8(emoji + CJK),test_floor_char_boundarycrates/uteke-server/src/types.rs— url_decode hardening&s[i + 1..i + 3]→std::str::from_utf8(&bytes[i + 1..i + 3])— safe byte-level hex parsingi + 2 < bytes.len()→i + 3 <= bytes.len()(equivalent, more explicit intent)test_url_decode_basic,test_url_decode_trailing_percent,test_url_decode_utf8Testing
cargo clippy --workspace --all-targets— 0 warningscargo test --workspace— 470 pass, 0 fail, 26 ignoredcora review— No issues found