T09 · Insecure Skill Coding Practices
- Location
scripts/harden-skill.sh:13- Finding
Python Code Injection in the Hardening Workflow
- Content
View full analysis
}" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PROJECT_DIR="$(dirname "$SCRIPT_DIR")" # Find skill in catalog SKILL_INFO=$(python3 -c " import json with open('$PROJECT_DIR/data/skills.json') as f: catalog = json.load(f) for s in catalog['skills']: if s['name'] == '$SKILL_NAME': print(f'{s[\"author\"]}/{s[\"name\"]}') break else: print('NOT_FOUND') ") ``` ### Technical Analysis The shell argument `SKILL_NAME` is interpolated directly into a Python program passed to `python3 -c`. Shell quoting does not make this value safe inside Python source code. An attacker can include quote characters and additional Python syntax in the skill name, terminate the intended string literal, and cause arbitrary Python statements or expressions to run. This exceeds the minimum privileges required to look up a skill name. The script only needs to compare an input string with catalog entries; it does not need to generate executable Python source from that input. ### Attack Path 1. An attacker persuades an operator or automation system to invoke `harden-skill.sh` with a crafted skill name. 2. The crafted value closes the Python string literal in: ```python if s['name'] == '$SKILL_NAME': ``` 3. Additional attacker-controlled Python syntax is interpreted by `python3 -c`. 4. The payload executes with the operating-system privileges of the user running the review workflow. ### Impact Assessment Successful exploitation provides arbitrary local code execution as the review operator. The attacker could read or modify files accessible to that account, alter catalog data, tamper with reviews, access environment variables, or invoke available local commands. No privilege escalation be ...[truncated 150 chars]- Remediation
View remediation
