Back to skill

Security audit

My Tools

Security checks for vulnerabilities and agentic risk

Overview

This skill is a small time-and-calculator tool, but its calculator executes user-provided expressions through Python eval and a documented shell command, which is too powerful for a calculator.

Review before installing. The time function is straightforward, but the calculator should be changed to a safe arithmetic parser before use, with strict allowed operators and limits on expression length, nesting, exponent size, and result size. Avoid using this skill on untrusted inputs in its current form.

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 (2)

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:19
Finding

Command and Python Code Injection Through the Documented Calculator Command

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 19-24
Vulnerability Type: User-controlled input embedded in shell and Python source code
Risk Level: Critical

Vulnerable Code:

markdown
## calculator
当用户要求计算数学表达式时,使用 `exec` 工具执行以下命令进行计算:

```powershell
py -c "print(eval('EXPRESSION'))"

将 EXPRESSION 替换为用户提供的表达式。

text

### Technical Analysis

The instructions require the Agent to replace `EXPRESSION` directly with a user-provided value inside a quoted `py -c` program. The input therefore crosses two unsafe interpretation boundaries:

1. The command shell parses the constructed command.
2. Python parses the interpolated value as executable source code.

No escaping, strict validation, argument separation, or arithmetic-only parsing is applied. A crafted expression containing quote characters and Python syntax can terminate the intended string passed to `eval`, append additional Python operations, and alter the remainder of the generated program. Depending on shell metacharacter handling, the same construction may also expose a shell-command injection boundary.

The use of `eval` compounds the issue because the calculator accepts executable Python syntax rather than a constrained mathematical grammar.

### Attack Path

1. An attacker submits a crafted value while presenting it as a mathematical expression.
2. The Agent follows `SKILL.md` and substitutes the value directly for `EXPRESSION`.
3. The resulting text is passed to the `exec` tool as a PowerShell command.
4. The crafted input escapes the intended Python string or otherwise changes the generated Python source.
5. The injected Python operations execute with the privileges and filesystem access of the Agent process.

### Impact Assessment

Successful exploitation can execute arbitrary Python operations with the Agent's effective operating-system privileges. This may permit reading or modifying accessible files, launching proce
...[truncated 246 chars]
Remediation
View remediation

Remediation Suggestions

  • Remove the dynamically constructed py -c command and do not interpolate user input into shell commands or Python source.
  • Route calculations through a dedicated implementation that parses an arithmetic grammar.
  • Use Python's ast.parse in expression mode and allow only explicitly approved nodes, such as numeric constants and selected unary and binary arithmetic operators.
  • Reject names, attribute access, function calls, comprehensions, indexing, containers, and all other non-arithmetic syntax.
  • Impose limits on input length, nesting depth, integer size, exponent size, and execution time to prevent resource exhaustion.
  • If a subprocess is unavoidable, pass arguments as a structured argument array without invoking a shell and provide the expression through a non-code data channel.
  • Update SKILL.md so it invokes only the hardened calculator implementation.

T09 · Insecure Skill Coding Practices

Error
Location
__init__.py:13
Finding

Unsafe Evaluation of User-Controlled Expressions in the Calculator Method

Content
View full analysis

Vulnerability Details

File Location: __init__.py, lines 13-19
Vulnerability Type: Unsafe use of eval with attacker-controlled input
Risk Level: High

Vulnerable Code:

python
def calculator(self, expression: str):
    """计算数学表达式"""
    try:
        result = eval(expression, {"__builtins__": {}}, {})
        return f"{expression} = {result}"
    except Exception as e:
        return f"计算失败:{str(e)}"

Technical Analysis

The calculator method passes the caller-controlled expression directly to Python's eval. Setting __builtins__ to an empty dictionary blocks straightforward access to built-in functions, but it does not convert Python expressions into a safe arithmetic language.

Python literals still expose their types and object inheritance metadata. Carefully constructed expressions may traverse Python's object model and locate useful classes or already-loaded runtime objects. Whether this can be escalated to operating-system command execution depends on the classes loaded in the hosting process, but the design is not a reliable security boundary.

Independently of sandbox escape, valid Python expressions can request computationally expensive arithmetic or construct very large values. Because there are no limits on expression length, nesting, exponentiation, integer size, memory consumption, or execution time, the method is susceptible to CPU and memory exhaustion.

Catching Exception only handles failures after evaluation has begun. It does not prevent malicious evaluation, and it cannot reliably protect the host from resource exhaustion or process termination.

Attack Path

  1. An attacker invokes the calculator with a crafted Python expression rather than ordinary arithmetic.
  2. The skill passes the expression unchanged to eval.
  3. The Python interpreter evaluates the attacker-selected syntax in the Agent process.
  4. The attacker attempts object-model traversal to r ...[truncated 674 chars]
Remediation
View remediation

Remediation Suggestions

  • Eliminate eval, even when built-ins are removed.
  • Parse the input with ast.parse(expression, mode="eval") and recursively validate every node against a strict allowlist.
  • Permit only numeric constants and explicitly required operators, such as addition, subtraction, multiplication, division, modulo, and carefully bounded exponentiation.
  • Reject function calls, identifiers, attributes, subscripts, collection literals, comprehensions, conditional expressions, and any unrecognized AST node.
  • Enforce strict limits on expression length, AST depth, numeric magnitude, exponent values, and result size.
  • Apply execution time and memory limits at the process boundary when calculations may involve untrusted users.
  • Return generic validation errors rather than exposing raw exception text from the runtime.
  • Add security tests covering object traversal attempts, malformed syntax, deeply nested expressions, huge integers, and oversized exponentiation.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (8)

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The calculator instruction uses py -c "print(eval('EXPRESSION'))", which evaluates arbitrary Python code rather than a restricted math expression. If user input is substituted directly, an attacker can execute system commands or access files through Python builtins, making this far more dangerous than a calculator feature.

Content

No source excerpt is available for this finding.

eval() call detected

High
Category
Dangerous Code Execution
Confidence
99% confidence
Finding

The calculator method evaluates user-supplied input with Python eval(), which allows execution of arbitrary Python expressions rather than only arithmetic. Although builtins is cleared, eval is still unsafe for untrusted input because attackers may abuse Python object semantics and implementation details to escape restrictions or trigger denial-of-service through expensive expressions.

Content

Scanner excerpt · __init__.py (reported line 16)May include surrounding context.

python
def calculator(self, expression: str):
        """计算数学表达式"""
        try:
            result = eval(expression, {"__builtins__": {}}, {})
            return f"{expression} = {result}"
        except Exception as e:
            return f"计算失败:{str(e)}"

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The advertised capability is a math calculator, but the implementation accepts arbitrary Python expressions, creating a dangerous mismatch between intended functionality and actual execution power. In an agent skill context, tool inputs may be influenced by users or other agent components, so this broad interpreter surface materially increases the chance of code execution or abuse.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The activation description includes broad phrases like asking about "日期" and uses "等" without defining clear boundaries. This makes it unclear when the skill should activate versus when a user is discussing dates more generally, increasing the chance of unintended invocation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill directs the agent to use shell execution for both time retrieval and calculation without disclosing that external command execution will occur. This increases risk because a seemingly harmless user request can trigger command execution, and in this skill one of those commands incorporates unsafe user-controlled input, compounding the danger.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This code contains natural-language user-facing text only in Chinese, including method docstrings and returned error/output messages. The file does not indicate that the skill is intentionally region-specific or provide any user opt-in for language/locale, which can violate language-choice policy requirements.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
72% confidence
Finding

The natural-language content of the skill is entirely in Chinese and the trigger phrases are specified only in Chinese, which implies a fixed language expectation without offering user choice. This can violate language or locale policy when no opt-in or justification is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The manifest description is written only in Chinese, which can impose a language expectation without offering user opt-in or documenting that the skill is intended for a Chinese-speaking or region-specific audience. This may conflict with organizational language/locale policy where skills should not force a specific language absent justification.

Content

No source excerpt is available for this finding.