T09 · Insecure Skill Coding Practices
- Location
deploy-pilot.py:312- Finding
Arbitrary Command Execution Through Configurable Health Checks and Deployment Hooks
- Content
View full analysis
dict: """Execute custom script for health check.""" script = check.get("script", "") try: result = subprocess.run( script, shell=True, capture_output=True, text=True, timeout=check.get("timeout", 30) ) ok = result.returncode == 0 ``` ```python # Pre-deploy hooks for hook in stack.get("hooks", {}).get("pre", []): print(f"{Colors.status_wait()} Running pre-hook: {hook}") try: subprocess.run(hook, shell=True, check=True) print(f"{Colors.status_ok()} Pre-hook completed") except subprocess.CalledProcessError as e: print(f"{Colors.status_fail()} Pre-hook failed: {e}") return False ``` ```python # Post-deploy hooks if success: for hook in stack.get("hooks", {}).get("post", []): print(f"{Colors.status_wait()} Running post-hook: {hook}") try: subprocess.run(hook, shell=True, check=True) print(f"{Colors.status_ok()} Post-hook completed") except subprocess.CalledProcessError as e: print(f"{Colors.status_fail()} Post-hook failed: {e}") ``` ### Technical Analysis Health-check scripts and pre/post-deployment hooks are obtained from mutable stack configuration and passed directly to `subprocess.run()` with `shell=True`. The shell interprets command separators, substitutions, pipelines, redirections, environment expansion, and other shell syntax. No command allowlist, executable-path validation, argument separation, file ownership verification, or trust-boundary check is applied before execution. Consequently, a malicious configuration value is treated as exe ...[truncated 1512 chars]- Remediation
View remediation
