T09 · Insecure Skill Coding Practices
- Location
scripts/agentcloud.py:248- Finding
Server-Controlled Download Filename Allows Arbitrary File Overwrite
- Content
View full analysis
Vulnerability Details
File Location:
scripts/agentcloud.py, lines 248-252
Vulnerability Type: Path traversal and arbitrary file overwrite
Risk Level: Highpython content_disp = r.headers.get("Content-Disposition", "") if "filename=" in content_disp: output = content_disp.split("filename=")[-1].strip('"').strip("'") with open(output, "wb") as f:Technical Analysis
The download implementation trusts the filename supplied by the remote server in the
Content-Dispositionheader. This value replaces the local output path without validation, even when the user explicitly provided an output path.A filename containing an absolute path or directory traversal sequence, such as
../../.bashrc, can escape the intended download directory. The subsequentopen(output, "wb")call creates or truncates the selected file.Exploitation requires control of the API response, such as through compromise of the AgentCloud service, its infrastructure, or another mechanism capable of supplying a malicious authenticated HTTPS response.
Attack Path
- An attacker gains control over the download response returned by the AgentCloud API.
- The response includes a header such as
Content-Disposition: attachment; filename="../../.bashrc". - The user invokes the CLI
downloadcommand. - The CLI replaces the intended output path with the server-provided filename.
- The downloaded response body is written to the traversed path, truncating an existing file if present.
- If the overwritten file is security-sensitive or later executed, additional code execution or configuration compromise may result.
Impact Assessment
The attacker can create or overwrite files accessible to the operating-system user running the CLI. The vulnerability does not directly provide elevated system privileges, but it can modify user-owned shell configuration, application configuration, source files, credentials, or agent ...[truncated 135 chars]
- Remediation
View remediation
Remediation Suggestions
- Never allow a remote filename to override an explicitly supplied
--outputpath. - Extract only the basename using
Path(remote_name).name. - Reject absolute paths,
..components, path separators, null bytes, and platform-specific drive prefixes. - Resolve the destination against a designated download directory and verify that the resolved path remains inside that directory.
- Require confirmation before overwriting an existing file, or use exclusive creation mode.
- Parse
Content-Dispositionwith a standards-compliant parser rather than splitting the raw header. - Add tests covering absolute paths, traversal paths, encoded separators, Windows paths, malformed headers, and explicit output-path preservation.
- Never allow a remote filename to override an explicitly supplied
