T09 · Insecure Skill Coding Practices
- Location
SKILL.md:16- Finding
Predictable Temporary Script Path Enables Symlink-Based File Overwrite
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 16–17 and 142
Vulnerability Type: Unsafe predictable temporary file
Risk Level: MediumVulnerable Code:
bash # Save the deploy helper script cat > /tmp/agentstead-deploy.sh << 'SCRIPT'After writing the script, the same predictable path is made executable:
bash SCRIPT chmod +x /tmp/agentstead-deploy.shTechnical Analysis
The installation instructions write an executable script to the fixed, publicly predictable path
/tmp/agentstead-deploy.sh. Shell output redirection opens an existing target without exclusive creation and may follow a symbolic link.On a multi-user system, an attacker who can write to
/tmpcould create this pathname or place a symbolic link there before the victim follows the instructions. The redirection may then overwrite the linked target using the victim's privileges. The subsequentchmod +xoperation also acts on the predictable path and may modify the target's permissions.Exploitability and the exact behavior depend on operating-system protections such as sticky-directory rules, protected symlink settings, file ownership, and whether the victim has permission to modify the linked target.
Attack Path
- An attacker with local access monitors or anticipates use of the documented installation command.
- The attacker creates
/tmp/agentstead-deploy.shas a symbolic link to a file writable by the victim. - The victim executes the documented
cat > /tmp/agentstead-deploy.shcommand. - The shell follows the attacker-controlled link and replaces the target with the helper-script contents.
- The documented
chmod +xcommand may additionally add executable permissions to the target. - The overwritten file may cause denial of service or unintended code execution if it is subsequently executed or sourced in a security-sensitive context.
Impact Assessment
Successful e ...[truncated 513 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not install executable content at a fixed pathname in a shared temporary directory.
- Prefer a user-owned installation location such as
${HOME}/.local/bin/agentstead-deploy. - If temporary storage is necessary, create a private directory using
mktemp -d, set restrictive permissions, and register a cleanup trap. - Refuse to overwrite an existing destination and verify that the destination is a regular file owned by the current user.
- Avoid following symbolic links. Where supported, use APIs or utilities that provide exclusive creation and no-follow semantics.
- Apply restrictive permissions during creation, such as through
umask 077, rather than creating the file first and securing it afterward.
