T09 · Insecure Skill Coding Practices
- Location
scripts/detect_environment.py:899- Finding
Unrestricted Command Execution Through Probe Files
- Content
View full analysis
dict[str, Any]: if not path: return {} probe_path = Path(path) return json.loads(probe_path.read_text(encoding="utf-8-sig")) ``` ```python def run_checks(extra_probe_data: dict[str, Any], baseline_data: dict[str, Any] | None) -> dict[str, Any]: existing_checks = deepcopy((baseline_data or {}).get("checks", {})) if not extra_probe_data.get("checks"): return existing_checks for check in extra_probe_data["checks"]: command = check["command"] result = run_command(command, timeout=check.get("timeout", 8), cwd=check.get("cwd")) ``` JavaScript equivalent: ```javascript function loadProbeFile(pathname) { if (!pathname) return {}; return JSON.parse(readText(pathname)); } ``` ```javascript function runChecks(extraProbeData, baselineData) { const existingChecks = deepClone((baselineData || {}).checks || {}); if (!extraProbeData.checks) return existingChecks; for (const check of extraProbeData.checks) { const result = runCommand(check.command, { timeout: check.timeout == null ? 8 : check.timeout, cwd: check.cwd || null, }); ``` The documented command field explicitly permits direct execution: ```markdown - `command` - Command array executed exactly as provided. ``` ### Technical Analysis Probe files are parsed as JSON and then treated as trusted executable configuration. The `checks[].command`, `cwd`, and timeout fields are accepted without command allowlisting, path restrictions, a safety preview, or explici ...[truncated 2009 chars]- Remediation
View remediation
