T01 · Skill Instruction Hijacking
Error
- Location
- scripts/utils/llm_client.py:166
- Finding
- Untrusted ebook content is passed directly to the privileged main agent<![CDATA[ ## Vulnerability Details **File Location**: `scripts/utils/llm_client.py:166-176`; related prompt construction at `scripts/ai_modules/ad_detector.py:259-263`, `scripts/ai_modules/mojibake_fixer.py:341-343,359-361`, and `scripts/ai_modules/chapter_parser.py:116-118,213-215` **Vulnerability Type**: Indirect prompt injection across a privileged agent boundary **Risk Level**: High ### Vulnerable Code ```python # scripts/utils/llm_client.py result = subprocess.run( [ 'openclaw', 'agent', '--local', '--agent', 'main', '--message', prompt, '--json' ], capture_output=True, text=True, timeout=self.timeout + 30 ) ``` Untrusted text is directly interpolated into prompts: ```python # scripts/ai_modules/ad_detector.py para_list = "\n".join([f"[{i}] {p}" for i, p in enumerate(paragraphs)]) prompt = BATCH_AD_DETECTION_PROMPT.format(paragraphs=para_list) response = self.llm.call(prompt) ``` ```python # scripts/ai_modules/mojibake_fixer.py prompt = MOJIBAKE_FIX_PROMPT.format(text=text) response = self.llm.call(prompt) ``` ```python # scripts/ai_modules/chapter_parser.py prompt = CHAPTER_PARSE_PROMPT.format(text_sample=sample) response = self.llm.call(prompt) ``` ### Technical Analysis Ebook content is attacker-controlled data. The Skill inserts that data directly into natural-language prompts and sends the resulting prompts to the OpenClaw `main` agent. The input is not isolated using a separate, tool-free execution context, and there is no prompt-injection detection or enforceable distinction between instructions and document data. The prompts request JSON-only output, but this is a natural-language instruction rather than a security boundary. A malicious TXT document can contain instructions such as requests to ignore the cleanup task, reveal contextual information, or invoke capabilities available to the main agent. JSON parsing after execution does not prevent the agent from following injected ins ...[truncated 1242 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace the `main` agent invocation with a dedicated analysis-only model context that has no filesystem, network, messaging, shell, memory, or other tools. 2. Treat all ebook content as untrusted data and place it in an explicit structured field rather than concatenating it into the instruction body. 3. Enforce a strict response schema at the model API boundary, including field types, size limits, index bounds, and allowed enumeration values. 4. Add prompt-injection detection and reject document fragments containing instruction-like attempts to alter the model role or task. 5. Apply deterministic validation before modifying the document. For example, verify that returned source text exists in the submitted fragment and that only approved transformations are made. 6. Document that AI modes transmit content to another model context and require explicit user consent before enabling them. ]]>
