T09 · Insecure Skill Coding Practices
- Location
scripts/imagegen.py:215- Finding
Unvalidated Server-Provided Upload Destination
- Content
View full analysis
Vulnerability Details
File Location:
scripts/imagegen.py:215-224
Vulnerability Type: Unrestricted remote upload destination and HTTP method
Risk Level: Highpython media_id = token["mediaId"] upload_url = token["upload"]["url"] upload_method = token["upload"].get("method", "PUT") upload_headers = token["upload"].get("headers", {}) # PUT to object storage without the API key, using the returned headers print(f"[2/3] Uploading file to object storage...") with open(str(path), "rb") as f: try: oss_resp = requests.request( upload_method, upload_url, headers=upload_headers, data=f, timeout=300, )Technical Analysis
The upload-token API response controls the URL, HTTP method, and headers used to transmit the selected local image. The client does not verify that the URL uses HTTPS, belongs to an approved object-storage domain, or resolves to a public address. It also does not restrict the returned method to an expected upload method such as
PUT.Although the primary API endpoint is fixed, a compromised AI Hive service, compromised upstream component, or maliciously altered API response could instruct the client to transmit the image to an arbitrary external or internal endpoint.
Attack Path
- A user invokes the generation or upload command with a local image.
- The client requests an upload token from the fixed AI Hive API.
- A compromised service or upstream component returns an attacker-controlled
upload.url,upload.method, orupload.headersvalue. - The client opens the user-selected image.
requests.request()sends the image body to the attacker-selected destination without destination validation.- The attacker receives the image or causes the client to issue a request against a network service reachable from the user's machine.
Impact Assessment
Successful exploitation can disclose the complete contents ...[truncated 483 chars]
- Remediation
View remediation
Remediation Suggestions
- Require the upload URL to use HTTPS.
- Maintain an explicit allowlist of approved object-storage hostnames and reject all other destinations.
- Resolve the destination and reject loopback, private, link-local, multicast, and other non-public address ranges.
- Restrict upload methods to the exact methods required by the service, such as
PUTorPOST. - Allowlist permitted upload headers rather than forwarding every server-provided header.
- Disable redirects for upload requests or validate every redirect destination using the same policy.
- Consider cryptographically binding upload-token responses to an expected storage provider and media identifier.
