T09 · Insecure Skill Coding Practices
- Location
scripts/upload_attachment.py:69- Finding
Unvalidated Presigned Upload URL Can Disclose Local Attachment Files
- Content
View full analysis
bool: """Upload the file to OSS through HTTP PUT.""" file_data = file_path.read_bytes() req = Request(upload_url, data=file_data, method='PUT') req.add_header('Content-Type', mime_type) try: with urlopen(req, timeout=120) as resp: ``` ### Technical Analysis The function reads the complete contents of a local file and transmits them to `upload_url`. That URL is obtained from the output of the `dws aitable attachment upload` command, but the script does not independently validate: - The URL scheme, such as requiring HTTPS. - Whether the destination hostname belongs to an approved DingTalk or Alibaba OSS domain. - Whether the URL contains embedded credentials or uses an unexpected port. - Whether DNS resolution points to a loopback, private, or link-local address. - Whether the final destination remains approved after redirects. Uploading file bytes to object storage is necessary for the declared attachment functionality. However, trusting an unrestricted destination URL is broader than the minimum network privilege required. A compromised or spoofed `dws` executable, service response, or upstream endpoint could return an attacker-controlled upload URL. The local file is explicitly selected through a command-line argument, so this is not arbitrary filesystem discovery. Nevertheless, the selected file may contain sensitive business or personal information, and the function will disclose its complete contents without confirming the destination. ### Attack Path 1. A user or agent invokes `upload_attachment.py` with a legitimate-looking base ID and a sensitive local file. 2. The script executes `dws aitable attachment upload`. 3. A compromised local `dws` binary o ...[truncated 1037 chars]- Remediation
View remediation
