You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
doctor.sh --json writes stderr to a predictable temp path instead of mktemp #427
Found by the round-one release audit of v0.23.0..9f3269e. The auditor reported it unranked -- it classified the finding and no row in the ranking table fits. unranked is not the same as minor, and the missing row is worth weighing separately from the fix.
Symptom
doctor.sh --json writes its stderr to a path an attacker can predict and pre-seed, so a symlink at that name truncates an attacker-chosen file as the invoking user.
The shell opens a redirection target following symlinks. On Linux, where TMPDIR is commonly unset, /tmp is shared and the name is $$ -- guessable. A pre-seeded symlink there redirects the write and truncates the target; the rm -f afterwards removes only the symlink.
Provenance, stated rather than absorbed: this is a duplication, not a new introduction.git show v0.23.0:scripts/doctor.sh carries the identical pattern at its line 107, so it predates this delta. The rest of the codebase does it correctly -- save-session.sh uses mktemp "${TMPDIR:-/tmp}"/remember-...-XXXXXX in five places.
Why no row fits
The auditor's reasoning, kept because it is the useful half: containment (write)'s fix sends a reviewer to "which repository did the caller mean", and the target here is not an argument. destroys's fix sends them to a destructive call with an unvalidated argument, and there is none. misreports does not apply -- nothing is misreported. The fix this actually invites is "route every temp file through mktemp", which no existing row sends a reviewer to.
What would settle it
Replace both sites with mktemp, matching save-session.sh. A guard test that no script under scripts/ builds a temp path from $$ would pin the class rather than the instance. Separately: whether the ranking table wants a row for predictable-temp-path, which is a decision about the table and not about this file.
Activity
fix: lib-memory-dir.sh and lib-env-cache.sh no longer build a shared-…
fix: doctor.sh no longer builds its stderr-capture temp path from $$ (D…