T09 · Insecure Skill Coding Practices
- Location
scripts/monitor.py:47- Finding
Unrestricted URL Fetching Enables SSRF and Local Resource Disclosure
- Content
View full analysis
str: req_headers = {"User-Agent": USER_AGENT} if headers: req_headers.update(headers) req = Request(url, headers=req_headers) try: with urlopen(req, timeout=30) as resp: charset = resp.headers.get_content_charset() or 'utf-8' return resp.read().decode(charset, errors='replace') ``` The URL is supplied without validation: ```python p.add_argument("--url", required=True) ``` Additional URLs are also stored without validation: ```python def cmd_add_url(args): config = load_monitor(args.event) config["urls"].append({"url": args.url, "label": args.label or args.url}) save_monitor(config) print(f"✅ Added URL to '{args.event}'") ``` ### Technical Analysis The monitor passes a user-controlled URL directly to `urllib.request.Request` and `urlopen`. It does not restrict the scheme to HTTP or HTTPS, resolve and validate the destination address, block loopback or private address ranges, or validate redirect destinations. Consequently, a crafted monitor can request resources that are not intended to be exposed through the web-monitoring feature. Depending on the URL handlers and network environment available to the process, targets may include: - Local files through a supported local-file URL scheme. - Services listening on loopback interfaces. - Private or link-local network services. - Cloud instance metadata endpoints. - Internal HTTP applications inaccessible to the external attacker. The fetched response is subsequently printed by `cmd_fetch`, included in JSON output, passed to an LLM agent, or written into reports. This creates ...[truncated 1451 chars]- Remediation
View remediation
