T09 · Insecure Skill Coding Practices
- Location
scripts/website_screenshot.py:37- Finding
Unrestricted Browser Navigation Enables Server-Side Request Forgery
- Content
View full analysis
Vulnerability Details
File Location:
scripts/website_screenshot.py, lines 37-38, 65-89, and 94-109
Vulnerability Type: Server-Side Request Forgery through unrestricted URL navigation
Risk Level: HighVulnerable Code
python if not url.startswith(('http://', 'https://')): url = 'https://' + url result = self._capture_with_playwright( url, output_path, full_page, width or self.default_width, height or self.default_height, delay )python def _capture_with_playwright(self, url: str, output_path: str, full_page: bool, width: int, height: int, delay: int) -> bool: """Use Playwright to capture a screenshot.""" try: from playwright.sync_api import sync_playwright with sync_playwright() as p: browser = p.chromium.launch() page = browser.new_page(viewport={"width": width, "height": height}) page.goto(url, wait_until="networkidle") if delay > 0: time.sleep(delay) if full_page: page.screenshot(path=output_path, full_page=True) else: page.screenshot(path=output_path) browser.close() return True except ImportError: return self._capture_with_selenium( url, output_path, full_page, width, height, delay ) except Exception as e: print(f"Playwright error: {e}") return Falsepython def _capture_with_selenium(self, url: str, output_path: str, full_page: bool, width: int, height: int, delay: int) -> bool: try: from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service chrome_options = Options() chrome_options.add_argument("--he ...[truncated 2634 chars]- Remediation
View remediation
Remediation Suggestions
- Permit only explicitly supported schemes, normally HTTPS and optionally HTTP.
- Parse the URL and reject malformed URLs, embedded credentials, unexpected ports, and missing hostnames.
- Resolve the hostname before navigation and reject every address in loopback, private, link-local, multicast, reserved, and unspecified ranges for both IPv4 and IPv6.
- Explicitly block cloud metadata destinations, including link-local metadata addresses and provider-specific metadata hostnames.
- Revalidate the destination after DNS resolution and at every redirect. Do not rely solely on validation of the initial URL.
- Prefer an explicit domain allowlist when the expected screenshot targets are known.
- Apply network-level egress controls to the browser container so that validation bypasses cannot reach internal networks.
- Run browser workloads in an isolated, unprivileged container with no access to sensitive host services.
- Add tests for loopback addresses, private IPv4 and IPv6 addresses, alternate IP representations, DNS rebinding, link-local addresses, and public-to-private redirects.
