T09 · Insecure Skill Coding Practices
- Location
scripts/loop.py:40- Finding
Unrestricted Shell Command Execution Through the Evaluation Argument
- Content
View full analysis
Vulnerability Details
File Location:
scripts/loop.py, lines 40-50 and line 229
Vulnerability Type: OS command injection through an unrestricted shell command
Risk Level: HighVulnerable Code
python def run_eval(eval_cmd: str) -> float: """Run the evaluation command and parse SCORE from output.""" try: result = subprocess.run( eval_cmd, shell=True, capture_output=True, text=True, timeout=300, # 5 min timeout per eval )The command is obtained directly from a command-line argument:
python parser.add_argument("--eval", required=True, help="Eval command (must print 'SCORE: <float>')")Technical Analysis
The
--evalvalue is passed as a string tosubprocess.run()withshell=True. The operating system shell therefore interprets shell operators, command substitutions, redirections, pipelines, and environment-variable expansions contained in that value.No validation, executable allowlist, argument separation, confirmation, or sandbox is applied before execution. Consequently, an evaluation command obtained from an untrusted project, copied from untrusted instructions, or supplied by a malicious operator can append arbitrary commands to an otherwise legitimate evaluator invocation.
The timeout limits execution duration but does not prevent a payload from performing immediate actions or spawning detached processes.
Attack Path
- An attacker supplies or recommends a project-specific evaluation command containing shell syntax and a malicious payload.
- A user or Agent invokes
loop.pywith the command through--eval. main()passes the unmodified string intorun_loop()and thenrun_eval().run_eval()invokes the command withshell=True.- The shell interprets the injected operators and executes the payload during the baseline evaluation.
- If t ...[truncated 1003 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove
shell=Trueand execute an argument list withshell=False. - Replace the free-form
--evalstring with a repeatable argument interface or a configuration containing a validated executable and separate arguments. - Restrict evaluator executables to an explicit allowlist or require confirmation before running an unrecognized executable.
- Resolve and validate evaluator paths, rejecting unexpected executable locations.
- Run evaluators in a sandbox or container with:
- A read-only project mount where possible.
- Access only to required files.
- No inherited secrets or unnecessary environment variables.
- Disabled or restricted networking.
- CPU, memory, process, and execution-time limits.
- Clearly warn users that evaluation code is executable and must be reviewed before use.
- If shell syntax is an unavoidable product requirement, require explicit opt-in and display the exact command for confirmation before every execution.
- Remove
