T01 · Skill Instruction Hijacking
Error
- Location
- hooks/openclaw/handler.js:8
- Finding
- Agent Bootstrap and Per-Prompt Instruction Injection<![CDATA[ ## Vulnerability Details **File Location**: `hooks/openclaw/handler.js:8-24, 28-51`; `scripts/activator.sh:8-19`; `SKILL.md:489-536` **Vulnerability Type**: T01: Skill Instruction Hijacking **Risk Level**: High ### Vulnerable Code ```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 per-prompt hook also emits instructions explicitly intended to become system context: ```bash # Output reminder as system context 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? - E ...[truncated 2324 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not insert skill-controlled behavioral instructions into bootstrap or system-equivalent context. 2. Emit a clearly identified, non-authoritative notification that cannot be confused with system instructions. 3. Run learning evaluation only after explicit invocation by the user rather than after every prompt or bootstrap. 4. Require separate, explicit consent before writing a learning, creating a skill, or modifying an agent-context file. 5. Display the destination, proposed content, and exact diff before any write. 6. Ensure hook output is treated as untrusted tool output rather than privileged instructions. 7. Scope hook activation to specific projects and provide a visible method to inspect and disable it. 8. Add tests confirming that hook content cannot override the current task, user instructions, or platform safety constraints. ]]>
