T09 · Insecure Skill Coding Practices
- Location
scripts/generate.py:119- Finding
Unescaped Template Input Enables Server-Side Request Forgery Through Headless Chromium
- Content
View full analysis
...{args.left_label}{_chat_items(args.left_items)}VS{args.right_label}{_chat_items(args.right_items)}""", ``` ```python "tutorial": f""" ...{args.title}{args.subtitle}{args.title}{args.subtitle}{args.code_content or ''}{args.tagline or ''}""", ``` ```python def _chat_items(items_str): if not items_str: return "" items = [i.strip() for i in items_str.split("|") if i.strip()] return "\n".join(f'{item}' for item in items) ``` ```python if not success and mode in ("html", "auto"): print(f"Trying HTML engine (Chromium)...") html = get_template(args.template, args) out_dir = os.path.dirname(os.path.abspath(args.output)) or "." tmp_png = os.path.join(out_dir, "pf_html_tmp.png") if html_render(html, args.width, args.height, tmp_png): ``` ### Technical Analysis Multiple command-line values are interpolated directly into an HTML document without contextual HTML escaping. Affected values include the title, subtitle, tagline, labels, list items, and tutorial code content. Because these values are treated as markup rather than text, an attacker can inject active HTML elements such as `img`, `iframe`, `object`, or CSS res ...[truncated 2146 chars]- Remediation
View remediation
{escape(item, quote=True)}' for item in items ) ``` 3. Add a restrictive Content Security Policy to generated templates. For templates that require no external resources, use a policy similar to: ```html ``` 4. Render templates in an isolated environment without access to loopback, private networks, cloud metadata addresses, or the public Internet. 5. Disable unnecessary browser features and external resource loading. Where feasible, replace browser rendering with a renderer that does not support network-capable active content. 6. Add regression tests using payloads containing `img`, `iframe`, `object`, CSS `url()`, and closing tags, verifying that they appear as literal poster text and do not generate network requests. ]]>
