T09 · Insecure Skill Coding Practices
- Location
SKILL.md:97- Finding
Unsanitized Markdown HTML May Execute Active Content in the Browser Renderer
- Content
View full analysis
{{CARDS_HTML}} ``` `references/browser-screenshot-spec.md:12-19` requires that the resulting document be loaded in a headless browser: ```markdown ## 2) Browser Context - Launch browser in headless mode. - Create context with: - `viewport = { width: viewport_width, height: viewport_height }` - `deviceScaleFactor = export_scale` - Keep default zoom (100%). - Do not use print/PDF rendering mode. ``` No corresponding requirement for HTML sanitization, JavaScript disabling, Content Security Policy enforcement, or browser request filtering is specified. ### Technical Analysis The skill instructs implementations to process attacker-controllable Markdown using the `md_in_html` extension and then inject rendered card HTML into a page opened by a headless browser. Raw HTML support can preserve active elements and attributes supplied through Markdown, depending on how the renderer constructs `CARDS_HTML`. Without a strict sanitization step, hostile input could contain constructs such as: - `- Remediation
View remediation
`, ``, `<object>`, `<embed>`, `<form>`, `<meta>`, `<link>`, and unneeded SVG/MathML content. - Remove all event-handler attributes, including attributes beginning with `on`. - Reject `javascript:`, `vbscript:`, and unsafe `data:` URLs. 2. **Disable raw HTML unless explicitly required** - Remove `md_in_html`. - Escape embedded HTML in Markdown by default. - If limited inline HTML is necessary, allow only explicitly documented, sanitized elements. 3. **Restrict browser network access** - Use Playwright request interception to deny all outbound requests by default. - Allow only resources that are necessary for rendering. - Block loopback, private, carrier-grade NAT, link-local, multicast, and metadata-service address ranges after DNS resolution. - Revalidate redirects and resolved addresses to prevent DNS rebinding and redirect-based bypasses. 4. **Harden the browser document** - Disable JavaScript if pagination and capture can operate without it; replace the font-readiness script with an implementation-side wait where feasible. - Otherwise, enforce a restrictive Content Security Policy such as `default-src 'none'`, with narrowly scoped exceptions for required local images and styles. - Use an isolated browser context without cookies, authentication state, extensions, or access to unrelated origins. - Keep the browser sandbox enabled and avoid unsafe launch flags such as `--no-sandbox`. 5. **Constrain resource consumption** - Add a maximum length for `markdown`, `title`, `author`, and `description`. - Enforce navigation, rendering, resource-download, and total-job timeouts. - Limit response sizes, image dimensions, DOM node counts, and concurrent rendering jobs. - ...[truncated 440 chars]
