T09 · Insecure Skill Coding Practices
- Location
scripts/analyzer.py:138- Finding
Arbitrary Code Execution Through User-Controlled Suggestion Rule Conditions
- Content
View full analysis
- Remediation
View remediation
= right, "gt": lambda left, right: left > right, } ``` 3. Allow only the documented metrics: - `pass_rate` - `duration_ms` - `failure_count` - `regression_detected` 4. Validate the entire rules document against a strict schema before processing it. Reject: - Unknown fields. - Unsupported operators. - Incorrect value types. - Missing required fields. - Invalid priority values. - Excessively long strings or rule collections. 5. If expression syntax must be retained, parse it with `ast.parse()` and permit only a narrowly defined set of nodes, such as names, constants, Boolean operators, and comparison operators. Reject calls, attributes, subscripts, comprehensions, lambdas, imports, and all other executable constructs. Structured rules remain the safer design. 6. Replace the broad `except Exception: pass` behavior with explicit validation errors and safe logging so malformed or rejected conditions remain observable. 7. Treat custom rule files as untrusted input. Apply file ownership and integrity controls when rules are used in automated or privileged workflows. 8. Add regression tests proving that expressions containing function calls, imports, attribute access, and other executable syntax are rejected without side effects. ]]>
