T01 · Skill Instruction Hijacking
Warning
- Location
- hooks/openclaw/handler.js:8
- Finding
- Agent Bootstrap Context Injection Through the OpenClaw Hook<![CDATA[ ## Vulnerability Details **File Location**: `hooks/openclaw/handler.js:8-26, 34-52`; `scripts/activator.sh:9-19` **Vulnerability Type**: Agent instruction injection **Risk Level**: Medium ### Complete Code Snippet ```javascript const REMINDER_CONTENT = ` ## Self-Improvement Reminder After completing tasks, evaluate if any learnings should be captured: **Log when:** - User corrects you → \`.learnings/LEARNINGS.md\` - Command/operation fails → \`.learnings/ERRORS.md\` - User wants missing capability → \`.learnings/FEATURE_REQUESTS.md\` - You discover your knowledge was wrong → \`.learnings/LEARNINGS.md\` - You find a better approach → \`.learnings/LEARNINGS.md\` **Promote when pattern is proven:** - Behavioral patterns → \`SOUL.md\` - Workflow improvements → \`AGENTS.md\` - Tool gotchas → \`TOOLS.md\` Keep entries simple: date, title, what happened, what to do differently. `.trim(); const handler = async (event) => { // Safety checks for event structure if (!event || typeof event !== 'object') { return; } // Only handle agent:bootstrap events if (event.type !== 'agent' || event.action !== 'bootstrap') { return; } // Safety check for context if (!event.context || typeof event.context !== 'object') { return; } // Inject the reminder as a virtual bootstrap file // Check that bootstrapFiles is an array before pushing if (Array.isArray(event.context.bootstrapFiles)) { event.context.bootstrapFiles.push({ path: 'SELF_IMPROVEMENT_REMINDER.md', content: REMINDER_CONTENT, virtual: true, }); } }; ``` The prompt-submit hook also emits instructions into agent context: ```bash cat << 'EOF' <self-improvement-reminder> After completing this task, evaluate if extractable knowledge emerged: - Non-obvious solution discovered through investigation? - Workaround for unexpected behavior? - Project-specific pattern learned? - Error required debugging to resolve? If yes: Log to .learnings/ using the se ...[truncated 2127 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace automatic bootstrap injection with an explicitly invoked command or Skill action. 2. Obtain visible user consent before adding instructions to a session that was not started for learning management. 3. Restrict the hook to clearly identified self-improvement workflows rather than every bootstrap or prompt. 4. Keep the TypeScript and JavaScript implementations synchronized, including the sub-agent exclusion. 5. Add an explicit marker stating that the injected content is advisory and cannot override system, developer, or current user instructions. 6. Provide a documented disable or uninstall command and expose the hook’s active status to the user. 7. Add tests confirming that unrelated sessions and sub-agent sessions do not receive the reminder. ]]>
