Repository navigation
fix(server): stop % and _ in a forget id from acting as LIKE wildcards (#1435) - #1436
Merged
Merged
Conversation
#1435) resolve_id_prefix now escapes %, _ and the escape character, so an id prefix is never a pattern for any caller, and the HTTP forget policy validates the id like MCP (hex digits and '-', 400 otherwise). Before, DELETE /forget?id=%25 matched every memory whose id contains "25" and deleted it when exactly one matched. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This was referenced Oct 12, 2026
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
Two layers, both needed:
Store::resolve_id_prefixbuildsLIKE '<prefix>%'and now escapes%,_and the escape character (ESCAPE '\'), so an id prefix is literal text for every caller (HTTP forget, the CLI contradiction commands, anything else that resolves a short id).ForgetPolicy::HTTP) now usesIdCharset::HexAndDash, the same rule MCP has had since fix: align /import size limit and harden /mcp & id handling #1328. A non-hex id is400 Invalid memory id '<id>' (expected a UUID or hex prefix).Why
Closes #1435.
DELETE /forget?id=%25(the query value is not percent-decoded) matched every memory whose id contains "25" and deleted it when exactly one matched. Any write token could trigger it with a malformed id. Found by the differential run of the typed-request refactor (#1343): the pre-refactor server sometimes returned200 forgottenfor that request and sometimes 404 or "ambiguous", depending on which random UUIDs contained "25". MCP was never affected.Testing
-D warnings,cargo test --workspace, vecq-only core lib tests (721) green;docgenleaves docs/ cleanresolve_id_prefix_treats_wildcards_literally(store level: real prefixes still resolve, shared prefix still ambiguous,%,_,%25,ab_d,a%,\,abcd%match nothing) andcharset_check_applies_to_every_surface_and_wildcards_never_match(HTTP and MCP reject%,_,%25,\, braces andurn:ids; a policy that skips the charset check still cannot wildcard; a real 8-char prefix resolves). The old test that pinned "HTTP lets%resolve" (charset_check_is_mcp_only) was rewrittenuteke-serve, 12 memories: 12 wildcard variants (%25,%,_,__,%2525,a%25,1%,%5F,abc%,2_,\) all return 400 and the memory count stays 12; a valid 12-char prefix returns200 {"forgotten": ...}(12 to 11)urn:uuid:...and{...}ids were404before (they failed the existence check) and are now400; HTTP/CLIforget by tagand every valid hex id or prefix are unchanged. Percent-decoding of query values is a separate, pre-existing mismatch and is not changed here🤖 Generated with Claude Code