T09 · Insecure Skill Coding Practices
- Location
scripts/clip_webpage.py:50- Finding
Arbitrary URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
Vulnerability Details
File Location:
scripts/clip_webpage.py, lines 50–51, with attacker-controlled input entering through lines 215 and 220
Vulnerability Type: Server-Side Request Forgery (SSRF)
Risk Level: Highpython resp = requests.get(url, headers=headers, timeout=30) resp.raise_for_status()The request target originates directly from a command-line argument:
python parser.add_argument('url', help='要剪藏的网页URL') ... data = extract_content(args.url)Technical Analysis
The application sends an HTTP request to an arbitrary user-supplied URL without validating its scheme, hostname, resolved IP address, port, or redirect destinations. The
requestslibrary follows redirects by default, so validating only the initial URL would also be insufficient.An attacker can provide URLs targeting loopback interfaces, private network ranges, link-local services, IPv6 local addresses, or cloud instance metadata endpoints. DNS rebinding and redirects can also be used to bypass simplistic hostname checks. The response is processed as a webpage, partially printed to standard output, and may be written to a local Markdown file.
No response-size limit is applied beyond the 30-second timeout, which can additionally expose the process to excessive memory consumption when a remote endpoint returns a very large response.
Attack Path
- The attacker supplies a URL such as a loopback address, a private-network service, or a cloud metadata endpoint.
- The command-line value is passed unchanged from
args.urltoextract_content(). requests.get()initiates the request from the host running the Skill.- If the target redirects, the library follows the redirect without validating the new destination.
- The response content is parsed by Readability and BeautifulSoup.
- Extracted internal content is displayed in the excerpt or persisted to a Markdown file, allowing the attacker or caller ...[truncated 645 chars]
- Remediation
View remediation
Remediation Suggestions
- Parse URLs before making requests and permit only explicitly supported
httpandhttpsschemes. - Reject URLs containing embedded credentials, malformed hostnames, or unsupported ports.
- Resolve the destination hostname and reject every address in loopback, private, link-local, multicast, reserved, unspecified, and carrier-grade NAT ranges for both IPv4 and IPv6.
- Either disable redirects with
allow_redirects=Falseor manually process each redirect and repeat complete URL and resolved-address validation before following it. - Consider using an explicit hostname allowlist when the operational use case permits it.
- Route outbound requests through a restricted proxy or network policy that cannot reach internal services or metadata endpoints.
- Stream responses and enforce a conservative maximum response size and content type.
- Revalidate the connected destination to mitigate DNS rebinding and time-of-check/time-of-use discrepancies.
- Parse URLs before making requests and permit only explicitly supported
