T09 · Insecure Skill Coding Practices
- Location
scripts/request_http.py:66- Finding
Unrestricted URL Requests Permit Server-Side Request Forgery
- Content
View full analysis
Vulnerability Details
File Location:
scripts/request_http.py, lines 66 and 91–99
Vulnerability Type: Server-Side Request Forgery (SSRF)
Risk Level: HighVulnerable Code
python parser.add_argument("--url", required=True)python response = requests.request( method=args.method.upper(), url=args.url, headers=headers, params=params, json=json_body, data=data_body, timeout=args.timeout, )Technical Analysis
The script accepts an arbitrary URL and passes it directly to
requests.request()without validating the URL scheme, destination hostname, resolved IP address, port, or redirect destination.Python Requests follows HTTP redirects by default. Consequently, validating only the initial URL would not be sufficient: an attacker-controlled public endpoint could redirect the request to a loopback, private-network, or link-local address.
The vulnerable behavior can permit requests to destinations such as:
- Loopback services accessible only from the execution environment
- RFC 1918 private-network services
- Link-local and cloud instance metadata services
- Internal administrative interfaces
- Services bound to otherwise inaccessible ports
The response status, final URL, and response body are printed to standard output, allowing information obtained through SSRF to be returned to the invoking agent or user.
Attack Path
- An attacker supplies or influences the
--urlargument used by the skill. - The URL directly references an internal address, or references an attacker-controlled public server that redirects to an internal address.
- The script calls
requests.request()without destination restrictions and follows redirects by default. - The HTTP request is sent using the network privileges of the environment running the skill.
- The internal service's response body is printed to standard output.
- The attacker may ...[truncated 697 chars]
- Remediation
View remediation
Remediation Suggestions
Implement centralized URL validation before every request:
- Allow only explicitly required schemes, normally
httpsand, where necessary,http. - Reject URLs containing embedded usernames or passwords.
- Resolve the hostname and reject every resolved loopback, private, link-local, multicast, unspecified, or reserved IP address.
- Consider an explicit hostname and port allowlist when the intended integrations are known.
- Disable redirects by default with
allow_redirects=False, or validate the destination of every redirect before following it. - Protect against DNS rebinding by connecting only to an address that has already been validated and by avoiding an unchecked second DNS resolution.
- Apply outbound firewall or proxy restrictions so the process cannot reach metadata services or sensitive internal networks.
- Require an explicit, prominently documented override for legitimate internal requests rather than permitting them by default.
- Add tests covering IPv4, IPv6, alternative IP representations, DNS aliases, embedded credentials, and redirect chains.
- Allow only explicitly required schemes, normally
