T09 · Insecure Skill Coding Practices
- Location
SKILL.md:1733- Finding
Unrestricted eval Enables Arbitrary Python Code Execution
- Content
View full analysis
- Remediation
View remediation
256: raise ValueError("Expression is too long") tree = ast.parse(expression, mode="eval") def evaluate(node): if isinstance(node, ast.Expression): return evaluate(node.body) if isinstance(node, ast.Constant) and type(node.value) in (int, float): return node.value if isinstance(node, ast.BinOp) and type(node.op) in _ALLOWED_BINARY_OPERATORS: return _ALLOWED_BINARY_OPERATORS[type(node.op)]( evaluate(node.left), evaluate(node.right), ) if isinstance(node, ast.UnaryOp) and type(node.op) in _ALLOWED_UNARY_OPERATORS: return _ALLOWED_U ...[truncated 253 chars]
