T09 · Insecure Skill Coding Practices
- Location
scripts/monitor.py:123- Finding
Arbitrary URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
Optional[str]: """ Fetch page content using Playwright (Node.js subprocess). Returns HTML string or None on failure. """ import subprocess script = f""" const {{ chromium }} = require('playwright'); (async () => {{ const browser = await chromium.launch({{ headless: true }}); const page = await browser.newPage(); await page.setExtraHTTPHeaders({{}}); await page.setExtraHTTPHeaders({{ 'Accept-Language': 'zh-CN,zh;q=0.9' }}); await page.goto({json.dumps(url)}, {{ waitUntil: 'networkidle', timeout: {timeout_ms} }}); const content = await page.content(); await browser.close(); console.log(JSON.stringify({{ ok: true, content }})); }})().catch(e => {{ console.log(JSON.stringify({{ ok: false, error: e.message }})); process.exit(1); }}); """ try: result = subprocess.run( ["node", "-e", script], capture_output=True, text=True, timeout=30 ) if result.returncode != 0: return None data = json.loads(result.stdout.strip()) if data.get("ok"): return data["content"] except Exception: pass return None ``` The unrestricted URL is subsequently fetched by `check_task`: ```python # Fetch page html = fetch_page(task.url) if not html: return {"ok": False, "error": "Failed to fetch page"} ``` ### Technical Analysis The application accepts a user-controlled URL, stores it as a monitoring task, and passes it directly to Playwright's `page.goto()` method. No validation is performed on: - The URL scheme - Embedded credentials ...[truncated 2501 chars]- Remediation
View remediation
