T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_status.py:25- Finding
Arbitrary URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
Dict[str, Any]: with request.urlopen(url, timeout=timeout) as resp: # noqa: S310 (trusted URL) return json.load(resp) ``` ```python parser.add_argument("--url", default=API_URL, help="API URL (default: %(default)s)") ``` ```python data = fetch_status(args.url, args.timeout) ``` ### Technical Analysis The command-line `--url` argument is passed directly to `urllib.request.urlopen()` without validating its scheme, host, port, resolved IP address, or path. The accompanying `# noqa` comment describes the URL as trusted, but the URL is caller-controlled. The Skill's declared functionality only requires access to the fixed official endpoint: ```text https://cms.tablemountain.net/admin/actions/submissions/default/weather-api ``` Permitting arbitrary URLs exceeds the minimum network privileges required for that functionality. Depending on the schemes supported by the runtime and the host's network access, a caller may direct the script to internal HTTP services, loopback interfaces, link-local services, cloud metadata endpoints, or local resources. Redirects can also undermine a superficial validation check unless every redirect destination is independently verified. The response must contain valid JSON for `json.load()` to succeed. Furthermore, normal output only exposes the predefined status fields. These constraints reduce exploitability but do not eliminate the SSRF primitive. ### Attack Path 1. An attacker influences instructions or arguments supplied to the Skill. 2. The attacker causes the agent to invoke the script with an attacker-selected URL, for example an internal JSON endpoint: ```bash python3 scripts/fetch_status.py \ --url htt ...[truncated 1058 chars]- Remediation
View remediation
