Repository navigation
Conversation
cleanGeneratedTitle only trimmed quotes, prefixes and punctuation, so a reasoning model answering the title prompt with its own chain of thought stored the raw <think>…</think> text as the session title (MemTensor#432). reasoningEffort is none, but inherently-reasoning models ignore it, so strip defensively with the existing stripThink helper. When the model produces only thinking, the title stays empty and the session keeps its default title instead of exposing reasoning. Adds unit tests for cleanGeneratedTitle and two WebuiTitleService tests; each fails on the unpatched tree.
…mTensor#468) The Memory service is a machine-local API, but /api/v1/admin/shutdown and /api/v1/admin/reload-config accepted any caller that passed requireAdminWrite — and with no localServiceToken configured the anonymous principal carries scopes ["*"], so the check always passed. A page the user visits can therefore POST /api/v1/admin/shutdown and stop the service: a local denial of service. Admin routes now reject requests that can only come from a browser page on another origin: a non-loopback Origin header, or Sec-Fetch-Site: cross-site (which also catches DNS-rebinding-shaped attempts). The check mirrors the one assertLocalViewerRequest already applies to the Viewer API; loopback Origins (the desktop renderer) stay allowed, and non-browser clients — the desktop main process, the CLI, the backend — send neither header and are unaffected. Adds 6 tests: each browser vector is refused (403), and the headerless and loopback-Origin paths still reach the route and fire the shutdown callback. Fixes MemTensor#468.
insuffer
requested review from
Wang-Daoji,
ZongYue99 and
hijzy
as code owners
September 22, 2026 03:38
Contributor
Author
|
Hi — this is a security fix for #468 (a web page can shut the local Memory service down through an unauthenticated |
This branch has not been deployed
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
Fixes #468 (unauthenticated local denial of service):
POST /api/v1/admin/shutdownis reachable from a web page the user visits, which stops the Memory service.Root cause
/api/v1/admin/shutdownand/api/v1/admin/reload-configguard onrequireAdminWrite(principal). With nolocalServiceTokenconfigured — the default —authenticate()falls through to the anonymous principal, which carriesscopes: ["*"], andrequireAnyScopeshort-circuits on*. So the guard always passes for an anonymous caller. The service listens on127.0.0.1:18960, which does not stop a browser page from reaching it (directly, or via a DNS rebinding that makes the browser treat the loopback address as same-origin).Fix
Admin routes now refuse requests that can only originate from a browser page on another origin:
Originheader, orSec-Fetch-Site: cross-site(catches rebinding-shaped attempts that smuggle no Origin).The check mirrors what
assertLocalViewerRequestalready applies to the Viewer API (Memory/src/server/viewer-api.ts— the newassertNotBrowserCrossOriginlives beside it and reuses its loopback logic). Loopback Origins — the desktop renderer — stay allowed. Non-browser clients (the desktop app's main process, the CLI inruntime-installer.ts, the backend) send neither header and are unaffected.Verification
Windows 11,
Memoryworkspace:Memory/tests/admin-browser-guard.test.ts: cross-originOrigin→ 403;Sec-Fetch-Site: cross-sitewithout Origin → 403; unparseable Origin → 403; headerless request (the desktop/CLI shape) → 200 and the shutdown callback fires; loopback Origin → 200; the sibling admin route guarded the same way.tsc -p tsconfig.json --noEmitclean; existingviewer-api,http-startup,server-entrypoint,server-locksuites pass (26 tests).Scope notes
*scope also feeds Local sensitive logic exposure lead to the user's LLM usage log leakage #462/Local sensitive logic exposure lead to the user LLM memory arbitrary search #463) — worth a follow-up once maintainers decide the default token posture; I did not change the anonymous scope behavior here because the default desktop flow depends on it.