T09 · Insecure Skill Coding Practices
- Location
install.sh:60- Finding
Arbitrary Python Code Injection Through the Installation Path
- Content
View full analysis
/dev/null; then python3 -c " import yaml import sys try: with open('$TARGET_DIR/$SKILL_NAME/SKILL.md', 'r', encoding='utf-8') as f: content = f.read() if content.startswith('---'): _, frontmatter, _ = content.split('---', 2) data = yaml.safe_load(frontmatter) print('📋 Skill 信息:') print(f' 名称: {data.get(\"name\", \"N/A\")}') print(f' 描述: {data.get(\"description\", \"N/A\")[:60]}...') print('') print('✅ Skill 格式验证通过') else: print('⚠️ SKILL.md 格式可能不正确') except Exception as e: print(f'⚠️ 验证警告: {e}') " else echo "⚠️ 未检测到 Python3,跳过格式验证" fi ``` ### Technical Analysis `TARGET_DIR` is derived directly from attacker-influenced command-line input. Although the shell variable is expanded inside a shell double-quoted string, its value is ultimately embedded inside a single-quoted Python string literal: ```python with open('$TARGET_DIR/$SKILL_NAME/SKILL.md', ...) ``` Shell quoting does not escape the value for the Python language. A target directory containing a single quote, newline, and crafted Python statements can terminate or restructure the Python string and insert arbitrary statements into the program passed to `python3 -c`. The preceding filesystem commands quote ` ...[truncated 2300 chars]- Remediation
View remediation
