[GH-ISSUE #1565] [Issue]: Long-Term Memory: any installed package can read and change the whole memory vault through the storage service #1546

Closed
opened 2026-10-23 04:02:53 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Oct 22, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1565

Originally assigned to: @Promansis on GitHub.

Summary

Long-Term Memory registers an Engine service, long-term-memory:storage, that hands out the vault folder path, the whole memory store and the suggestion store. Since Engine 2.5.1 any installed package can look up another package's service, so any package can list, change or delete every memory, including memories limited to one chat, and read or change pending suggestions. The Engine doesn't use this service. Slurp reads one thing through it: a character's own memory, for its flavour brief. Shrink the service to that one read, limited to memories available to the character everywhere.

Affected package

  • Package: long-term-memory 1.4.82
  • Package type: Agent package (server)
  • Area: server-entry.ts (service registration), a new services/storage-read.ts, tests/long-term-memory-runtime.regression.ts, tests/long-term-memory-routes.regression.ts, docs/ARCHITECTURE.md

Expected behavior

Another package can list the memories available to a character everywhere, which is all Slurp asks for. It can't get the vault folder, write or delete memories, see memories limited to a chat or group, imported sources, archived or game-only memories, or touch suggestions.

Actual behavior

runtime.services.get("long-term-memory:storage") returns { root, storage, drafts }: the vault path, every method of the memory store (create, update, permanent delete, a list with any filter) and the suggestion store.

Steps to reproduce

  1. On Engine 2.5.1, install Long-Term Memory 1.4.82 and any package with server code.
  2. In that package's server code, call api.runtime.services.get("long-term-memory:storage").
  3. The object has root, storage and drafts. storage.listNotes({}) lists every memory, including memories limited to one chat, and storage can create, change and delete memories.

Minimal fix

One PR, patch bump. S = packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory.

 activate
-  registerService("long-term-memory:storage", { root, storage, drafts })
+  registerService("long-term-memory:storage", createLtmStorageReadService(storage))
+    storage.listNotes({ type?, characterIds })     # character ids required; any other field is ignored
+      memories available to those characters everywhere   # a character query never matches a chat- or group-limited memory
+      minus imported sources, archived and game-only memories
  • New S/services/storage-read.ts: the filter is checked with zod (type optional, characterIds 1 to 100 ids); only type and characterIds reach the store, so a chat or group id in the filter can't open chat-limited memories. A read without character ids, or with a malformed filter, lists nothing. A malformed file elsewhere in the vault is skipped, as in chat recall.
  • Imported sources are left out: an imported chat summary's source memory is available to the summary's chat and to the destination characters, so a character query would otherwise return the raw summary text. Slurp asks only for character memories, so it is unaffected.
  • S/server-entry.ts registers the read in place of { root, storage, drafts }.
  • The service key and the call Slurp makes keep their shape, so Slurp works unchanged. Its call already passes type: "character" and the character's id and already skips archived memories; the one difference is that a game-only character memory no longer reaches a feed post.
  • The routes regression took the store from the service; it now opens the store on the same folder directly.
  • docs/ARCHITECTURE.md names the new services/ folder and the rule that anything handed to other packages lists only memories available everywhere.
  • CHANGELOG under ## Unreleased: other installed Agents can no longer reach the memory vault itself; the storage service now offers one read, the memories available to a character everywhere, which is what Slurp's flavour brief uses; memories limited to a chat or group, imported sources, archived and game-only memories, suggestions and the vault folder stay private.

Regression proof

tests/long-term-memory-runtime.regression.ts:

  • the registered service has only storage.listNotes;
  • in its own vault, eight memories (available to the character; to a chat and the character; to a chat only; to another character; archived; game-only; an imported chat summary for that chat and character; the character's own character memory) list exactly the first two and the character memory;
  • a type filter, a filter without character ids, an empty character list, and a filter carrying a chat id behave as above.

With the regression change but staging's server-entry.ts, the suite fails at "the storage service must not hand out the vault folder or drafts"; with the fix it passes. Letting sources through, or allowing an empty character list, fails the matching assertion.

Environment

  • Marinara Engine version: 2.5.1 (capability API 1.341; staging 010829b36)
  • Package version: long-term-memory 1.4.82 (upstream/staging a6e2b20ce)
  • Install type: source (code reading and regression tests)
  • OS + version: any
  • Browser or app shell: any

Logs, screenshots, or video

None.

Additional context

The service has been registered since 1.0.0, when only the Engine could look services up. Engine 2.5.1 opened the lookup to packages. Package server code already runs inside the Engine with file access, so this is not a way past a sandbox; it is a ready-made way to change memories that a well-meaning package could use by mistake. This is the groundwork for a recall service other Agents can use, which follows in a separate issue.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 22, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1565 Originally assigned to: @Promansis on GitHub. ## Summary Long-Term Memory registers an Engine service, `long-term-memory:storage`, that hands out the vault folder path, the whole memory store and the suggestion store. Since Engine 2.5.1 any installed package can look up another package's service, so any package can list, change or delete every memory, including memories limited to one chat, and read or change pending suggestions. The Engine doesn't use this service. Slurp reads one thing through it: a character's own memory, for its flavour brief. Shrink the service to that one read, limited to memories available to the character everywhere. ## Affected package - Package: `long-term-memory` 1.4.82 - Package type: Agent package (server) - Area: `server-entry.ts` (service registration), a new `services/storage-read.ts`, `tests/long-term-memory-runtime.regression.ts`, `tests/long-term-memory-routes.regression.ts`, `docs/ARCHITECTURE.md` ## Expected behavior Another package can list the memories available to a character everywhere, which is all Slurp asks for. It can't get the vault folder, write or delete memories, see memories limited to a chat or group, imported sources, archived or game-only memories, or touch suggestions. ## Actual behavior `runtime.services.get("long-term-memory:storage")` returns `{ root, storage, drafts }`: the vault path, every method of the memory store (create, update, permanent delete, a list with any filter) and the suggestion store. ## Steps to reproduce 1. On Engine 2.5.1, install Long-Term Memory 1.4.82 and any package with server code. 2. In that package's server code, call `api.runtime.services.get("long-term-memory:storage")`. 3. The object has `root`, `storage` and `drafts`. `storage.listNotes({})` lists every memory, including memories limited to one chat, and `storage` can create, change and delete memories. ## Minimal fix One PR, patch bump. S = `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory`. ```diff activate - registerService("long-term-memory:storage", { root, storage, drafts }) + registerService("long-term-memory:storage", createLtmStorageReadService(storage)) + storage.listNotes({ type?, characterIds }) # character ids required; any other field is ignored + memories available to those characters everywhere # a character query never matches a chat- or group-limited memory + minus imported sources, archived and game-only memories ``` - New `S/services/storage-read.ts`: the filter is checked with zod (`type` optional, `characterIds` 1 to 100 ids); only `type` and `characterIds` reach the store, so a chat or group id in the filter can't open chat-limited memories. A read without character ids, or with a malformed filter, lists nothing. A malformed file elsewhere in the vault is skipped, as in chat recall. - Imported sources are left out: an imported chat summary's source memory is available to the summary's chat and to the destination characters, so a character query would otherwise return the raw summary text. Slurp asks only for character memories, so it is unaffected. - `S/server-entry.ts` registers the read in place of `{ root, storage, drafts }`. - The service key and the call Slurp makes keep their shape, so Slurp works unchanged. Its call already passes `type: "character"` and the character's id and already skips archived memories; the one difference is that a game-only character memory no longer reaches a feed post. - The routes regression took the store from the service; it now opens the store on the same folder directly. - `docs/ARCHITECTURE.md` names the new `services/` folder and the rule that anything handed to other packages lists only memories available everywhere. - **CHANGELOG under `## Unreleased`**: other installed Agents can no longer reach the memory vault itself; the storage service now offers one read, the memories available to a character everywhere, which is what Slurp's flavour brief uses; memories limited to a chat or group, imported sources, archived and game-only memories, suggestions and the vault folder stay private. ## Regression proof `tests/long-term-memory-runtime.regression.ts`: - the registered service has only `storage.listNotes`; - in its own vault, eight memories (available to the character; to a chat and the character; to a chat only; to another character; archived; game-only; an imported chat summary for that chat and character; the character's own character memory) list exactly the first two and the character memory; - a `type` filter, a filter without character ids, an empty character list, and a filter carrying a chat id behave as above. With the regression change but staging's `server-entry.ts`, the suite fails at "the storage service must not hand out the vault folder or drafts"; with the fix it passes. Letting sources through, or allowing an empty character list, fails the matching assertion. ## Environment - Marinara Engine version: 2.5.1 (capability API 1.341; `staging` 010829b36) - Package version: long-term-memory 1.4.82 (`upstream/staging` a6e2b20ce) - Install type: source (code reading and regression tests) - OS + version: any - Browser or app shell: any ## Logs, screenshots, or video None. ## Additional context The service has been registered since 1.0.0, when only the Engine could look services up. Engine 2.5.1 opened the lookup to packages. Package server code already runs inside the Engine with file access, so this is not a way past a sandbox; it is a ready-made way to change memories that a well-meaning package could use by mistake. This is the groundwork for a recall service other Agents can use, which follows in a separate issue. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-23 04:02:53 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#1546
No description provided.