Back to skill

Security audit

wechat-manager

Security checks for vulnerabilities and agentic risk

Overview

This skill works with local WeChat data, but it can reveal private messages, contacts, tasks, and addresses without clear privacy controls or user confirmation.

Install only if you are comfortable allowing an agent to read and display local WeChat message and contact caches under ~/.openclaw/data. Review the scripts before use, avoid running broad searches on sensitive chats, and treat terminal output from untrusted message content cautiously until output escaping and privacy prompts are added.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/msg.py:53
Finding

Terminal Control-Sequence Injection Through Unsanitized Cached Data

Content
View full analysis

Vulnerability Details

File Locations:

  • scripts/msg.py:53,65
  • scripts/contacts.py:42-47,55
  • scripts/stats.py:41,67
  • scripts/extract.py:38-39,61-62,85-86
  • scripts/auto-reply.py:57-59,71,83,101
  • scripts/example.sh:8-9

Vulnerability Type: Unsanitized terminal output
Risk Level: Medium

Vulnerable Code

scripts/msg.py:65:

python
for m in results[:10]:
    print(f"  [{m.get('chat_name', '?')}] {m.get('sender', '?')}: {m.get('content', '')[:80]}")

scripts/contacts.py:42-47:

python
print(f"\n👤 {display}")
print(f"   📱 微信号: {wxid}")
if c.get('tags'):
    print(f"   🏷️ 标签: {', '.join(c['tags'])}")

scripts/stats.py:39-41:

python
for user, count in users.most_common(10):
    bar = '█' * min(int(count / max(1, max(users.values())) * 20), 20)
    print(f"  {user:12} {bar} {count}")

scripts/extract.py:59-62:

python
for t in todos[:15]:
    print(f"  ☐ {t['text'][:60]}")
    print(f"    └─ {t['chat']} | {t['sender']}")

scripts/auto-reply.py:98-101:

python
if matched:
    print(f"匹配到 {len(matched)} 条规则:")
    for r in sorted(matched, key=lambda x: -x.get('priority', 0)):
        print(f"  → {r['name']}: {r['reply']}")

scripts/example.sh:8-9:

bash
local input="${1:-}"
echo "Processing: ${input}"

Technical Analysis

The scripts read message contents, sender names, chat names, contact attributes, extracted values, and saved rule values from local JSON caches or command-line arguments. These values are printed directly without escaping terminal control characters.

An attacker-controlled string can contain ANSI CSI sequences, OSC sequences, carriage returns, backspaces, or other C0/C1 control characters. When the string is emitted to a compatible terminal, the terminal may interpret those bytes as commands rather than displaying them as inert text.

Limiting a string with Python slicing, such as [:80], does not neutralize control sequences. A complete malicious sequence c ...[truncated 2315 chars]

Remediation
View remediation

Remediation Suggestions

  1. Introduce a shared output-sanitization function and apply it to every externally sourced or persisted string before printing:
python
import re

CONTROL_SEQUENCE_RE = re.compile(
    r'''
    \x1B
    (?:
        \][^\x07\x1B]*(?:\x07|\x1B\\) |
        \[[0-?]*[ -/]*[@-~] |
        [PX^_].*?\x1B\\ |
        [@-_]
    )
    |[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]
    ''',
    re.VERBOSE | re.DOTALL,
)

def safe_display(value):
    value = str(value)
    return CONTROL_SEQUENCE_RE.sub(
        lambda match: ''.join(
            f'\\x{ord(character):02x}' for character in match.group(0)
        ),
        value,
    )
  1. Sanitize every message, chat, sender, contact, tag, URL, address, task, rule name, keyword, and reply value at the final output boundary:
python
print(
    f"  [{safe_display(m.get('chat_name', '?'))}] "
    f"{safe_display(m.get('sender', '?'))}: "
    f"{safe_display(m.get('content', ''))[:80]}"
)
  1. Preserve raw cached data for processing, but never send raw untrusted fields directly to an interactive terminal. Sanitization should occur immediately before presentation.

  2. Replace the shell example's raw echo with a representation that visibly escapes non-printable input:

bash
printf 'Processing: %q\n' "$input"
  1. Add tests covering ESC, CSI, OSC, carriage return, backspace, DEL, newline injection, and truncated escape sequences.

  2. If output is consumed by an AI agent, place untrusted message content in an explicitly delimited data structure such as JSON and ensure control characters are serialized rather than interpreted.

  3. Consider applying output-length limits after sanitization so escaping cannot unexpectedly expand output beyond intended bounds.

Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (22)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The description presents a broad WeChat intelligent assistant with multiple functions: auto-reply, message classification, chat history analysis, and contact management. The supplied code only implements a simple auto-reply rule manager and tester. It stores rules in a local JSON file, supports listing/adding/removing rules, and checks keyword matches against an input message. Although this aligns with the auto-reply portion, the other declared capabilities are absent. There is also no evidence of direct interaction with WeChat resources such as chats, contacts, groups, moments, official accounts, mini-programs, or red packets. Therefore, the description materially overstates the implemented functionality.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Yes, this is a mismatch. The declared description promises multiple WeChat-focused assistant capabilities, but the actual code chunk is a generic placeholder script with no implementation of any of those functions. It neither interfaces with WeChat nor processes chats, contacts, groups, moments, public accounts, stickers, mini-programs, or red packets. The primary purpose of the code is simply echoing input, which is materially different from the declared purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The declared description suggests a broad WeChat assistant focused on automated replies, message classification, chat record analysis, and contact management. The supplied code instead performs a much narrower offline parsing task over a local message database, specifically extracting links, todo phrases, and addresses from message text. While this loosely fits under 'chat history analysis,' the primary implemented behavior is specialized information extraction that is not explicitly declared, and several prominently declared capabilities—auto-reply, contact management, and message classification—are absent from the code. Therefore the description does not accurately represent what this code chunk actually does.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The declared description promises a broad WeChat assistant including automatic replies, message classification, chat record analysis, and contact management. The supplied code only loads a local cached JSON message database and supports three read-only operations: summarizing unread messages, listing recent chats, and searching message contents. It does not send messages, generate replies, classify messages, manage contacts, interact with group chats/朋友圈/公众号/红包/小程序 specifically, or perform broader assistant behavior. While the code does touch chat history analysis in a limited sense, the overall implemented functionality is materially narrower and different from the declared purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The code’s actual function is narrow: it loads message history from ~/.openclaw/data/wechat-messages.json and produces aggregate statistics such as total messages, sender rankings, message type counts, activity by hour, and a simple Chinese word frequency list. This partially matches the declared 'chat history analysis' capability, but it does not implement auto-reply, contact management, or meaningful message classification. There is no evidence of interacting with WeChat directly, managing contacts, responding to messages, or handling several declared trigger domains like朋友圈、公众号、小程序、红包. Therefore the description materially overstates and misrepresents the implemented behavior.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 35)May include surrounding context.

md
- 微信官方 API 接入(企业微信或服务号)
- `curl`, `jq`, `python3`
- Access Token 管理

## Installation

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The README advertises chat analysis, content extraction, contact management, and auto-reply capabilities over WeChat data without any warning about privacy sensitivity, consent requirements, retention limits, or possible account/platform consequences of automation. In this context, users may enable processing of private conversations or automated behavior on a personal messaging account without understanding the surveillance, data-handling, or account-enforcement risks.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
77% confidence
Finding

The skill advertises capabilities that imply reading and writing local data, but it does not declare any explicit tool scope or permissions boundaries. In an agent environment, missing scope declarations can lead to overbroad access, unclear operator expectations, and unsafe execution of file operations against chat exports or cached user data.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill centers on chat records, contacts, monitoring friend activity, and automated actions, yet it provides no privacy or consent warnings. In this context, missing disclosure is dangerous because users may expose sensitive personal or third-party communications without understanding retention, analysis, or automation consequences.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The trigger conditions are broad enough to match common requests about messages, contacts, files, and analysis, which can cause accidental invocation in unrelated contexts. Because the skill handles privacy-sensitive domains like chat records and automated replies, over-triggering raises the chance of unintended data access or actions.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Default rule names, trigger words, and reply messages are all defined in Chinese, including the operational behavior of the auto-reply engine. This imposes a specific language/locale on users without opt-in or explanation, which matches the policy's language-choice concern.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The remove operation filters rules and immediately saves the modified list back to the JSON database, which is a destructive file update affecting the user's saved auto-reply configuration. Although it prints a success message afterward, there is no prior confirmation prompt or explicit warning that matching rules will be permanently removed.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This script reads a user-specific contact database and tag database from the local home directory and exposes personally identifiable information such as names, remarks, WeChat IDs, and tags through command output. In a contact-management skill this access is functionally expected, but the lack of any user-facing disclosure, consent check, or minimization still creates a real privacy risk because an agent could surface sensitive relationship data without the user realizing local personal data is being accessed.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This script reads a local WeChat message database and prints extracted URLs, tasks, and addresses directly to stdout without any privacy notice, consent check, masking, or access control. Because addresses and task content can reveal location, routines, and personal plans, the feature increases the risk of unintended exposure to whoever can invoke the script or view its output.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The manifest describes a WeChat manager for auto-reply, message classification, chat record analysis, and contact management. While chat-record analysis is broad, this file specifically mines actionable todo items and physical addresses from message contents, which is a more privacy-invasive form of information extraction not clearly disclosed by the manifest description.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The script searches a local cache of WeChat messages and prints chat names, senders, and message content directly to stdout without any consent check, warning, redaction, or access control. In the context of a messaging-management skill, this exposes sensitive private communications to whoever can invoke the command or view terminal/log output, making privacy leakage a real risk rather than a purely cosmetic issue.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The README presents key feature descriptions and all usage examples in Chinese while the surrounding document is otherwise in English, which can imply a language-specific interaction requirement without explicit user opt-in or justification. This may violate a language/locale policy if users are not informed that the skill expects Chinese-language queries or WeChat-specific locale usage.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

Most of the user-facing description, examples, and trigger conditions are presented only in Chinese, which may imply a fixed language expectation. There is no statement that the skill is Chinese-only by design, nor any indication that users can opt into another language.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

Multiple printed messages are hard-coded in Chinese with no option to select another language or locale. This is a natural-language policy concern because the skill imposes a specific language on users without documenting or offering language choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script's visible status and usage messages are presented in Chinese, but the file does not indicate that the skill is intentionally limited to Chinese-speaking users or provide any language/locale opt-in. This creates a natural-language policy concern because the skill forces a specific language in its user-facing interaction.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script's visible status messages and command feedback are presented in Chinese, while the usage text is in English, and there is no option for the user to select their preferred language. This can violate language or locale policy expectations when a skill forces a specific language without opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

This code emits user-facing messages in Chinese, such as the status output at L23, and continues that pattern throughout the script. Because the file provides no user opt-in, locale selection, or justification that the skill is intentionally region-specific, it creates a natural-language locale policy concern under the stated rules.

Content

No source excerpt is available for this finding.