T09 · Insecure Skill Coding Practices
- Location
SKILL.md:73- Finding
Predictable Shared Temporary Script Paths Enable Local File Replacement or Symlink Attacks
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 73, 137, 194, 247, 295, and 327
Vulnerability Type: Unsafe temporary-file handling
Risk Level: MediumVulnerable Code Snippets
markdown **Recipe** — save as `/tmp/at_chat.py`, run with `python3 /tmp/at_chat.py <model> <prompt...>`:markdown **Recipe** — save as `/tmp/at_image.py`:markdown **Recipe** — save as `/tmp/at_video.py`:markdown **Recipe** — save as `/tmp/at_search.py`:markdown **Recipe** — save as `/tmp/at_models.py`:markdown **Recipe** — save as `/tmp/at_cost.py`:Technical Analysis
The Skill instructs the host agent to write executable Python programs to predictable filenames in the globally shared
/tmpdirectory and then execute them. Fixed temporary paths are vulnerable to symlink attacks and time-of-check/time-of-use file replacement on systems where another user or compromised process can modify/tmp.An attacker can pre-create a documented path as a symbolic link, potentially causing the agent's write operation to overwrite another file accessible to the agent. Alternatively, an attacker can replace the temporary script after it is written but before Python opens it, causing attacker-controlled code to execute with the agent process's permissions.
Exploitability depends on the host's file-creation semantics,
/tmpprotections, local attacker access, and the privileges under which the agent operates. The flaw is most relevant on multi-user systems or hosts where another process is already compromised.Attack Path
- A local attacker identifies a predictable filename such as
/tmp/at_chat.py. - Before the agent creates the recipe, the attacker places a symbolic link at that path targeting a file writable by the agent. Alternatively, the attacker waits for script creation and races to replace it before execution.
- The agent follows ...[truncated 1288 chars]
- A local attacker identifies a predictable filename such as
- Remediation
View remediation
Remediation Suggestions
- Do not use fixed filenames directly under shared
/tmp. - Create a private temporary directory with Python's
tempfile.TemporaryDirectory()and restrictive owner-only permissions. - Create scripts using
tempfile.NamedTemporaryFile()or an equivalent atomic, exclusive-create operation. - Avoid closing and reopening temporary scripts by pathname where practical. Retain a trusted file descriptor or verify the file's identity before execution.
- Reject symbolic links and confirm that the resulting file is a regular file owned by the expected user.
- Set permissions to owner-only access, such as mode
0700for the private directory and0600for script files. - Execute the verified script from the private directory and remove the directory immediately afterward.
- Where supported by the host agent, execute the recipe from an in-memory or securely managed script channel instead of writing executable content to a shared temporary filesystem.
- Run the agent under a dedicated, minimally privileged account so exploitation cannot access unrelated files or credentials.
- Do not use fixed filenames directly under shared
