T09 · Insecure Skill Coding Practices
- Location
SKILL.md:35- Finding
Full-Screen Captures Are Written to Predictable Temporary Files
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 35 and 74
Vulnerability Type: Unsafe temporary-file handling and excessive screen capture
Risk Level: MediumVulnerable code snippets:
bash screencapture -x /tmp/clash_nodes.pngbash screencapture -x /tmp/screen.pngTechnical Analysis
The documented commands capture the entire display even though the workflow only requires information from the ClashX menu. A full-screen image can include unrelated sensitive content, such as notifications, account information, messages, application windows, or confidential documents.
Both images are written under fixed, predictable names in the shared
/tmpdirectory. The workflow does not create a private temporary directory, verify the destination file, enforce restrictive permissions, or delete the screenshots after use. Predictable temporary paths may permit another local process or user to monitor the generated files. They may also create file-clobbering or symbolic-link risks where the operating system's temporary-file protections do not prevent such attacks.Attack Path
- An attacker with local access monitors
/tmp/clash_nodes.pngand/tmp/screen.png, or prepares one of those paths as a symbolic link where platform protections permit it. - The user follows the Skill workflow while unrelated sensitive information is visible on the display.
screencapturerecords the complete screen and writes the image to the predictable path.- The attacker reads the retained screenshot or, in a file-replacement scenario, causes the command to overwrite a target writable by the user.
- Because no cleanup step is specified, the screenshot can remain available after the workflow finishes.
Impact Assessment
The primary impact is disclosure of any information visible on the user's screen at capture time. Exposure is limited to parties or processes capable of accessing the resulting ...[truncated 425 chars]
- An attacker with local access monitors
- Remediation
View remediation
Remediation Suggestions
- Capture only the ClashX menu or the smallest required screen region rather than the entire display.
- Create a private temporary directory with
mktemp -dand restrictive permissions instead of using fixed names directly under/tmp. - Generate unpredictable filenames and verify that destinations are regular files rather than symbolic links.
- Set a restrictive process umask, such as
umask 077, before creating screenshots. - Remove captured images immediately after processing and add cleanup through a shell
trapso files are deleted on both success and failure. - Avoid retaining screenshots unless they are strictly necessary. If retention is required, store them in an access-controlled location and document the retention period.
- A hardened pattern is:
bash umask 077 tmp_dir="$(mktemp -d "${TMPDIR:-/tmp}/clashx-scan.XXXXXX")" || exit 1 trap 'rm -rf "$tmp_dir"' EXIT # Capture only the required region; replace x,y,w,h with validated values. screencapture -x -R"x,y,w,h" "$tmp_dir/clash_nodes.png"
