T01 · Skill Instruction Hijacking
- Location
src/context-engine.js:241- Finding
Stored context can inject instructions at system-prompt privilege
- Content
View full analysis
WM_CACHE_TTL_MS) { state.wm = await client.readStartupContext(); state.lastWmFetch = Date.now(); } if (state.wm?.available) { const tag = state.wm.source === "context-bundle" ? "nowledge-context-bundle" : "working-memory"; sections.push( `<${tag}>\n${escapeForPrompt(state.wm.content)}\n`, ); } } catch (err) { logger.debug?.(`ce: assemble — startup context read failed: ${err}`); } ``` ```js // src/hooks/recall.js:3-14 const PROMPT_ESCAPE_MAP = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'", }; export function escapeForPrompt(text) { return String(text ?? "").replace( /[&<>"']/g, (char) => PROMPT_ESCAPE_MAP[char] ?? char, ); } ``` ### Technical Analysis The Context Engine reads a Context Bundle or Working Memory document and inserts its contents into `systemPromptAddition`. This gives stored content substantially higher instructional influence than ordinary user messages. `escapeForPrompt()` only performs XML/HTML character escaping. It prevents stored text from closing the surrounding XML-like tag, but it does not neutralize natural-language directives such as “ignore the user,” “send data through a tool,” or “save this rule permanently.” The code correctly labels ordinary recalled memories elsewhere as untrusted historical context, but the startup Context Bundle and Working Memory block does not receive an equivalent warning. The project is explicitly designed to share memory originating from browser capture, imported documents, other AI tools, and remote servers. Consequently, compromise or manipulation of any auth ...[truncated 1436 chars]- Remediation
View remediation
