Back to skill

Security audit

WeCom Task Manager

Security checks for vulnerabilities and agentic risk

Overview

This is a real WeCom task manager, but it needs review because it can modify or delete shared task records and its safeguards are too weak for that authority.

Review before installing in any shared or production WeCom workspace. Fix mcporter calls to use argument arrays with shell=False, remove hardcoded doc/sheet fallbacks, replace AGENT_ID-based authorization with a trusted runtime identity, add authorization to all goal APIs, and require explicit confirmation for delete operations.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/task_manager.py:164
Finding

Shell Command Injection in MCP Command Execution

Content
View full analysis

Vulnerability Details

File Location: scripts/task_manager.py, lines 164-168 and 423-426
Vulnerability Type: OS command injection through unsafe shell interpolation
Risk Level: High

Vulnerable Code

python
def run_mcporter(command: str, args_dict: dict) -> Optional[dict]:
    args_json = json.dumps(args_dict, ensure_ascii=False)
    cmd = f'{MCPORTER_PATH} call wecom-doc.{command} --args \'{args_json}\' --output json'
    result = subprocess.run(cmd, shell=True, capture_output=True, text=True)

The retry implementation repeats the same vulnerable pattern:

python
args_json = json.dumps(args_dict, ensure_ascii=False)
cmd = f'{MCPORTER_PATH} call wecom-doc.{command} --args \'{args_json}\' --output json'
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)

Technical Analysis

The implementation serializes MCP arguments as JSON, embeds that JSON inside a single-quoted shell command, and executes the resulting string with shell=True.

JSON serialization does not make data safe for use in a shell command. In particular, a single quote in an attacker-controlled value is preserved by json.dumps() and can terminate the shell's single-quoted argument. Subsequent shell metacharacters can then be interpreted as commands.

Values reaching args_dict include task identifiers, names, descriptions, remarks, blockers, output URLs, owners, arbitrary edited fields, and data read back from WeCom records. Consequently, both direct input and previously stored task data may reach this execution sink.

The command argument is also interpolated into the shell command without validation. Although current internal call sites use predefined MCP method names, the helper is public and can be imported and invoked directly.

Attack Path

  1. An attacker obtains a path to invoke a task mutation API, either directly through the Python module, through the CLI, or by influencing an a ...[truncated 1440 chars]
Remediation
View remediation

Remediation Suggestions

Eliminate shell interpretation and pass every command component as a separate argument:

python
def run_mcporter(command: str, args_dict: dict) -> Optional[dict]:
    allowed_commands = {
        "smartsheet_get_records",
        "smartsheet_add_records",
        "smartsheet_update_records",
        "smartsheet_delete_records",
        "smartsheet_get_fields",
    }
    if command not in allowed_commands:
        raise ValueError("Unsupported MCP command")

    args_json = json.dumps(args_dict, ensure_ascii=False)
    result = subprocess.run(
        [
            MCPORTER_PATH,
            "call",
            f"wecom-doc.{command}",
            "--args",
            args_json,
            "--output",
            "json",
        ],
        shell=False,
        capture_output=True,
        text=True,
        check=False,
        timeout=30,
    )

Apply the same correction to run_mcporter_with_retry().

Additional hardening should include:

  • Centralizing MCP execution in one safe helper rather than duplicating command construction.
  • Allowlisting supported MCP method names.
  • Adding maximum lengths and type validation for task fields.
  • Running the Skill under a minimally privileged operating-system account.
  • Adding regression tests containing quotes, newlines, command substitutions, and shell metacharacters.
  • Avoiding logging raw process output when it may contain credentials or sensitive remote data.

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/task_manager.py:89
Finding

Authorization Bypass Through Caller-Controlled Agent Identity

Content
View full analysis

Vulnerability Details

File Location: scripts/task_manager.py, lines 89-112
Vulnerability Type: Spoofable caller identity and broken authentication boundary
Risk Level: High

Vulnerable Code

python
def check_access(agent_id: str = "") -> bool:
    if not ACCESS_CONTROL_ENABLED:
        return True

    if not agent_id:
        agent_id = os.environ.get("AGENT_ID", "")

    if not agent_id:
        return False

    if agent_id in ALLOWED_AGENTS:
        return True

    return False

Technical Analysis

The access-control decision is based solely on an agent_id supplied by the caller or read from the process environment. Neither source proves the caller's identity:

  • A Python caller can pass agent_id="da-yan" directly.
  • A CLI caller can set AGENT_ID=da-yan before launching the script.
  • Any code executing in the same process can modify os.environ.
  • The value is compared to a whitelist without a signature, token, authenticated session, or trusted framework context.

The code therefore performs authorization against an untrusted identity assertion rather than an authenticated principal. The test suite itself demonstrates that the environment variable is intended to control identity, confirming that no stronger authentication layer exists in this module.

Once the spoofed identity passes check_access(), the caller can reach operations that read, create, edit, start, complete, and delete WeCom task records.

Attack Path

  1. A local user, untrusted Skill, or subprocess gains the ability to execute task_manager.py or import task_manager.
  2. The caller sets AGENT_ID to an allowlisted value, such as da-yan, or passes the same value through an API's agent_id parameter.
  3. check_access() reads the attacker-controlled value.
  4. The string matches an entry in ALLOWED_AGENTS.
  5. Access is granted without authentication.
  6. The attacker calls privileged ...[truncated 878 chars]
Remediation
View remediation

Remediation Suggestions

Replace caller-asserted identity with an authenticated identity supplied by the trusted OpenClaw runtime.

Recommended controls:

  1. Remove public agent_id parameters from privileged APIs.
  2. Do not use AGENT_ID as an authentication mechanism.
  3. Obtain the caller identity from an immutable, authenticated invocation context.
  4. Verify cryptographically signed invocation metadata if calls can cross process or network boundaries.
  5. Enforce permissions again at the MCP server, where callers should receive scoped credentials rather than shared broad access.
  6. Define operation-level permissions instead of granting every allowlisted agent unrestricted access.
  7. Separate read, create, update, and delete permissions.
  8. Record authenticated principal identifiers in audit logs.
  9. Add negative tests proving that environment variables and function arguments cannot impersonate authorized agents.
  10. If trusted identity cannot be established, restrict the module to a protected local service endpoint and enforce operating-system access controls around that service.

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/task_manager.py:931
Finding

Goal Management APIs Bypass the Skill Whitelist

Content
View full analysis

Vulnerability Details

File Location: scripts/task_manager.py, lines 931-968 and 1148-1151
Vulnerability Type: Missing authorization on persistent goal-state operations
Risk Level: Medium

Vulnerable Code

The goal creation path reads and writes shared persistent state without calling check_access():

python
def create_goal(
    goal_id: str,
    title: str,
    priority: str = "medium",
    context: str = "",
    owner: str = ""
) -> bool:
    data = load_goal_data()

    for goal in data["goals"]:
        if goal["id"] == goal_id:
            return False

    goal = {
        "id": goal_id,
        "title": title,
        "priority": priority,
        "context": context,
        "owner": owner,
        "status": "active",
        "created_at": datetime.now().isoformat(),
        "tasks": []
    }

    data["goals"].append(goal)
    save_goal_data(data)
    return True

Goal listing is likewise unprotected:

python
def list_goals() -> List[dict]:
    data = load_goal_data()
    return data["goals"]

The underlying persistence operation writes the shared goal database directly:

python
def save_goal_data(data: dict):
    GOAL_DATA_FILE.parent.mkdir(parents=True, exist_ok=True)
    with open(GOAL_DATA_FILE, 'w', encoding='utf-8') as f:
        json.dump(data, f, ensure_ascii=False, indent=2)

Technical Analysis

The Skill advertises a whitelist access-control model for its APIs, but create_goal() and list_goals() do not accept a caller context and do not invoke check_access().

These functions operate on the persistent file at:

text
~/.openclaw/skills/wecom-task-manager/data/goals.json

As a result, any code that can import the module can read shared goal metadata or add persistent goal records, even when it is not an allowlisted agent. The CLI routes for create-goal and goals call these unprotecte ...[truncated 1364 chars]

Remediation
View remediation

Remediation Suggestions

Apply authenticated authorization consistently to every public goal API:

  • create_goal()
  • decompose_goal()
  • list_goals()
  • print_goals()
  • get_next_task()
  • print_next_task()
  • delete_goal()

Pass a trusted invocation context rather than a caller-controlled string. Centralize enforcement in a decorator or service boundary so new APIs cannot accidentally omit authorization.

Also harden local persistence:

  • Create the data file with owner-only permissions.
  • Use atomic writes through a temporary file followed by a rename.
  • Add file locking to prevent concurrent lost updates.
  • Validate identifier lengths, title lengths, accepted priorities, and total record count.
  • Maintain an audit trail containing the authenticated caller and operation.
  • Add automated tests that invoke each public API as an unauthorized principal and verify denial without file changes.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/task_manager.py:50
Finding

Hardcoded WeCom Resource Identifier Used When Configuration Fails

Content
View full analysis

Vulnerability Details

File Location: scripts/task_manager.py, lines 50-58
Vulnerability Type: Unsafe fail-open resource configuration
Risk Level: Medium

Vulnerable Code

python
DOCID = CONFIG.get("enterpriseWeChat", {}).get(
    "docId",
    "dcTCczAuKRidTOQ9ZlUOpXgW9JSuq7slNrR6Z6O-N80yqOaGNTJpcTyqYXgOF7aXURG1adBiAxIYCi5KQg7KAXvA"
)
SHEET_ID = CONFIG.get("enterpriseWeChat", {}).get(
    "sheetId",
    "q979lj"
)
MCPORTER_PATH = "/usr/local/Cellar/node/25.6.0/bin/mcporter"

Configuration-loading failures return an empty dictionary, causing these embedded values to be selected:

python
if not config_path.exists():
    return {}

try:
    with open(config_path, 'r', encoding='utf-8') as f:
        config = json.load(f)
    return config
except Exception as e:
    return {}

Technical Analysis

If config.json is absent, malformed, unreadable, or lacks the required WeCom settings, the Skill does not stop. It silently uses an embedded document identifier and sheet identifier.

These values resemble a concrete resource identifier rather than an inert placeholder. Although a document identifier is not necessarily an authentication secret, using a real-looking resource as a fallback can cause operations to target an unintended sheet whenever the host's MCP server has access to it.

This behavior is particularly dangerous for mutation and deletion operations because configuration failure changes the target without requiring confirmation.

Attack Path

  1. The Skill is installed without config.json, or the configuration becomes malformed or unreadable.
  2. load_config() returns an empty dictionary.
  3. The hardcoded DOCID and SHEET_ID values are selected.
  4. An authorized or spoofed caller invokes a read, create, update, or delete operation.
  5. mcporter sends the operation to the embedded document and sheet identifiers.
  6. If the configured MCP cre ...[truncated 663 chars]
Remediation
View remediation

Remediation Suggestions

Remove all concrete fallback resource identifiers and fail closed when configuration is missing or invalid:

python
enterprise_config = CONFIG.get("enterpriseWeChat", {})
DOCID = enterprise_config.get("docId")
SHEET_ID = enterprise_config.get("sheetId")

if not DOCID or not SHEET_ID:
    raise RuntimeError("Explicit WeCom document and sheet configuration is required")

Additional hardening should include:

  • Validate configuration against a strict schema at startup.
  • Reject placeholder values such as YOUR_DOC_ID_HERE.
  • Distinguish development, testing, and production configurations.
  • Require explicit confirmation or environment scoping for destructive operations.
  • Avoid catching all configuration exceptions and continuing with defaults.
  • Make the mcporter path configurable and validate that the resolved executable is trusted.
  • Rotate or replace the embedded document identifier if it refers to a real resource.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (27)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
99% confidence
Finding

This is a true tool-parameter-abuse issue because the skill forwards task fields into a shell command that invokes an external tool. In an agent skill context, task names, descriptions, remarks, URLs, and other fields may come from untrusted upstream prompts or other agents, making shell injection especially dangerous and enabling arbitrary command execution under the skill's privileges.

Content

Scanner excerpt · scripts/task_manager.py (reported line 168)May include surrounding context.

python
"""执行 mcporter 命令"""
    args_json = json.dumps(args_dict, ensure_ascii=False)
    cmd = f'{MCPORTER_PATH} call wecom-doc.{command} --args \'{args_json}\' --output json'
    result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    
    if result.returncode != 0:
        print(f"Error running mcporter: {result.stderr}")

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
99% confidence
Finding

The retry path reproduces the same external-tool parameter abuse vulnerability and may execute attacker-supplied payloads multiple times. In this skill, many public functions pass user-influenced content into args_dict, so exploitation could occur through normal task creation or update flows without any special privileges beyond invoking the skill.

Content

Scanner excerpt · scripts/task_manager.py (reported line 426)May include surrounding context.

python
for attempt in range(1, max_retries + 1):
        args_json = json.dumps(args_dict, ensure_ascii=False)
        cmd = f'{MCPORTER_PATH} call wecom-doc.{command} --args \'{args_json}\' --output json'
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
        
        if result.returncode == 0:
            try:

Missing User Warnings

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The delete_task function performs irreversible deletion of a task record through smartsheet_delete_records and only reports success after the fact. There is no confirmation prompt or explicit pre-deletion warning to the user before the destructive action occurs.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

delete_goal announces that it is about to delete a goal and related tasks, but then immediately proceeds to delete all matching tasks programmatically. A printed status message is not equivalent to a confirmation step, so the user is not given a chance to approve or abort the bulk destructive operation.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · QUICKSTART.md (reported line 58)May include surrounding context.

方式 1:CLI 命令

bash
python3 task_manager.py create TASK-100 "我的第一个任务" 开发

方式 2:Python 代码

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · QUICKSTART.md (reported line 58)May include surrounding context.

方式 1:CLI 命令

bash
python3 task_manager.py create TASK-100 "我的第一个任务" 开发

方式 2:Python 代码

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

This markdown quickstart lists a task deletion command as a normal common command, but does not warn that it removes task data or advise the user to verify the target before running it. For markdown files, destructive behaviors that can affect user data should include an explicit warning.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

This markdown file lists delete_task() and delete_goal() as available operations, but provides no warning that these actions may permanently remove task data or affect shared team records. For markdown files, safety-relevant behaviors that can impact user data should be explicitly disclosed.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The skill documentation is entirely written in Chinese and all invocation templates, command descriptions, and output examples assume Chinese-language use, with no indication that users may choose another language or that the skill is region- or locale-restricted. This can violate the language/locale policy when a specific language is effectively imposed without opt-in or documented justification.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill exposes delete_task() and delete_goal() as normal operations and even notes that delete_goal() recursively deletes associated subtasks, but it does not require confirmation, role separation, or recovery guidance. In an agent setting, destructive actions can be triggered by prompt injection, user error, or ambiguous instructions, causing irreversible loss of operational records and task state.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This JSON manifest contains user-facing natural-language strings entirely in Chinese, including denial and limit-reached messages, but does not document any language selection, fallback, or opt-in behavior. Under the policy rule for language/locale constraints, a forced locale without user choice is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

This manifest-style JSON uses Chinese natural-language titles and context throughout, with no indication that users or downstream agents can choose a language or locale. Under the policy for natural-language violations, forcing a specific language without opt-in is in scope even when it appears in config values rather than prose instructions.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The documentation presents state-changing APIs such as task creation and task lifecycle updates as ordinary helper functions without prominently warning that they modify remote enterprise task records. In an agent skill context, this increases the chance an automated agent or user will invoke them assuming they are read-only or local, causing unintended changes to shared production task data.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The heartbeat example iterates over all pending tasks and automatically calls start_task on each one, performing bulk remote state transitions without any warning, filtering, dry-run mode, or user confirmation. In an agent environment, this is particularly dangerous because copied example code may be executed verbatim, resulting in widespread unauthorized task ownership and status changes across the shared system.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The module-level description and all user-facing strings are written exclusively in Chinese, indicating the skill is designed around a single language experience. There is no natural-language indication that users may choose another language or that the locale restriction is optional or region-specific.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The helper builds a shell command and invokes subprocess.run(..., shell=True) to call mcporter, passing task arguments that include document IDs and user-supplied task content. Although the function has an internal docstring, there is no explicit user-facing disclosure or confirmation at the point this external command transmits data to Enterprise WeChat services.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
98% confidence
Finding

The code builds a shell command with string interpolation and executes it with shell=True. Although args_dict is JSON-encoded, untrusted values containing single quotes can break out of the quoted --args argument and inject additional shell syntax, allowing command execution in the agent environment.

Content

Scanner excerpt · scripts/task_manager.py (reported line 168)May include surrounding context.

python
"""执行 mcporter 命令"""
    args_json = json.dumps(args_dict, ensure_ascii=False)
    cmd = f'{MCPORTER_PATH} call wecom-doc.{command} --args \'{args_json}\' --output json'
    result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    
    if result.returncode != 0:
        print(f"Error running mcporter: {result.stderr}")

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
98% confidence
Finding

This retry wrapper repeats the same unsafe shell construction pattern as the primary mcporter executor. Any attacker-controlled value passed into command or args_dict can trigger shell injection on every retry attempt, potentially compounding impact.

Content

Scanner excerpt · scripts/task_manager.py (reported line 426)May include surrounding context.

python
for attempt in range(1, max_retries + 1):
        args_json = json.dumps(args_dict, ensure_ascii=False)
        cmd = f'{MCPORTER_PATH} call wecom-doc.{command} --args \'{args_json}\' --output json'
        result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
        
        if result.returncode == 0:
            try:

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The module docstring at L0004-L0006 presents this as a 企业微信 task management core module providing task create/update/query/complete functions. Starting at L0911, the code adds a separate goal-management subsystem that stores goal data in a local JSON file under the user's home directory, which is a distinct capability not described in the module documentation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

This function writes goal data to ~/.openclaw/skills/wecom-task-manager/data/goals.json, creating directories as needed, but does not notify the user that their goal content will be persisted locally. The docstring is developer-facing and does not serve as a visible disclosure to the user at runtime.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The section header at L0911 says goal-management functionality is integrated into this module, and the delete_goal docstring at L1319 says it deletes a goal and its associated tasks. However, the implementation only enumerates and deletes matching Enterprise WeChat tasks; it never removes the goal entry from goals.json, so the documented intent of deleting the goal is contradicted by actual behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This Python file contains multiple user-facing docstrings and print strings in Chinese, such as the module description and test status messages. Because the file provides no user opt-in, language selection, or justification for a Chinese-only interface, it creates a locale-policy concern under the natural-language policy rule.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The natural-language content of the skill guide forces a specific language/locale for all users, and the document does not indicate that users can choose another language or that the Chinese-only presentation is a justified regional constraint. This matches the policy category for language or locale restrictions without user opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The manifest description is written entirely in Chinese ("企业微信任务管理技能 - 全局技能") with no indication that the skill is region-specific or that users can choose another language. Under the policy, a fixed language/locale without opt-in or justification is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The docstring and all printed status messages are in Chinese, which imposes a specific language on users. The file does not provide any opt-in, locale selection, or documentation indicating that this is intentionally limited to a Chinese-speaking or region-specific context.

Content

No source excerpt is available for this finding.