T09 · Insecure Skill Coding Practices
- Location
scripts/image_generator.py:297- Finding
Unescaped Repository URL Enables SVG/XML Injection During Cover Generation
- Content
View full analysis
{github_url} ``` The generated SVG is then processed by one of several renderers: ```python cairosvg.svg2png( url=svg_path, write_to=output_path, output_width=COVER_WIDTH, output_height=COVER_HEIGHT ) ``` ```python result = subprocess.run( ['convert', '-background', 'none', svg_path, '-resize', f'{COVER_WIDTH}x{COVER_HEIGHT}!', '-density', '150', output_path], capture_output=True, text=True, timeout=30, env=env ) ``` ```python result = subprocess.run( ['inkscape', svg_path, '--export-type=png', f'--export-filename={output_path}', f'--export-width={COVER_WIDTH}', f'--export-height={COVER_HEIGHT}', '--export-dpi=150'], capture_output=True, text=True, timeout=30 ) ``` ### Technical Analysis The `github_url` value originates from the user-supplied command-line URL and is retained as `repo_data['url']`. Unlike ...[truncated 2728 chars]- Remediation
View remediation
/ github.com// / ``` Reject query strings, fragments, control characters, XML metacharacters, credentials, and unexpected trailing path components. 4. Use a standard URL parser rather than permissive regular expressions. Validate the hostname exactly as `github.com`. 5. Configure SVG renderers to prohibit: - External network resources. - Local-file references. - Script execution. - Unsafe XML entities. - Unbounded filters, dimensions, and resource consumption. 6. Run image conversion in a sandbox with: - No network access. - A restricted temporary directory. - CPU, memory, file-size, and execution-time limits. - No access to sensitive home-directory files. 7. Add regression tests containing XML metacharacters and attempted element injection in every repository field. ]]>
