T01 · Skill Instruction Hijacking
- Location
hooks/openclaw/handler.js:46- Finding
Agent Bootstrap and Prompt Hook Instruction Injection
- Content
View full analysis
Vulnerability Details
File Location:
hooks/openclaw/handler.js:46-52
Additional Locations:hooks/openclaw/handler.ts:44-59,scripts/activator.sh:9-18,SKILL.md:411-465
Vulnerability Type: Agent-context instruction injection through lifecycle hooks
Risk Level: MediumVulnerable Code
javascript if (Array.isArray(event.context.bootstrapFiles)) { event.context.bootstrapFiles.push({ path: 'SELF_IMPROVEMENT_REMINDER.md', content: REMINDER_CONTENT, virtual: true, }); }The prompt hook also emits instructions into agent context:
bash <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 self-improvement skill format. If high-value (recurring, broadly applicable): Consider skill extraction. </self-improvement-reminder>Technical Analysis
Once the optional hooks are enabled, Skill-controlled instructions are inserted into the agent context during bootstrap or after each submitted prompt. The bootstrap handler presents the content as a virtual workspace file, while the shell hook emits an XML-like instruction block.
These instructions alter agent behavior beyond the immediate user request by directing the agent to evaluate, record, and potentially promote information after completing tasks. The behavior is documented and opt-in, and no explicit instruction to bypass platform safety controls was found. Nevertheless, it is an instruction-injection mechanism capable of influencing every matching session.
There is also a runtime-source discrepancy. The TypeScript source at
hooks/openclaw/handler.ts:44-49excludes session keys containing:subagent:, but the shipped JavaScript handler does not ...[truncated 1482 chars]- Remediation
View remediation
Remediation Suggestions
- Require an explicit user request or per-session consent before injecting self-improvement instructions.
- Clearly label injected content as optional advisory material that must not override the current user request or higher-priority instructions.
- Require confirmation before the agent writes learning records or modifies persistent instruction files.
- Restrict the hook to narrowly defined events and sessions rather than every prompt.
- Rebuild
handler.jsfrom the reviewed TypeScript source so the sub-agent exclusion is present in the runtime artifact. - Add an automated test that compares TypeScript and JavaScript behavior, including rejection of session keys containing
:subagent:. - Document which handler file OpenClaw executes and avoid shipping divergent source and runtime implementations.
