T01 · Skill Instruction Hijacking
Error
- Location
- hooks/openclaw/handler.js:39
- Finding
- Automatic Injection of Behavioral Instructions into Agent Bootstrap Context## Vulnerability Details **File Location**: `hooks/openclaw/handler.js:39-45` **Additional Locations**: `hooks/openclaw/handler.ts:44-57`, `scripts/activator.sh:8-19`, `SKILL.md:475-489` **Vulnerability Type**: Automatic prompt and bootstrap-context modification **Risk Level**: High ### Vulnerable Code ```javascript // 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 associated prompt-submit hook emits additional agent instructions as 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? - 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> EOF ``` ### Technical Analysis When the documented hooks are enabled, the runtime handler automatically appends a virtual file containing behavioral instructions to `event.context.bootstrapFiles`. This places Skill-controlled content into the agent's bootstrap context without requiring the Skill to be explicitly invoked during each affected session. There is also a material discrepancy between the TypeScript source and the distributed CommonJS runtime. The TypeScript handler contains the following sub-agent exclusion: ```typescript // Skip sub-agent sessions to avoid bootstrap issues // Sub-agents have sessionKey patterns like "agent:main:subagent:..." const sessionKey = event.s ...[truncated 1857 chars]
- Remediation
- ## Remediation Suggestions 1. Do not insert Skill instructions into bootstrap or system-equivalent context by default. 2. Require an explicit, per-session user action before adding any reminder to agent context. 3. Prefer a clearly labeled user-visible notification rather than a virtual bootstrap file. 4. Rebuild `handler.js` from the reviewed TypeScript source so both implementations enforce identical session restrictions. 5. Add automated tests verifying that main-session and sub-agent behavior match the documented policy. 6. Pin the runtime entry point to a generated artifact and verify source/runtime parity in CI. 7. Clearly display the exact injected content and affected event types before hook activation. 8. Provide a narrow configuration that limits injection to explicitly selected repositories and session types.
