T09 · Insecure Skill Coding Practices
- Location
SKILL.md:188- Finding
Documentation Encourages Arbitrary Code Execution Through eval()
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:188-196
Vulnerability Type: Unsafe evaluation of potentially LLM-controlled input
Risk Level: HighVulnerable Code
python tool = Tool( name="calculate", description="Perform mathematical calculation", parameters={ "type": "object", "properties": { "expression": {"type": "string"} }, "required": ["expression"] }, handler=lambda expr: eval(expr) # optional )Technical Analysis
The documented tool handler passes its
exprargument directly to Python'seval()function. Tool arguments commonly originate from an LLM response and therefore must be treated as untrusted input.eval()does not restrict input to arithmetic. It can evaluate Python expressions that import modules, access application objects, read files, or invoke operating-system functionality. The registry's validation only confirms thatexpressionis a string; it does not inspect or constrain the content of that string.This code is documentation rather than an automatically registered handler in the reviewed implementation. Exploitation therefore depends on a user adopting the example. Nevertheless, it presents an unsafe integration pattern as part of the Skill's API documentation.
Attack Path
- A developer follows the documented example and registers the
calculatetool. - An attacker influences an LLM prompt or tool call and supplies a malicious Python expression as
expression. ToolRegistry.validate_call()accepts the value because it is a string.ToolRegistry.execute()invokes the registered handler with the supplied expression.- The handler calls
eval(expr). - The expression executes with the privileges and environment access of the Agent process.
Impact Assessment
Successful exploitation can result in arbitrary Python code execution within the hosting pro ...[truncated 342 chars]
- A developer follows the documented example and registers the
- Remediation
View remediation
Remediation Suggestions
- Remove the
eval()example from the documentation. - For arithmetic expressions, use a dedicated expression parser that cannot access Python names, attributes, imports, function calls, or application objects.
- If implementing an AST-based evaluator, explicitly allow only numeric constants and required arithmetic operators. Reject every node type not on the allowlist.
- Apply input length, nesting-depth, and computational-complexity limits to prevent resource-exhaustion attacks.
- Add tests proving that imports, attribute traversal, function calls, comprehensions, and excessively complex expressions are rejected.
- Run tool handlers in a sandbox with minimal filesystem, credential, process, and network access as a defense-in-depth measure.
- Remove the
