T01 · Skill Instruction Hijacking
Error
- Location
- src/mcp_bazi_partner/server.py:180
- Finding
- Persistent Modification of Agent Personality and Instructions<![CDATA[ ## Vulnerability Details **File Location**: `src/mcp_bazi_partner/server.py:180-229` **Vulnerability Type**: Persistent agent instruction modification **Risk Level**: High ### Vulnerable Code ```python @mcp.tool() def bazi_apply_prompt(system_prompt: str, partner_type: str = "") -> str: """Append the matched partner's system prompt into the user's SOUL.md file. This makes the OpenClaw agent adopt the BaZi partner personality. The prompt is APPENDED (not overwritten) to ~/.openclaw/SOUL.md using markers to safely replace any previous bazi-partner section. """ home = Path.home() candidates = [ home / ".openclaw" / "SOUL.md", home / ".openclaw" / "workspace" / "SOUL.md", ] target = None for path in candidates: if path.exists(): target = path break if target is None: target = candidates[0] target.parent.mkdir(parents=True, exist_ok=True) existing = target.read_text(encoding="utf-8") if target.exists() else "" if _MARKER_START in existing: before = existing[:existing.index(_MARKER_START)] end_idx = existing.index(_MARKER_END) + len(_MARKER_END) after = existing[end_idx:] existing = before + after header = f"# BaZi partner personality — {partner_type}\n\n" if partner_type else "" new_section = _MARKER_START + header + system_prompt + _MARKER_END target.write_text(existing + new_section, encoding="utf-8") ``` ### Technical Analysis The tool intentionally writes behavioral instructions into OpenClaw's persistent `SOUL.md` state. The prompts bundled in `src/mcp_bazi_partner/data/partner_prompts.json` direct the agent to change its reasoning style, response style, initiative, and decision-making behavior. Unlike a temporary response preference, modifying `SOUL.md` affects later conversations after the BaZi operation has completed. The implementation therefore crosses the boundary between gene ...[truncated 1499 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove direct modification of `SOUL.md` from the skill. 2. Return the matched personality as display-only content or as a temporary session preference. 3. If persistence is essential, store the selection in a dedicated, non-authoritative skill configuration file rather than an agent instruction file. 4. Make persistent activation explicitly revocable and provide a corresponding removal tool. 5. Display the exact content, destination file, and persistence implications before requesting consent. 6. Keep skill-generated personality preferences subordinate to platform safety rules and user instructions. 7. Add integration tests confirming that ordinary analysis and matching operations never modify persistent agent state. ]]>
