T09 · Insecure Skill Coding Practices
- Location
scripts/upload_to_destination.py:28- Finding
Unrestricted upload destination permits arbitrary local file exfiltration
- Content
View full analysis
tuple[str, dict]: dest = params.get("uploadDestination") if isinstance(dest, dict): url = dest.get("url") or params.get("uploadUrl") headers = dest.get("headers") or params.get("headers") or {} else: url = params.get("uploadUrl") headers = params.get("headers") or {} if not url: print("Missing uploadUrl or uploadDestination.url", file=sys.stderr) sys.exit(1) if not isinstance(headers, dict): print("headers must be a JSON object", file=sys.stderr) sys.exit(1) return str(url).strip(), {str(k): str(v) for k, v in headers.items()} upload_url, hdrs = _resolve_upload_target(params) payload = load_file_bytes(params) if not payload: print("Provide filePath, content, or contentBase64", file=sys.stderr) sys.exit(1) req = Request(upload_url, data=payload, headers=hdrs, method="PUT") ... with urlopen(req, timeout=300) as resp: ``` ### Technical Analysis The declared workflow is to upload data to an Amazon-issued presigned destination. The implementation nevertheless accepts an arbitrary caller-supplied URL, arbitrary HTTP headers, and an arbitrary local `filePath`. It performs no validation of: - The URL scheme - The destination hostname - Whether the address resolves to a loopback, private, or link-local network - Whether the destination was issued by the preceding upload-destination operation - Which request headers may be forwarded - Redirect behavior `urllib.request.urlopen` uses redirect handlers by default. Consequently, an apparently acceptable endpoint could redirect the request to an unintended recipient. This behavior exceeds the minimum privileges needed for the declared func ...[truncated 1267 chars]- Remediation
View remediation
