Skip to content

fix(memory): validate namespace on memory store and memory import - #3571

Merged
ruvnet merged 2 commits into
ruvnet:mainfrom
drakeo338:claude/3570-fix
Sep 30, 2026
Merged

ruvnet merged 2 commits into
ruvnet:mainfrom
drakeo338:claude/3570-fix

Conversation

@drakeo338

Copy link
Copy Markdown
Contributor

Fixes #3570.

memory store and the memory_import tool accepted a namespace containing ../ and wrote it, while memory export and purge reject that namespace. The entries were left in the database where neither command could read or clean them up. Both paths now run validateIdentifier on the namespace before any write, and import checks every entry first so a bad file persists nothing.

Added tests in memory-store-import-namespace-3570.test.ts; they fail on the base commit and pass with the change.

…vnet#3570)

The CLI store path and memory_import wrote a namespace containing ../,
which memory export and purge reject, leaving entries they cannot read or
clean up. Validate with validateIdentifier before any write; import checks
every entry first so a bad file persists nothing.
…rt, export and purge (ruvnet#3570 follow-up)

Follow-up to drakeo338's fix, closing the remaining gaps found in review:

- Keys: MCP memory_store rejected `../` in keys, but CLI `memory store`
  and `memory_import` accepted it. The MCP rule (DANGEROUS_KEY_PATTERN)
  is now exported through `memoryKeyError()` and used by all three;
  import checks every key up front, so a bad file writes nothing. Keys
  with a plain `/` (`probe/x`) stay legal.
- Purge: `purgeNamespace` used its own NAMESPACE_PATTERN, which rejected
  `:`, so `team:alice` could be stored and exported but never purged. It
  now uses `validateIdentifier`, like the other three operations.
- MCP memory_store: namespaces only faced the key blacklist, so
  `proj/sub` was accepted there but rejected by export and purge. It now
  uses `validateIdentifier` too.

Tests added to memory-store-import-namespace-3570.test.ts: each gap fails
on the prior head and passes here, plus a round-trip table asserting that
CLI store, MCP store and purge accept exactly the namespaces export
accepts.

Co-Authored-By: drakeo338 <[email protected]>
Co-Authored-By: RuFlo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants