T09 · Insecure Skill Coding Practices
- Location
get-favorite-notes.sh:18- Finding
Predictable Temporary File Exposes Private Note Data and Enables Symlink Attacks
- Content
View full analysis
Vulnerability Details
File Location:
get-favorite-notes.sh:18-24
Vulnerability Type: Predictable temporary file with sensitive content
Risk Level: MediumVulnerable Code
bash TMPFILE="${TMPDIR:-/tmp}/ynote-fav-notes-$$.json" cleanup() { rm -f "$TMPFILE"; } trap cleanup EXIT # Main path: write to disk and parse with jq if ! mcporter call youdaonote.getRecentFavoriteNotes --args "{\"limit\":$LIMIT}" --output json > "$TMPFILE" 2>/dev/null; thenTechnical Analysis
The script creates a temporary filename using only the process ID and places it in
${TMPDIR:-/tmp}. In a shared temporary directory, this name is predictable. The file is created through ordinary shell redirection rather than an atomic, exclusive operation such asmktemp.A local attacker may pre-create the expected path as a symbolic link. When redirection occurs, the shell follows the link and truncates or overwrites the linked file if the invoking user has permission. The resulting file can also expose private note titles and content if the current
umaskpermits access by other users.The cleanup trap removes the path after execution but does not prevent pre-creation, symlink following, or access while the script is running.
Attack Path
- A local attacker monitors or predicts the process ID of a forthcoming Skill invocation.
- The attacker creates
/tmp/ynote-fav-notes-<PID>.jsonas a symbolic link to a file writable by the victim. - The script redirects the Youdao MCP response to that path.
- The shell follows the symbolic link and truncates or overwrites the linked target.
- Alternatively, if permissions are insufficiently restrictive, the attacker reads the temporary file while it contains private note data.
Impact Assessment
Exploitation requires local access and the ability to create files in the selected temporary directory. A successful attacker may disclose private note titles, ide ...[truncated 221 chars]
- Remediation
View remediation
Remediation Suggestions
Create the file atomically with restrictive permissions:
bash umask 077 TMPFILE="$(mktemp "${TMPDIR:-/tmp}/ynote-fav-notes.XXXXXX")" cleanup() { rm -f -- "$TMPFILE"; } trap cleanup EXITAlso validate that
TMPDIRrefers to a trusted directory owned by the invoking user or protected against unsafe file replacement. Where possible, avoid writing note content to disk and process it through a pipe.
