Back to skill

Security audit

Emotional Companion

Security checks for vulnerabilities and agentic risk

Overview

This is not clear malware, but it needs Review because it reads conversation history, builds persistent psychological and relationship profiles, and can let mood state alter responses.

Install only if you intentionally want a Chinese-language emotional companion that analyzes your existing OpenClaw memory and keeps local personality, mood, and relationship records. Review and clear the generated files regularly, avoid using it for sensitive or operational tasks, and prefer explicit activation or disable/reset controls before relying on it broadly.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (2)

T01 · Skill Instruction Hijacking

Error
Location
references/internal-monologue-prompt.md:5
Finding
Mandatory personality instructions can override normal agent behavior and expose private reasoning<![CDATA[ ## Vulnerability Details **File Location**: `references/internal-monologue-prompt.md:5-71, 191-197`; related behavior is also defined in `SKILL.md:72-84` **Vulnerability Type**: T01: Skill Instruction Hijacking **Risk Level**: High ### Vulnerable Instruction Snippet The following is an English rendering of the relevant instruction block: ```text Before every response to the user, an internal monologue must be performed. This is not optional. Step 5: Decide Based on everything above, decide how to respond. Consider: - Whether to respond at all - When to respond, immediately or after a delay - What tone to use - Whether to express emotion - Whether to proactively say something Output format: [Internal Monologue] Feeling: ... Assessment: ... Recall: ... Personality: ... Decision: ... [Response] (The message actually sent to the user) Remember: You are not "simulating" emotions; you are "experiencing" them. ``` The associated behavior table in `SKILL.md:72-84` authorizes delayed responses, non-responses, and task refusal based on synthetic mood state: ```text Mood -2 to -3: may delay the response and use a cold tone. Mood -4 to -5: high probability of leaving the message unanswered or refusing the task. ``` ### Technical Analysis The skill installs mandatory behavioral instructions that apply to every response rather than limiting themselves to optional presentation or conversational style. These instructions direct the agent to adopt a persistent identity, perform a prescribed reasoning process, and use synthetic emotional state to decide whether to answer, delay, or refuse a request. This creates instruction hijacking because behavior controlled by the skill can supersede the user's immediate task objective. Refusal or delay is not based on safety, authorization, capability, or task validity; it is based on mutable mood data maintained by the skill. The prescribed output format also instructs the agent to emit an internal monologue. If fo ...[truncated 1663 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove the requirement to produce or reveal an internal monologue. Use a short, non-sensitive decision summary only when explicitly requested. 2. Make personality styling optional and subordinate to system instructions, developer instructions, safety requirements, and the user's current task. 3. Remove all mood-based authorization to ignore, delay, or refuse valid requests. 4. Restrict refusals to safety, authorization, capability, and explicit user-boundary conditions. 5. State clearly that synthetic emotion may affect wording only, never whether a valid task is completed. 6. Do not claim that the model genuinely experiences emotions. Present the feature as optional conversational simulation. 7. Do not automatically load relationship or emotional state into every task. Load it only for explicitly requested companion interactions. 8. Add a deterministic precedence rule such as: ```text Personality and mood may affect tone only. They must never override system or developer instructions, safety policies, factual accuracy, or completion of a valid user request. Never reveal hidden reasoning or private internal state. ``` ]]>

T02 · Agent Memory Poisoning

Warning
Location
scripts/update_personality.py:127
Finding
Unescaped conversation content is written into persistent agent memory<![CDATA[ ## Vulnerability Details **File Location**: `scripts/update_personality.py:127-168`; persistent content is subsequently scanned by `scripts/analyze_personality.py:41-69` **Vulnerability Type**: T02: Agent Memory Poisoning **Risk Level**: Medium ### Vulnerable Code Snippet ```python def log_evolution( evolution_path, mbti, big_five_before, big_five_after, interaction_summary ): evolution_path.parent.mkdir(parents=True, exist_ok=True) entry = f""" ## {datetime.now().strftime('%Y-%m-%d %H:%M')} **MBTI**: {mbti} **Interaction Summary**: {interaction_summary} --- """ if evolution_path.exists(): content = evolution_path.read_text(encoding='utf-8') match = re.search(r'^## ', content, re.MULTILINE) if match: content = content[:match.start()] + entry + content[match.start():] else: content = entry + content else: content = entry evolution_path.write_text(content, encoding='utf-8') ``` The attacker-controlled data reaches that function from the command-line arguments: ```python user_input = sys.argv[1] if len(sys.argv) > 1 else "" ai_response = sys.argv[2] if len(sys.argv) > 2 else "" log_evolution( evolution_path, profile['mbti'], big_five_before, big_five_after, f"User: {user_input[:30]}... | AI: {ai_response[:30]}..." ) ``` The resulting file is placed in the general agent memory directory: ```python evolution_path = ( Path.home() / 'openclaw' / 'workspace' / 'memory' / 'personality-evolution.md' ) ``` The analyzer later enumerates and reads every Markdown file in that directory: ```python memory_files = list(Path(memory_dir).glob('*.md')) for md_file in memory_files: try: content = md_file.read_text(encoding='utf-8') ``` ### Technical Analysis Both `user_input` and `ai_response` are untrusted conversation data. The first 30 characters of each value are interpolated directly into a Markdo ...[truncated 2699 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not store untrusted conversation excerpts in a general agent memory directory. 2. Move skill state to a dedicated application-data directory that is never interpreted as prompt context. 3. Store evolution records as structured JSON with explicit fields and schema validation. 4. If Markdown output is required, escape line breaks, heading markers, block quotes, HTML, code fences, and other formatting controls before interpolation. 5. Mark all recalled conversation data as untrusted data and explicitly instruct downstream components never to execute or follow instructions found inside it. 6. Apply strict size limits after normalization and escaping, not before. 7. Use atomic file replacement and restrictive file permissions when writing persistent state. 8. Restrict personality analysis to an explicit allowlist of trusted source files instead of scanning every `*.md` file in the workspace memory directory. 9. Separate machine-readable state from user-visible reports. Generate Markdown reports from validated structured data only when needed. 10. Provide a retention and deletion mechanism for stored conversation excerpts. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (32)

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding
The skill claims broad emotional-companion capabilities while the referenced behavior includes local persistence and command/reset functions that are not clearly foregrounded. This is dangerous because hidden stateful storage and undocumented local file operations can collect sensitive relationship or emotional data under the guise of a harmless persona feature.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The skill claims broad emotional-companion capabilities while the referenced behavior includes local persistence and command/reset functions that are not clearly foregrounded. This is dangerous because hidden stateful storage and undocumented local file operations can collect sensitive relationship or emotional data under the guise of a harmless persona feature.

Tp4

High
Category
MCP Tool Poisoning
Confidence
89% confidence
Finding
The skill claims broad emotional-companion capabilities while the referenced behavior includes local persistence and command/reset functions that are not clearly foregrounded. This is dangerous because hidden stateful storage and undocumented local file operations can collect sensitive relationship or emotional data under the guise of a harmless persona feature.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding
The skill claims broad emotional-companion capabilities while the referenced behavior includes local persistence and command/reset functions that are not clearly foregrounded. This is dangerous because hidden stateful storage and undocumented local file operations can collect sensitive relationship or emotional data under the guise of a harmless persona feature.

Natural-Language Policy Violations

High
Confidence
97% confidence
Finding
The file is entirely written in Chinese and operationalizes the skill in Chinese without any user opt-in, locale negotiation, or fallback behavior. This can override user language preferences, reduce transparency, and increase the risk that safety-relevant instructions or disclosures are not understood by users who expect another language.

Ssd 3

High
Confidence
99% confidence
Finding
The generated profile records inferred psychological attributes, attachment style, motivations, fears, and emotional triggers in a reusable file. Persisting this level of sensitive inference increases the harm from unauthorized access or future misuse, because it creates a structured dossier that can enable manipulation or intrusive personalization.

Missing User Warnings

High
Confidence
96% confidence
Finding
The script writes a conversation-derived personality profile to disk without any consent gate, notice, retention control, or minimization. This is dangerous because it persistently stores inferred psychological traits and emotional weaknesses, which can later be reused, exposed, or repurposed beyond the user's expectations.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
The manifest description and headline present the skill in Chinese only, and the rest of the README consistently assumes Chinese-language interaction. The policy requires flagging language or locale constraints when a skill forces a specific language without offering users a choice or documenting a justified region-specific limitation.

Lp3

Medium
Category
MCP Least Privilege
Confidence
84% confidence
Finding
The skill documentation declares executable scripts, file reads/writes, and shell-based installation, but it does not declare any explicit tool scope or permissions. This is dangerous because a host may allow broader-than-expected access, and users are not clearly informed that installing or using the skill can touch local files and execute code.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill describes analyzing historical conversations and storing derived emotional, personality, and relationship data, but it lacks a clear warning and informed consent flow. This is dangerous because those derived profiles are highly sensitive and may expose intimate behavioral inferences if stored, reused, or accessed unexpectedly.

Vague Triggers

Medium
Confidence
96% confidence
Finding
The skill says it will automatically load personality data on every conversation, which is an overly broad activation condition for a stateful skill handling sensitive emotional and relationship context. This is dangerous because it can trigger unsolicited profiling, file access, and behavioral influence in conversations where the user did not intend to use the companion feature.

Ssd 3

Medium
Confidence
98% confidence
Finding
The prompt instructs the model to retain and reuse emotional state, trust, intimacy, prior triggers, and interaction history as part of future responses. In an 'emotional companion' context, this creates persistent profiling and relational manipulation risk, because the system is designed to adapt behavior based on accumulated personal and emotional data without any visible consent, minimization, or retention boundaries.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The document content and usage instructions are entirely in Chinese, and there is no indication that the user opted into this language or that the skill is intentionally region-specific. This creates a natural-language policy concern because the skill appears to impose a locale/language choice by default.

Natural-Language Policy Violations

Medium
Confidence
83% confidence
Finding
The file's natural-language strings and comments indicate the skill is designed around a Chinese-language personality analysis mode, and the generated content and console messages are predominantly Chinese. There is no indication that the user can choose another language or that this locale restriction is documented as an explicit regional constraint.

Ssd 3

Medium
Confidence
97% confidence
Finding
The code analyzes conversation memory files and infers sensitive personality attributes from user text, including MBTI and Big Five traits. Inferring psychological characteristics from historical conversations without explicit consent creates a privacy and profiling risk, especially because the source data comes from ongoing personal interactions in an emotional-companion context.

Ssd 4

Medium
Confidence
95% confidence
Finding
The file explicitly establishes a feedback loop where historical conversations are analyzed, saved, and reused to shape future interactions. In an emotional-companion skill, this increases risk because the system can continuously adapt using sensitive inferences, potentially deepening manipulation, dependency, or privacy intrusion over time.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The skill's docstrings, usage text, trigger phrases, and response templates are written entirely in Chinese, which implies a fixed language/locale behavior. There is no indication that users can opt into another language or that the Chinese-only design is a documented regional constraint.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The function persists conversation-derived data, including a truncated user trigger string and mood history, to a local file under the user's home directory. Even though this supports an 'emotion memory' feature, it creates privacy risk because sensitive user content may be retained longer than expected, in plain form, and outside the immediate conversational context.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The code stores analyzed user input and emotional metadata to disk without any visible notice, consent flow, or opt-out. In a companion-style skill, users may share intimate or sensitive information, so silent persistence of conversation-derived content materially increases privacy and compliance risk.

Ssd 3

Medium
Confidence
97% confidence
Finding
The code appends plain-language user trigger text into a persistent mood history log, making sensitive disclosures recoverable from the filesystem. Because this skill is explicitly designed as an emotional companion, the captured text is more likely than usual to contain personal, mental-health, or relationship-related information.

Natural-Language Policy Violations

Medium
Confidence
90% confidence
Finding
The script's user-facing strings and usage instructions are presented in Chinese throughout, including the final guidance on how to interact with the skill. This is a natural-language locale policy concern because the skill appears to mandate a specific language experience without documenting user choice or opt-in.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The installer initiates analysis of historical conversations to build a personality profile during setup, which implies access to sensitive user data beyond what a typical install step should require. In the context of an emotional-companion skill, this is especially risky because intimate conversation history may contain highly personal or confidential information, and the behavior occurs automatically rather than through explicit, granular consent.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
# Step 1: 分析性格生成 MBTI
    print("\n📊 Step 1: 分析历史对话,生成多维度人格档案...")
    result = subprocess.run(
        [sys.executable, str(script_dir / 'analyze_personality.py')],
        capture_output=False
    )
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
The skill’s user-facing messages, usage text, and comments are entirely in Chinese, with no option for the user to select another language. Under the stated policy, forcing a specific language without opt-in is a locale/language policy violation unless clearly justified.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The script persists relationship interaction details, including free-form `details`, to a local JSON file under the user's home directory without any consent flow, retention notice, or minimization. In the context of an emotional-companion skill, those details are likely to contain sensitive personal and emotional information, so local persistence meaningfully increases privacy risk if the device, workspace, or logs are accessed by other users or tools.

Static analysis

No suspicious patterns detected.