T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/scraper-stealth.js:432
- Finding
- Unrestricted browser navigation permits access to private and local network resources## Vulnerability Details **File Location**: - `scripts/scraper-simple.js:82` - `scripts/scraper-stealth.js:432-441` - `scripts/scraper-stealth.js:461` - `scripts/scraper-batch.js:93-96` **Vulnerability Type**: Server-Side Request Forgery through unrestricted browser navigation **Risk Level**: Medium ### Vulnerable Code `scripts/scraper-simple.js:82`: ```js await page.goto(opts.url, { waitUntil: 'domcontentloaded', timeout: 30000 }); ``` `scripts/scraper-stealth.js:432-441`: ```js const context = await browser.newContext({ userAgent, viewport, locale: 'zh-CN', timezoneId: 'Asia/Shanghai', deviceScaleFactor: isMobile ? pick([2, 3]) : 1, isMobile, hasTouch: isMobile, javaScriptEnabled: true, ignoreHTTPSErrors: true, }); ``` `scripts/scraper-stealth.js:461`: ```js await page.goto(opts.url, { waitUntil: 'domcontentloaded', timeout: 60000 }); ``` `scripts/scraper-batch.js:93-96`: ```js const scriptName = opts.stealth ? 'scraper-stealth.js' : 'scraper-simple.js'; const scriptPath = path.join(__dirname, scriptName); const args = [scriptPath, url]; ``` ### Technical Analysis The scraper accepts user-provided URLs and passes them directly to Playwright without validating the URL scheme, hostname, embedded credentials, resolved IP address, or redirect destination. There are no controls preventing navigation to loopback, private, link-local, or cloud metadata addresses. Consequently, the browser may access services reachable from the execution host even when those services are not externally accessible. The page text, links, images, and metadata are then serialized into the scraper's JSON output. Redirects present an additional bypass because an initially public URL can redirect to a prohibited internal destination. Stealth mode further configures `ignoreHTTPSErrors: true`, disabling certificate validation for browser requests. This weakens transport security and a ...[truncated 1557 chars]
- Remediation
- ## Remediation Suggestions 1. Parse every supplied URL with the standard `URL` class and permit only explicitly supported schemes, normally `https:` and optionally `http:`. 2. Reject URLs containing embedded usernames or passwords. 3. Resolve the destination hostname before navigation and reject all loopback, private, link-local, multicast, unspecified, carrier-grade NAT, and reserved IPv4 and IPv6 ranges. 4. Revalidate the destination after every redirect. Use Playwright request interception or navigation event handling to block requests whose resolved destination violates the network policy. 5. Protect against DNS rebinding by validating each connection destination rather than validating only the initial hostname. 6. Block known metadata addresses and hostnames explicitly, including link-local metadata endpoints used by supported cloud platforms. 7. Prefer an explicit hostname allowlist when the set of legitimate targets is known. 8. Remove `ignoreHTTPSErrors: true`, or expose it only as an explicit high-risk option that is disabled by default. 9. Apply outbound firewall or sandbox rules to the browser process so code-level validation is not the only protection. 10. Add tests covering direct private addresses, IPv6 loopback, decimal or encoded IP forms, redirects to private destinations, and DNS rebinding behavior.
