T09 · Insecure Skill Coding Practices
- Location
scripts/backfill_email.py:168- Finding
Predictable Temporary Files Expose Private Communication Data and Permit Symlink Attacks
- Content
View full analysis
/tmp/sent_emails.json gog calendar list --after 2024-01-01 --format json > /tmp/events.json wacli search --after 2024-01-01 --from me --format json > /tmp/wa_sent.json ``` ### Technical Analysis The scripts store raw email, calendar, and messaging exports under fixed, globally predictable names in `/tmp`. Python's `open(path, "w")` does not create the file exclusively and normally follows symbolic links. Shell redirection in the documented commands has equivalent risks. Consequently, another local user who can write to the shared temporary directory may create the expected path before the script runs. Depending on operating-system hardening, the path may be a symbolic link to another file writable by the account running the backfill process. Opening it in write mode can truncate and replace that target. The files also are not removed after processing. Their access permissions depend on the process umask rather than an explicit restrictive mode. If created with permissions such as `0644`, another local user may read the residual export. ...[truncated 2047 chars]- Remediation
View remediation
"$tmp_file" python3 scripts/backfill_email.py "$tmp_file" ``` 6. **Apply the correction consistently** to email, calendar, and messaging backfills, and advise users not to e ...[truncated 48 chars]
