core/storage: LIKE patterns lack an ESCAPE clause (% and _ in search terms act as wildcards) #14
Labels
No labels
code-review
correctness
dos
performance
security
severity/high
severity/low
severity/medium
tech-debt
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
h-dv/code-index#14
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: Medium · Category: Correctness
Search terms are correctly bound as parameters (no SQL injection), but they are spliced into
LIKEpatterns (format!("{query}%"),%{query}%) with noESCAPEclause:crates/daemon/src/local_index.rs:461,491(search_symbols):753-766(similar_symbol_names):588-591(import branch)A term containing
%or_is silently interpreted as a LIKE wildcard — e.g.get_matchesgetX, and a lone%matches everything (the count path scans the whole symbols table before the limit). Correctness/surprise bug, not memory-safety.Fix
%,_, and the escape char in the term, then appendESCAPE '\'to eachLIKE. A literal-prefix escape still allows theNOCASEindex range scan.Verified good (context)
format!-built statement splices only&'static strfragments; FTS5 query construction is well-defended (fts5_safe_query+ regression suite).Filed from a deep multi-agent code review of the workspace (v0.5.7). Severity/category per the review; file:line refs were accurate at review time — verify against current
master.Fixed in
53dbc19(branchfix/ultradeep-review-findings).Reassessed on current master — still present at all three sites (
search_symbolsname LIKE + the four import alias/module LIKEs,similar_symbol_names' three matchers). Fix adds anescape_likehelper (escapes\,%,_, backslash first) andESCAPE '\'on every LIKE. The prefix%a caller appends is added after escaping so it stays a real wildcard;similar_symbol_namestakes its 3-char head raw then escapes, so a truncation can't leave a dangling\. The exact-match tier uses=on the raw query and is unaffected. The NOCASE prefix-range-scan optimization is preserved (a literal-prefix escape still allows the index range).Tests:
like_escape_tests::underscore_in_query_is_literal_not_wildcard(get_matchesget_user, notgetXuser) andpercent_in_query_is_literal_not_match_all(%matches nothing literal, not every row). Full daemon suite green (195).