T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/export_pdf.js:109
- Finding
- Chromium Sandbox Disabled While Rendering User-Selectable HTML## Vulnerability Details **File Location**: `scripts/export_pdf.js`, lines 109–146 **Vulnerability Type**: Unsafe browser security configuration **Risk Level**: High ### Vulnerable Code ```javascript return puppeteer.launch({ headless: true, executablePath, args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'], }); ``` The resulting browser instance later loads a user-selectable HTML file: ```javascript const page = await browser.newPage(); await page.setViewport({ width: W, height: H, deviceScaleFactor: 2 }); const filePath = path.resolve(process.cwd(), HTML_FILE); await page.goto(`file://${filePath}`, { waitUntil: 'networkidle0' }); ``` ### Technical Analysis The exporter explicitly disables both principal Chromium sandbox mechanisms through `--no-sandbox` and `--disable-setuid-sandbox`. These flags are not required for the declared task of rendering HTML slides under a properly configured, unprivileged environment. The input path comes from `process.argv[2]`, allowing the user or an invoking process to select the HTML document rendered by Chromium. JavaScript remains enabled, and no request interception prevents the document from loading remote scripts, images, frames, or other resources. Although browser JavaScript does not inherently receive unrestricted filesystem access, disabling the Chromium sandbox removes an important containment boundary. If malicious HTML exercises a Chromium vulnerability, exploitation can occur with the operating-system privileges of the Node.js process rather than being constrained by the browser sandbox. ### Attack Path 1. An attacker supplies, modifies, or convinces a user to render a malicious HTML slide deck. 2. The user invokes `node export_pdf.js malicious.html`. 3. The script starts Chromium with its sandbox explicitly disabled. 4. Chromium loads the attacker-controlled document with JavaScript enabled. 5. The document may conta ...[truncated 829 chars]
- Remediation
- ## Remediation Suggestions 1. Remove `--no-sandbox` and `--disable-setuid-sandbox`. 2. Run Chromium as a dedicated, unprivileged user with a writable profile and functioning browser sandbox. 3. If the deployment environment cannot support Chromium sandboxing, run the exporter inside a hardened container or virtual machine with: - No sensitive host-directory mounts. - A read-only root filesystem where practical. - Dropped Linux capabilities. - Resource and process limits. - No host network access unless explicitly required. 4. Disable JavaScript with `page.setJavaScriptEnabled(false)` when generated decks do not require scripts. 5. Add request interception and allow only required `file:` resources. Block `http:`, `https:`, `ws:`, and `wss:` requests by default during PDF export. 6. Resolve and validate the HTML path against an explicitly permitted project directory. 7. Keep Chromium and Puppeteer pinned and promptly updated for browser security fixes.
