T09 · Insecure Skill Coding Practices
- Location
scripts/agent.py:213- Finding
Default Auto Mode Fails Open to Unrestricted Shell Execution
- Content
View full analysis
ExecutionResult: command_str = command.strip() if not command_str: return ExecutionResult(False, "Command is empty", "") try: result = subprocess.run( command_str, shell=True, capture_output=True, text=True, timeout=30, encoding="utf-8", errors="replace", ) output = result.stdout or result.stderr or "(no output)" success = result.returncode == 0 return ExecutionResult(success, output, command_str) ``` ```python if actual_mode == "text": command = " ".join(remaining_args) result = execute_raw_command(command) print(result) return ``` ### Technical Analysis The configured default is `auto` mode. When the external `system-controller` directory, required scripts, or Python runtime cannot be validated, `determine_actual_mode()` switches from the restricted function interface to unrestricted text mode. Text mode concatenates all remaining command-line arguments into one string and passes that string to `subprocess.run()` with `shell=True`. Consequently, shell metacharacters, pipelines, redirections, command substitutions, and chained commands are interpreted directly by the operating-system shell. There is no executable allowlist, argument-level validation, sandbox, privilege reduction, or pol ...[truncated 1843 chars]- Remediation
View remediation
