T01 · Skill Instruction Hijacking
- Location
scripts/compact.mjs:177- Finding
Untrusted Conversation Content Is Promoted to a System-Role Message
- Content
View full analysis
{ lines.push(`${i + 1}. ${req}`); }); // 待完成事项 const pending = extractPendingWork(messages); if (pending.length > 0) { lines.push(''); lines.push('### 待完成事项'); pending.forEach(item => { lines.push(`- ${item}`); }); } ``` ```javascript const newMessages = [ { role: 'system', content: `\n${newSummary}\n\n### 最近消息(未压缩)\n---\n
`, timestamp: new Date().toISOString() }, ...toPreserve ]; ``` ### Technical Analysis The compaction process extracts portions of user and assistant messages and inserts them substantially verbatim into `newSummary`. It then stores that summary as a message with the privileged `system` role. No trust-boundary separation, instruction filtering, structured encoding, or explicit untrusted-data delimiters are applied before the extracted conversation text is promoted. An attacker-controlled user message can therefore contain imperative instructions that become embedded in a system-role message following compaction. The `extractRecentUserRequests()` path copies recent user content, while `extractPendingWork()` copies content containing keywords such as `todo`, `next`, or `pending`. These provide direct routes for attacker-controlled instructions to reach the generated system message. ### Attack Path 1. An attacker submits a user message containing malicious instructions. 2. The attacker structures the message as a recent request or includes a pending-work keyword such as `todo`, `next`, or `pending`. 3. The session reaches the configured compaction threshold and `compact()` is invoked. 4. The extraction functions copy the attacker-controlled text into the generated summary. 5. The application stores the generated summary with `role: 'system'`. ...[truncated 687 chars]- Remediation
View remediation
