T09 · Insecure Skill Coding Practices
- Location
scripts/mineru_parse.py:102- Finding
Unvalidated Service-Provided URLs Enable Arbitrary Outbound Transfers
- Content
View full analysis
Vulnerability Details
File Location:
scripts/mineru_parse.py, lines 37-38 and 102-106
Vulnerability Type: Unvalidated remote upload and download destinations
Risk Level: MediumVulnerable Code
python md_url = data["markdown_url"] md_resp = requests.get(md_url)python file_url = result["data"]["file_url"] # Upload the file using the returned URL. with open(file_path, "rb") as f: put_resp = requests.put(file_url, data=f)Technical Analysis
The script directly trusts
file_urlandmarkdown_urlreceived from the MinerU API. It does not validate their schemes, hostnames, ports, or resolved destinations before issuing requests. Therequestslibrary also follows redirects by default, allowing an initially acceptable URL to redirect to an untrusted destination.In file mode, this trust boundary is particularly sensitive because the script opens the user-selected local file and sends its complete contents to the destination specified by
file_url. If the upstream service or its response path were compromised, an attacker could substitute an attacker-controlled upload URL and receive the document.The same issue affects
markdown_url: a malicious response could cause the process to contact an arbitrary network destination and consume attacker-controlled content. These requests also lack explicit connect and read timeouts, and the Markdown response is loaded without a size limit. The polling timeout therefore does not guarantee that an individual network request cannot hang indefinitely.This finding does not demonstrate malicious behavior by the current MinerU service. Exploitation requires control over, or compromise of, the API response path or a redirect destination trusted by the API.
Attack Path
- A user invokes the script with
--fileand selects a local document. - The script sends a task request to the MinerU API.
- A compromised or malicious API resp ...[truncated 1010 chars]
- A user invokes the script with
- Remediation
View remediation
Remediation Suggestions
- Require
httpsfor every upload and download URL. - Validate hostnames against an explicit list of documented MinerU and object-storage domains. Use exact hostname or properly bounded suffix comparisons rather than substring matching.
- Reject URLs containing embedded credentials, unexpected ports, malformed hostnames, or unsupported schemes.
- Disable automatic redirects with
allow_redirects=False. If redirects are required, validate every redirect destination before following it. - Consider resolving destinations and rejecting loopback, link-local, private, multicast, and other prohibited IP ranges when access to internal network resources is not required.
- Configure explicit connect and read timeouts for every
requests.get,requests.post, andrequests.putcall. - Use
raise_for_status()and validate the API response schema before reading task IDs or transfer URLs. - Stream the Markdown download and enforce a maximum response size instead of loading an unrestricted response into memory.
- Document the approved upload providers and expected URL patterns so destination validation can be maintained when the service configuration changes.
- Clearly notify users that selected documents are transferred to a third-party parsing service before uploading sensitive material.
- Require
