T09 · Insecure Skill Coding Practices
- Location
SKILL.md:58- Finding
Predictable and Unsanitized Temporary-File Path
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:58and duplicated inreferences/avatar-style.md:87
Vulnerability Type: Unsafe temporary-file handling
Risk Level: LowVulnerable Code Snippet:
markdown 1. Write the prompt to the temporary file `/tmp/openclaw-[lobster name]-prompt.md`The instruction appears in Chinese in the source files and directs the agent to construct a predictable path in the shared
/tmpdirectory by interpolating the character name.Technical Analysis
The temporary-file name is both predictable and derived from a potentially user-controlled character name. The instructions do not require:
- Sanitizing path separators or traversal sequences in the name.
- Creating the file atomically with exclusive-create semantics.
- Rejecting symbolic links.
- Restricting file permissions.
- Using a private, randomly named temporary directory.
- Deleting the temporary file after image generation.
On a multi-user system, an attacker may pre-create the expected path as a symbolic link. A subsequent agent write could follow that link and overwrite another file writable by the agent process. If path separators or traversal components are accepted in the character name, they could also influence where the prompt is written.
This issue exists in Skill instructions rather than directly executable project code, but an agent following those instructions would perform the unsafe operation.
Attack Path
- The attacker determines or influences the selected character name.
- The attacker predicts the resulting path, such as
/tmp/openclaw-example-prompt.md. - Before the Skill writes the prompt, the attacker creates that path as a symbolic link to another file.
- The agent follows the Skill instruction and writes the prompt to the predictable path.
- If the runtime write operation follows symbolic links, the link target is overwritten with the agent's privileges.
Alternatively, a crafted name containing path separa ...[truncated 776 chars]
- Remediation
View remediation
Remediation Suggestions
- Create a private, randomly named temporary directory using a secure facility such as Python
tempfile.TemporaryDirectory()or shellmktemp -d. - Create the prompt file atomically with exclusive-create semantics and permissions no broader than
0600. - Never use a raw character name as a path component. Replace it with a generated identifier, or strictly allow-list safe characters and reject path separators,
.., control characters, and absolute paths. - Ensure the write operation does not follow symbolic links, using platform facilities such as
O_NOFOLLOWwhere available. - Verify that the resolved file remains inside the newly created private temporary directory.
- Delete the prompt file and temporary directory immediately after image generation, including on error paths.
- Apply the same correction to the duplicated instruction in
references/avatar-style.md:87.
- Create a private, randomly named temporary directory using a secure facility such as Python
