T09 · Insecure Skill Coding Practices
- Location
exec-reducer.py:22- Finding
Unrestricted Filesystem Read and Overwrite Through User-Controlled Paths
- Content
View full analysis
Vulnerability Details
File Location:
exec-reducer.py, lines 22-27
Vulnerability Type: Arbitrary file read and overwrite
Risk Level: MediumVulnerable Code
python if cmd == "read" and len(sys.argv) > 2: with open(sys.argv[2], 'r', encoding='utf-8') as f: print(f.read()) elif cmd == "write" and len(sys.argv) > 3: with open(sys.argv[2], 'w', encoding='utf-8') as f: f.write(sys.argv[3])Technical Analysis
The file path passed in
sys.argv[2]is used directly byopen()without path normalization, workspace containment checks, symlink validation, an allowlist, or overwrite confirmation. Absolute paths and path-traversal sequences can therefore reference files outside the intended project directory.The
readoperation prints the complete contents of any UTF-8 text file accessible to the process. Thewriteoperation opens the target inwmode, immediately truncating an existing file before writing attacker-controlled content. Security depends entirely on the operating-system privileges of the Agent process rather than on restrictions imposed by the Skill.Attack Path
- An attacker supplies malicious instructions or otherwise influences the path passed to the Skill.
- The Agent invokes the script with
readand an absolute or traversal-based path to a sensitive file, or withwriteand a path to a security-relevant file. - The script passes the path directly to
open(). - For
read, accessible file contents are printed into Agent output and may be disclosed. - For
write, the target file is truncated and replaced with attacker-controlled content. - The attacker obtains access to data or causes modifications within the full filesystem scope available to the Agent's operating-system account.
Impact Assessment
Successful exploitation can disclose readable text files such as source code, configuration files, local credentials, t ...[truncated 593 chars]
- Remediation
View remediation
Remediation Suggestions
- Define an explicit workspace root and permit access only to files beneath that directory.
- Normalize and resolve every supplied path before access, then verify containment using
pathlib.Path.resolve()andPath.relative_to(). - Reject absolute paths, traversal outside the workspace, device files, and other sensitive filesystem locations.
- Detect and reject symbolic links, or securely verify that both the requested path and final resolved target remain within the allowed root.
- Require explicit confirmation before overwriting an existing file. Prefer exclusive creation mode (
x) when replacement is unnecessary. - Apply separate permissions for reading and writing, with narrower writable directories.
- Run the Skill under a dedicated, least-privileged operating-system account.
- Avoid printing sensitive file contents into logs or persistent Agent transcripts.
- Where possible, replace arbitrary paths with opaque workspace-relative file identifiers selected from an allowlist.
