T09 · Insecure Skill Coding Practices
- Location
scripts/md2pdf.js:94- Finding
Unsanitized Markdown HTML Executes in a Chrome Process with Sandbox Disabled
- Content
View full analysis
${escapeHtml(inputName)} ${pageCss} ${baseCss} ${extraCss} ${bodyHtml} `; ``` ```javascript // scripts/md2pdf.js:142-155 const chrome = findChrome(); // Default to no header/footer for clean preview export const pdfArgs = [ "--headless=new", "--disable-gpu", "--no-sandbox", "--run-all-compositor-stages-before-draw", "--virtual-time-budget=2000", "--print-to-pdf=" + outPath, "--no-pdf-header-footer", ]; pdfArgs.push("file://" + tmpHtml); try { execFileSync(chrome, pdfArgs, { stdio: ["ignore", "ignore", "pipe"], timeout: 60000 }); ``` The vendored Marked renderer passes raw HTML through unchanged: ```javascript // assets/marked.min.js:6 html(e,t){return e} ``` ### Technical Analysis The Markdown input is treated as untrusted text when read, but its trust level changes incorrectly after parsing. Marked permits embedded raw HTML and its default renderer returns HTML tokens without sanitization. The resulting `bodyHtml` is inserted directly into a complete HTML document. Consequently, Markdown can introduce active elements including `- Remediation
View remediation
``` The exact policy should be tested against the supported offline rendering features. 4. **Remove `--no-sandbox`.** - Run Chrome with its normal sandbox enabled. - If the environment cannot support sandboxed Chrome, fail with actionable setup guidance rather than silently removing the protection. - Consider running conversion in an additional operating-system sandbox or isolated container with no network access and a read-only filesystem. 5. **Restrict resource URLs.** - Permit only validated local files and explicitly supported `data:` resources. - Reject HTTP, HTTPS, FTP, `javascript:`, and other unnecessary schemes. - Resolve and validate local paths before use. 6. **Use a dedicated ephemeral Chrome profile.** - Supply a private temporary `--user-data-dir`. - Ensure it contains no user cookies, credentials, extensions, or existing browser state. - Delete it reliably after conversion. ]]>
