T09 · Insecure Skill Coding Practices
- Location
scripts/perform_doc_extraction.py:51- Finding
Unrestricted URL Fetching Enables SSRF and Internal Data Disclosure
- Content
View full analysis
Vulnerability Details
File Location:
scripts/perform_doc_extraction.py:51-54andscripts/perform_doc_extraction.py:155-159
Vulnerability Type: Server-Side Request Forgery and unintended data disclosure
Risk Level: HighVulnerable Code
python if filepath.startswith(("http://", "https://")): response = requests.get(filepath, timeout=10) response.raise_for_status() fields.append(("file", (name, response.content, response.headers.get("Content-Type", "application/octet-stream"))))python elif "file_url" in output_data: file_url = output_data["file_url"] print(f"Downloading result from: {file_url}", file=sys.stderr) doc_response = requests.get(file_url) doc_response.raise_for_status() final_text = doc_response.textTechnical Analysis
The script accepts an arbitrary HTTP or HTTPS URL through
--fileand retrieves it from the environment where the Skill runs. It does not validate the destination hostname, resolved IP address, port, redirect chain, response type, or response size.Consequently, the request can target loopback addresses, private network ranges, link-local services, cloud instance metadata endpoints, or internal administrative interfaces. Automatic redirects and DNS changes may also allow an initially public hostname to resolve or redirect to a prohibited internal address.
The content obtained through
--fileis subsequently inserted into the multipart request and uploaded to the external Gitee AI service. This turns the issue into both SSRF and potential internal-data exfiltration.The API-controlled
file_urlis also fetched without a host allowlist. That request has no explicit timeout or response-size limit, creating additional exposure to internal resource access and denial of service.Attack Path
- An attacker causes the Skill to run with a URL such as a loopback, private-network, link-local, metadata-service, or attacker-controlled redirect URL.
...[truncated 1059 chars]
- Remediation
View remediation
Remediation Suggestions
- Prefer accepting local document files only unless remote URL support is essential.
- If remote URLs are required, enforce an explicit allowlist of trusted HTTPS hosts.
- Resolve hostnames before connecting and reject loopback, private, link-local, multicast, reserved, and cloud metadata addresses.
- Disable redirects or validate the hostname and resolved address at every redirect hop.
- Restrict destination ports to those explicitly required.
- Protect against DNS rebinding by ensuring the validated address is the address used for the connection.
- Stream responses while enforcing a strict maximum size instead of reading the complete body into memory.
- Validate expected document MIME types and file signatures before uploading content.
- Configure explicit connection and read timeouts for every request.
- Require result URLs to use HTTPS and belong to documented Gitee AI result-delivery domains.
- Consider returning an error instead of fetching any API-provided URL that does not meet the allowlist policy.
