T09 · Insecure Skill Coding Practices
- Location
SKILL.md:50- Finding
Predictable Workspace Staging Permits File Collisions and Symlink-Following Overwrites
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 50–53; the unsafe operation is repeated at lines 94–96 and mandated by lines 166–170
Vulnerability Type: Unsafe temporary-file handling and forced overwrite
Risk Level: MediumVulnerable Code:
bash # Extract filename from source path filename=$(basename "/source/path/to/file.png") # Copy to workspace (overwrite if exists) cp -f "/source/path/to/file.png" "~/.openclaw/workspace/${filename}"The retry procedure repeats the operation:
bash # Sometimes transient failure, retry cp -f "/source/path/to/file.png" "~/.openclaw/workspace/${filename}" # ResendTechnical Analysis
The destination filename is derived solely from the source basename and is therefore predictable. The command then uses
cp -f, which intentionally replaces an existing destination. Two unrelated source files with the same basename consequently share the same staging location.If another process or user can modify the workspace directory, an attacker may pre-create the expected destination as a symbolic link. Depending on the platform and
cpimplementation, the forced copy may follow that link and replace its target with attacker-selected source content. The retry workflow performs the same unsafe write again, increasing exposure rather than recovering safely.The quoted destination also contains
"~". Shell tilde expansion does not occur when the tilde is quoted, so the documented command refers to a literal path beginning with~rather than reliably resolving the current user's home directory. This can cause staging and validation to operate on an unintended location.Attack Path
- The attacker learns or predicts the basename of a file that the Agent will send.
- The attacker creates a colliding file or symbolic link at the corresponding workspace destination.
- A user asks the Agent to send the source file through Feishu.
- The Age ...[truncated 965 chars]
- Remediation
View remediation
Remediation Suggestions
- Resolve the workspace path explicitly, such as with
$HOME/.openclaw/workspace, rather than quoting a literal tilde. - Create a private, uniquely named temporary directory for every operation using a secure primitive such as
mktemp -d. - Set restrictive directory and file permissions, such as
0700for the directory and0600for staged files. - Generate an unpredictable staging filename instead of relying only on the source basename. Preserve the original name separately as display metadata.
- Refuse to copy onto an existing destination and verify that every path component and destination is not a symbolic link.
- Use exclusive file creation and platform-supported no-follow controls where available.
- Confirm with a canonical-path check that the final destination remains inside the intended workspace.
- Remove staged files after successful delivery and during failure cleanup.
- Do not repeat the unsafe copy during retries; retry transmission from an already validated immutable staging file.
- Resolve the workspace path explicitly, such as with
