T09 · Insecure Skill Coding Practices
- Location
scripts/itil-review.sh:90- Finding
Arbitrary Python Code Execution Through Crafted JSON Filenames
- Content
View full analysis
/dev/null || echo "unknown") CONSEC_ERRORS=$(python3 -c "import json; print(json.load(open('$job_file')).get('consecutiveErrors',0))" 2>/dev/null || echo "0") LAST_ERROR=$(python3 -c "import json; print(json.load(open('$job_file')).get('lastError','')[:120])" 2>/dev/null || echo "") ``` The same unsafe construction is used for coordination-task files: ```bash IS_ITIL=$(python3 -c " import json d = json.load(open('$task_file')) title = d.get('title','') status = d.get('status','') if 'ITIL' in title and status in ('open','in_progress','claimed'): print(f\"{status}: {title[:80]}\") else: print('') " 2>/dev/null || echo "") ``` ### Technical Analysis The variables `job_file` and `task_file` originate from filesystem glob results and are interpolated directly into Python programs supplied through `python3 -c`. Shell quoting protects these values only while the shell constructs the command; it does not safely encode them as Python string literals. A filename containing a single quote and suitable Python syntax can terminate the intended `open('...')` expression and inject additional Python statements. When the review script runs, the injected statements are interpreted by Python with the privileges of the user executing the script. The vulnerable directories are: - `~/.openclaw/cron/jobs` - `~/.skcapstone/coordination/tasks` The `.json` suffix requirement does not prevent exploitation because executable Python syntax can be embedded before the suffix. ### Attack Path 1. An attacker obtains the ability to create or rename a file in either monitored directory. 2. The attacker creates a `.json` file who ...[truncated 1239 chars]- Remediation
View remediation
