T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/convert_svg.py:31
- Finding
- Unrestricted External Resource Resolution in Untrusted SVG Files<![CDATA[ ## Vulnerability Details **File Location**: `scripts/convert_svg.py:31-51` **Vulnerability Type**: Unrestricted processing of attacker-controlled SVG resources **Risk Level**: Medium ### Vulnerable Code ```python if args.format == "png": cairosvg.svg2png( url=args.input, write_to=args.output, output_width=args.width, output_height=args.height, dpi=args.dpi, ) else: import io from PIL import Image buf = io.BytesIO() cairosvg.svg2png( url=args.input, write_to=buf, output_width=args.width, output_height=args.height, dpi=args.dpi, ) buf.seek(0) img = Image.open(buf).convert("RGB") img.save(args.output, "JPEG", quality=95) ``` ### Technical Analysis The converter passes a caller-selected SVG file directly to `cairosvg.svg2png()` without first parsing the document and rejecting external resource references. SVG documents may contain references to resources identified by network URLs or local file URLs. If the installed CairoSVG version and its resource-loading configuration resolve such references, conversion can cause the process to access resources outside the input document. No application-level URL allowlist, scheme validation, network isolation, local-file restriction, input size limit, or rendering resource limit is applied. The documented workflow also tells the agent to convert user-provided SVG files directly and without confirmation, increasing exposure to untrusted documents. This issue does not provide arbitrary command execution by itself. Exploitability and the exact resources accessible depend on CairoSVG's resource-loading behavior, the operating environment, filesystem permissions, network connectivity, and the contents of the crafted SVG. ## ...[truncated 1277 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Treat every input SVG as untrusted. 2. Parse the SVG before rendering and reject references using `file:`, `http:`, `https:`, UNC paths, absolute paths, and other external schemes. 3. Permit only required inline content and, if necessary, carefully validated `data:` resources with strict media-type and size limits. 4. Configure a custom resource fetcher, where supported, that denies all external resource access by default. 5. Run conversion in an isolated worker with networking disabled and a minimal, read-only filesystem view containing only the input and output locations. 6. Execute the renderer as a dedicated unprivileged account with no access to credentials, home directories, cloud metadata, or internal administrative services. 7. Apply limits for input size, dimensions, DPI, processing time, memory, and output size. 8. Add security tests using SVG files that reference loopback URLs, private network ranges, cloud metadata addresses, and local files, verifying that conversion fails without making requests. ]]>
