Repository navigation
fix(security): escape recall boundaries + harden key expiry/session cleanup - #2006
Open
TINGyu123644 wants to merge 2 commits into
Open
TINGyu123644 wants to merge 2 commits into
TINGyu123644 wants to merge 2 commits into
Conversation
|
Thank you for your contribution! This is an automated acknowledgment. We'll review it internally soon and share all feedback in the discussion below. |
Memory content and persona are persisted values (LLM extraction, panel edits, imports) that get concatenated into XML-delimited prompt sections such as <relevant-memories> and <user-persona>. A stored value containing a matching closing tag could break out of its section and be interpreted as a system-level instruction on a future recall (stored prompt injection / memory poisoning). - Add escapeXmlTags to the openclaw client plugin's sanitize.ts (mirrors the core helper) and apply it to L1 memory content and persona in format.ts. - Apply escapeXmlTags in core auto-recall hook at read time for persona, scene navigation and L1 memory lines, so protection also covers edited/imported values regardless of how they were produced. Adds regression tests for both client and server paths. Signed-off-by: TINGyu123644 <TINGyu123644@users.noreply.github.com>
- user-key: an unparseable expires_at now fails closed (treated as expired) instead of producing a never-expiring credential. Absent value still means no expiry. - session-store: reclaim all expired sessions on create() and enforce a capacity cap, so entries never revisited cannot accumulate indefinitely. Avoids a background timer (which would keep the Node process alive). - codex runner: remove a leftover DEBUG block that dumped the request_user_input tool schema to stdout on every request. Adds regression tests for key expiry and session-store reclamation. Signed-off-by: TINGyu123644 <TINGyu123644@users.noreply.github.com>
TINGyu123644
force-pushed
the
fix/security-and-robustness
branch
from
November 18, 2026 11:42
b1999fa to
d32a629
Compare
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.
Summary
Small, focused hardening patch found during source review. Split into two commits:
1.
fix(security)— escape injected-section boundaries in recall contexts (relates to #2005)Recalled memory content and L3 persona are persisted values (LLM extraction, panel edits, imports) that are concatenated into XML-delimited prompt sections. Without escaping, a stored value containing a matching closing tag can break out of its section and be read as a system-level instruction on a future recall — a stored prompt-injection / memory-poisoning risk.
MemoryCore/openclaw-plugin/src/sanitize.ts: addescapeXmlTags()mirroring the existing core helper.MemoryCore/openclaw-plugin/src/format.ts: escape L1 memory content and persona before injecting them into<relevant-memories>/<user-persona>.MemoryCore/src/core/hooks/auto-recall.ts: escape persona, scene navigation and L1 memory lines at read/injection time, so edited/imported values are covered regardless of how they were produced.2.
fix— key expiry, session reclamation, debug cleanupuser-key.ts: an unparseableexpires_atnow fails closed (treated as expired) instead of yielding a never-expiring credential. Absent value still means "no expiry".session-store.ts: reclaim all expired sessions oncreate()and enforce a capacity cap, so sessions that are never revisited cannot accumulate indefinitely. No background timer is used, so the Node process can still exit normally.codex.ts: remove a leftover DEBUG block that dumped therequest_user_inputtool schema to stdout on every request.Verification
Dependency install was not available in the author's environment, so the pure functions were exercised directly with Node 22's type stripping: 19 assertions on
escapeXmlTags/isUserKeyExpiredand 4 on the session-store algorithm, all passing. Vitest regression tests are included for CI to run in the project's normal setup.Test plan
cd MemoryCore && npm test(vitest) — newsanitize.injection-boundary.test.ts,user-key.test.tscd MemoryCore/openclaw-plugin && npx vitest run tests/format.injection-boundary.test.tscd MemoryPanel && npm test(vitest) — newsession-store-expiry.test.tsNotes
All commits are DCO signed-off. Base branch:
feat/server_team.