T09 · Insecure Skill Coding Practices
- Location
scripts/screenshot_capture.py:37- Finding
Unrestricted Browser Navigation Enables Server-Side Request Forgery
- Content
View full analysis
Vulnerability Details
File Location:
scripts/screenshot_capture.py, lines 37–45; unsafe navigation occurs at lines 21–23
Vulnerability Type: Server-Side Request Forgery (SSRF) through untrusted RSS links
Risk Level: MediumVulnerable Code
python def capture(url: str, out_path: str) -> str | None: try: from playwright.sync_api import sync_playwright except ImportError: print(" ⚠ playwright not installed, skipping screenshots", file=sys.stderr) return None with sync_playwright() as p: browser = p.chromium.launch(headless=True) page = browser.new_page(viewport={"width": 1920, "height": 1080}) try: page.goto(url, timeout=20000, wait_until="domcontentloaded") page.wait_for_timeout(2000) page.screenshot(path=out_path, full_page=True) print(f" ✓ {out_path}") return out_path except Exception as e: print(f" ✗ {url}: {e}", file=sys.stderr) return None finally: browser.close() def run(launches: list) -> list: os.makedirs(SCREENSHOT_DIR, exist_ok=True) results = [] for i, item in enumerate(launches): url = item.get("link", "") if not url or not url.startswith("http"): continue print(f" [{i+1}/{len(launches)}] Capturing: {url[:70]}") parsed = urlparse(url) fname = f"{parsed.netloc.replace('.','_')}_{int(time.time())}.png" out_path = os.path.join(SCREENSHOT_DIR, fname) path = capture(url, out_path)Technical Analysis
RSS entry links are remotely supplied input. The implementation only tests whether a link begins with the characters
http, then passes it directly to Playwright'spage.goto()method.It does not strictly allow only HTTP and HTTPS schemes, validate the resolved destination address, restrict destination ports, or reject loopback, private, link-local, reserved, and ...[truncated 1994 chars]
- Remediation
View remediation
Remediation Suggestions
- Parse URLs with
urllib.parse.urlsplit()and accept only exacthttpandhttpsschemes. - Require a nonempty hostname and reject malformed URLs, embedded credentials, unexpected ports, and ambiguous numeric host representations.
- Resolve the hostname before navigation and reject every IPv4 and IPv6 address classified as loopback, private, link-local, multicast, reserved, unspecified, or otherwise non-global.
- Explicitly deny known metadata destinations, including link-local metadata addresses and provider-specific metadata hostnames.
- Revalidate every redirect target rather than validating only the initial URL.
- Configure Playwright request interception so document, frame, script, image, stylesheet, and other subresource requests are blocked when their resolved destinations are unsafe.
- Prefer an allowlist of expected public domains when the monitored feed set is controlled.
- Run the browser in a sandboxed environment with outbound network policy that denies private and metadata ranges. Network-level egress restrictions should supplement application validation.
- Keep screenshot capture opt-in or use
--skip-screenshotuntil destination validation is implemented. - Add tests covering loopback, RFC 1918, IPv6 local addresses, DNS rebinding, redirects to private addresses, alternate IP representations, and malicious subresources.
- Parse URLs with
