Back to skill

Security audit

tool-use

Security checks for vulnerabilities and agentic risk

Overview

The skill is a tool dispatcher, but its safety claims do not match code that can run shell commands, import Python functions dynamically, and store usage notes.

Install only if you intend to review and restrict every registry entry yourself, run it in a low-privilege sandbox, avoid passing untrusted arguments to command tools, and are comfortable with local persistence of usage notes/preferences. The current artifacts should be treated as needing review before normal use, not as a safe general-purpose dispatcher.

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

Error
Location
scripts/dispatch.py:31
Finding

Shell Command Injection Through Untrusted Tool Arguments

Content
View full analysis

Vulnerability Details

File Location: scripts/dispatch.py, lines 31-32
Vulnerability Type: OS command injection caused by unsafe shell execution
Risk Level: High

Vulnerable Code

python
cmd = entry["cmd"].format(**args)
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)

Technical Analysis

The dispatcher inserts values from the tool call's arguments object directly into a registered command template using str.format(). It then passes the resulting string to subprocess.run() with shell=True.

Because a system shell interprets the formatted string, shell control characters contained in an argument—such as semicolons, command substitutions, pipes, or redirections—are treated as executable syntax rather than as literal argument data.

The validate() function only verifies that the requested tool is registered and that required argument names are present. It does not enforce argument types, validate values against a schema, reject shell metacharacters, or otherwise prevent command injection. Registration of the command template therefore does not make argument interpolation safe.

This implementation also contradicts the documented safety claim that command tools disable unnecessary shell expansion and redirection.

Attack Path

  1. A registry defines a command tool containing an argument placeholder, for example:

    json
    {
      "echo": {
        "type": "command",
        "cmd": "echo {text}",
        "required": ["text"]
      }
    }
    
  2. An attacker or untrusted model-generated tool call supplies shell syntax in that argument:

    json
    {
      "name": "echo",
      "arguments": {
        "text": "hello; id"
      }
    }
    
  3. validate() accepts the call because echo is registered and the text argument is present.

  4. String formatting produces:

    sh
    echo hello; id
    
  5. Because t ...[truncated 1080 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove shell=True and execute commands as argument arrays with shell=False:

    python
    command = entry["cmd"]
    argv = [part.format(**args) for part in command]
    result = subprocess.run(
        argv,
        shell=False,
        capture_output=True,
        text=True,
        timeout=30,
        check=False,
    )
    

    Registry commands should consequently be represented as arrays rather than shell command strings:

    json
    {
      "echo": {
        "type": "command",
        "cmd": ["echo", "{text}"],
        "required": ["text"]
      }
    }
    
  2. Validate that call is an object, arguments is an object, and each argument conforms to an explicit schema. Enforce types, lengths, enumerations, numeric bounds, and application-specific allowlists before execution.

  3. Reject undeclared arguments by default. This prevents unexpected input from reaching command construction or Python function calls.

  4. Avoid treating shell escaping as the primary defense. Utilities such as shlex.quote() are fragile when templates contain complex shell syntax; direct process execution with separate arguments is safer.

  5. If shell features are genuinely required, isolate those tools behind dedicated, fixed wrapper programs. Do not interpolate untrusted values into shell source. Apply strict allowlists and require explicit administrative approval for dangerous operations.

  6. Run the dispatcher under a dedicated least-privileged account, provide only the necessary filesystem and network access, and avoid exposing secrets through its environment.

  7. Add regression tests containing command separators, substitutions, pipes, redirections, newlines, and quoted payloads to verify that argument values remain literal data and cannot create additional commands.

Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • 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 (18)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The description claims 'safe' registered-tool dispatch, but the analyzed behavior includes shell=True command execution and dynamic Python import/execution, which are materially more powerful than described. This mismatch is dangerous because operators may trust the skill as a constrained orchestrator when it can actually execute arbitrary logic through registry-controlled commands or imports.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The description claims 'safe' registered-tool dispatch, but the analyzed behavior includes shell=True command execution and dynamic Python import/execution, which are materially more powerful than described. This mismatch is dangerous because operators may trust the skill as a constrained orchestrator when it can actually execute arbitrary logic through registry-controlled commands or imports.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The description claims 'safe' registered-tool dispatch, but the analyzed behavior includes shell=True command execution and dynamic Python import/execution, which are materially more powerful than described. This mismatch is dangerous because operators may trust the skill as a constrained orchestrator when it can actually execute arbitrary logic through registry-controlled commands or imports.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module claims schema validation and safe execution, but the implementation only checks presence of required fields before performing shell or Python execution. This mismatch can cause integrators to trust the component more than warranted, leading to unsafe deployment of a dispatcher that does not actually enforce schemas or safety constraints.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

This skill is described as a function-calling and schema orchestration helper, yet it includes a generic shell-command execution backend. In this context, arbitrary command execution is far more dangerous because it gives an LLM-facing tool dispatcher direct OS-level execution capability, enabling system compromise if the registry or arguments are influenced.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
99% confidence
Finding

This is a direct tool-parameter abuse issue: tool arguments are inserted into a command template and sent to a shell. In an agent environment, natural-language-driven parameters can be attacker-influenced, so this creates a straightforward path from prompt input to arbitrary OS command execution.

Content

Scanner excerpt · scripts/dispatch.py (reported line 32)May include surrounding context.

python
t = entry.get("type", "command")
    if t == "command":
        cmd = entry["cmd"].format(**args)
        r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
        return r.returncode == 0, (r.stdout or r.stderr).strip()
    if t == "python":
        mod = __import__(entry["module"])

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

This file implements a generic cross-skill learning/telemetry component that persists usage history, errors, notes, and preferences for arbitrary skills, which is materially broader than the declared purpose of a tool-calling/dispatch helper. In an agent ecosystem, undocumented persistence and cross-skill state collection expand the data-access surface and can enable covert retention of user activity or sensitive operational context without a clear need-to-know boundary.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill advertises and appears to rely on shell and file-writing capabilities, but it declares no explicit tool scope or permission boundary. In an agent setting, missing permission metadata increases the chance that the skill is invoked with overly broad authority, making accidental or unsafe command execution harder to constrain and audit.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The activation text uses broad trigger phrases around tools, function calling, dispatch, and registration, which can cause the skill to activate in many loosely related contexts. Because this skill is associated with execution-oriented capabilities, overbroad matching raises the risk of unnecessary invocation, unintended tool exposure, or unsafe automation in conversations that did not require this powerful skill.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
99% confidence
Finding

The dispatcher builds a shell command by interpolating user-controlled arguments into a template and executes it with shell=True. Minimal validation only checks for required fields, so an attacker can inject shell metacharacters through arguments or exploit an overly permissive registry entry to achieve arbitrary command execution.

Content

Scanner excerpt · scripts/dispatch.py (reported line 32)May include surrounding context.

python
t = entry.get("type", "command")
    if t == "command":
        cmd = entry["cmd"].format(**args)
        r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
        return r.returncode == 0, (r.stdout or r.stderr).strip()
    if t == "python":
        mod = __import__(entry["module"])

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This code executes registry-defined commands via subprocess.run with shell=True, which is a safety-relevant operation for a code file. Although the module prints results afterward, there is no prior confirmation, warning comment/docstring about shell execution risk, or other user disclosure near the operation itself.

Content

No source excerpt is available for this finding.

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
89% confidence
Finding

Dynamic import allows the registry to select which Python module is loaded at runtime, turning the registry into a code-execution control plane. In an agent tool-dispatch context, this is dangerous because any attacker who can influence the registry or tool definition can cause execution of unintended modules with full interpreter privileges.

Content

Scanner excerpt · scripts/dispatch.py (reported line 35)May include surrounding context.

python
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
        return r.returncode == 0, (r.stdout or r.stderr).strip()
    if t == "python":
        mod = __import__(entry["module"])
        fn = getattr(mod, entry["func"])
        res = fn(**args)
        return True, str(res)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The dispatcher imports a module and invokes a function based on registry data, which can trigger arbitrary code execution within the registered tool set. For code files, this kind of execution should have some visible disclosure or warning, but the file provides no explicit user-facing notice about running registered Python functions.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This Python file contains its primary docstring, CLI description, comments, and user-facing output entirely in Chinese, which imposes a specific language/locale on users. The file does not offer any language selection, fallback, or justification that this skill is intended only for a Chinese-speaking or region-specific environment.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The code records persistent telemetry and preferences to learned_patterns.json, including capability names, success/failure, error types, notes, and arbitrary key/value preferences. In the context of a tool-orchestration skill, this collection is unnecessary to core function-calling behavior and increases privacy and security risk because free-form notes and preferences may capture sensitive prompts, tool outputs, or user-specific data that then persist on disk.

Content

No source excerpt is available for this finding.

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
86% confidence
Finding

Using getattr with a registry-supplied function name permits invocation of arbitrary attributes from the imported module, not just intended safe entry points. Combined with dynamic import, this broadens the attack surface to arbitrary callable execution and bypasses any meaningful tool boundary.

Content

Scanner excerpt · scripts/dispatch.py (reported line 36)May include surrounding context.

python
return r.returncode == 0, (r.stdout or r.stderr).strip()
    if t == "python":
        mod = __import__(entry["module"])
        fn = getattr(mod, entry["func"])
        res = fn(**args)
        return True, str(res)
    return False, f"未知工具类型: {t}"

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

This code writes JSON output to a user-specified path, which is a file-modifying operation covered by the code-file warning criteria. The write is not preceded by a warning or confirmation, and the surrounding help text does not explicitly disclose that an existing file may be overwritten.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring and usage text are written entirely in Chinese, and the argparse description at runtime also uses Chinese-only text. For a general-purpose schema conversion script, this imposes a specific language/locale without user opt-in or documented justification, which matches the natural-language policy violation criteria.

Content

No source excerpt is available for this finding.