T09 · Insecure Skill Coding Practices
- Location
SKILL.md:149- Finding
Arbitrary Code Execution Through Unsafe Python Command Interpolation
- Content
View full analysis
'''); print(paths[0] if paths else 'NO_PATH_FOUND')" ``` ```bash python -c "import sys; sys.path.insert(0, r'{SKILL_DIR}/scripts'); from path_helper import validate_path; r = validate_path(r'<提取到的路径>'); print(f'Valid: {r[\"valid\"]}, Size: {r[\"size_mb\"]}MB' if r['valid'] else f'Error: {r[\"error\"]}')" ``` ```bash python -c "import sys; sys.path.insert(0, r'{SKILL_DIR}/scripts'); from compress_ppt_videos import run; run(r'<验证后的路径>')" ``` ```python python -c " import sys sys.path.insert(0, r'{SKILL_DIR}/scripts') from compress_ppt_videos import compress_pptx compress_pptx(r'') " ``` The path helper also generates an executable command by directly interpolating a validated path: ```python if result['valid']: print(f"可以使用以下命令压缩:") print(f'python -c "import sys; sys.path.insert(0, r\'{os.path.dirname(os.path.abspath(__file__))}\'); from compress_ppt_videos import run; run(r\'{result["normalized_path"]}\')"') ``` ### Technical Analysis The documented workflow embeds an entire user message or user-controlled file path directly into Python source passed to `python -c`. Python raw strings do not provide safe quoting or escaping. They only change how backslashes are interpreted inside a string literal. An attacker can include quote and delimiter sequences that terminate the intended string literal. For example, content containing `''')` can terminate the triple-quoted user-message literal. A valid Unix filename may also contain a single quote, which can terminate the `r'...'` literals used for p ...[truncated 1855 chars]- Remediation
View remediation
