T09 · Insecure Skill Coding Practices
- Location
scripts/daily-cost-report.sh:31- Finding
Predictable temporary files allow local disclosure and symlink attacks
- Content
View full analysis
"$OUTPUT_FILE" < "$HTML_FILE" << EOF ``` The fallback delivery path is also predictable: ```bash cp "$HTML_FILE" "/tmp/cost-report-${DATE_STR}-UNSENT.html" ``` ### Technical Analysis The scripts create and overwrite files under the shared `/tmp` directory using filenames derived from a predictable report date. The temporary working directory is based on the process ID, which is also guessable. The scripts do not: - Use `mktemp` for unpredictable, exclusive creation. - Apply a restrictive `umask`. - Verify that paths are regular files rather than symbolic links. - Refuse to overwrite existing files. - Create report files inside a private directory. - Atomically publish completed reports. Shell redirection and `cp` normally follow symbolic links. A local user who can write to `/tmp` can therefore pre-create one of the expected paths as a symbolic link. When the report runs under a more privileged or different account, it may overwrite the symlink target with the privileges of that account. The generated reports also contain potentially sensitive operational metadata, including session keys, agent identifiers, model usage, channel names, token counts, and costs. Depending on the account's `umask`, another local user may be able to read these fi ...[truncated 1185 chars]- Remediation
View remediation
