T09 · Insecure Skill Coding Practices
- Location
paint_skill.py:111- Finding
Unconditional File Overwrite at a Hard-Coded Absolute Path
- Content
View full analysis
Vulnerability Details
File Location:
paint_skill.py, lines 111–112
Vulnerability Type: Unsafe fixed-path file write and potential symlink-assisted overwrite
Risk Level: Lowpython filename = "/Users/m1/.openclaw/workspace/openclaw_drawing.png" image.save(filename)Technical Analysis
The generated image is saved to a developer-specific absolute path without checking whether the destination already exists, whether it is a symbolic link, or whether the user has approved replacing it. Pillow's
Image.save()uses ordinary filesystem path resolution and can truncate or replace an existing destination.If the final path is a symbolic link, normal operating-system resolution may cause the image to be written to the link's target. Exploitation is constrained by the filesystem permissions of the account running the script; this issue does not independently bypass access controls.
The absolute path also makes the program non-portable. On systems where
/Users/m1/.openclaw/workspacedoes not exist or is inaccessible, execution will fail rather than saving to a user-selected location.Attack Path
- An attacker with permission to modify the destination directory pre-creates
/Users/m1/.openclaw/workspace/openclaw_drawing.pngas either a valuable existing file or a symbolic link to another file writable by the victim. - The victim runs
paint_skill.py. image.save(filename)follows ordinary filesystem resolution and opens the resolved destination for writing.- The existing file or symlink target is replaced or corrupted with PNG image data.
This path requires the attacker to have sufficient prior filesystem access to create or replace the destination entry.
Impact Assessment
The issue can cause loss or corruption of an existing file. Through a planted symbolic link, the affected scope may include other files writable by the account executing the script. No privilege escalation is es ...[truncated 228 chars]
- An attacker with permission to modify the destination directory pre-creates
- Remediation
View remediation
Remediation Suggestions
- Accept the output location through a command-line argument rather than embedding a developer-specific absolute path.
- Use a safe, user-controlled default such as a filename in the current working directory.
- Refuse to overwrite an existing destination unless the user explicitly supplies an option such as
--force. - Detect and reject symbolic-link destinations where overwriting is not intended.
- For strict non-overwrite behavior, create the destination atomically with exclusive-create semantics and save through the resulting file handle.
- Validate that the parent directory exists and provide a clear error instead of silently selecting another sensitive location.
- If replacement is required, write to a securely created temporary file in the same directory and atomically rename it after successful image generation.
