Skip to content

fix: TOCTOU race in mktemp_portable fallback#38

Merged
Neo23x0 merged 1 commit intoNextronSystems:script-robustnessfrom
Colossus14:script-robustness
Mar 17, 2026
Merged

fix: TOCTOU race in mktemp_portable fallback#38
Neo23x0 merged 1 commit intoNextronSystems:script-robustnessfrom
Colossus14:script-robustness

Conversation

@Colossus14
Copy link
Copy Markdown

When mktemp is unavailable, the fallback path previously created a predictable filename (thunderstorm.$$.$RANDOM) and wrote to it non-atomically. An attacker could predict the name and pre-create a symlink.

Fix: Create a private directory first (mkdir is atomic), then create temp files inside it. Cleanup updated to remove the fallback directory on exit.

Found by Axiom-Loop (GLM-5 + Kimi K2.5 flagged independently).

When mktemp is unavailable, the fallback now creates a private directory
first (mkdir is atomic with umask 077), then creates temp files inside
it. This eliminates the race window where an attacker could predict the
filename and pre-create a symlink in /tmp.

Cleanup updated to remove the fallback directory on exit.
@Neo23x0 Neo23x0 merged commit fb2e454 into NextronSystems:script-robustness Mar 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants