Skip to content

fix(security): harden temp-dir handling against symlink/env-override#676

Merged
Chemaclass merged 2 commits into
mainfrom
fix/security-temp-dirs
May 12, 2026
Merged

fix(security): harden temp-dir handling against symlink/env-override#676
Chemaclass merged 2 commits into
mainfrom
fix/security-temp-dirs

Conversation

@Chemaclass
Copy link
Copy Markdown
Member

@Chemaclass Chemaclass commented May 12, 2026

Summary

  • src/learn.sh: replace predictable /tmp/bashunit_learn_$$ with mktemp -d, eliminating PID-based symlink races in shared /tmp
  • src/coverage.sh: replace $$-$RANDOM directory naming with mktemp -d for the same reason and to drop the (low but real) collision risk
  • src/parallel.sh: bashunit::parallel::cleanup now refuses to rm -rf a TEMP_DIR_PARALLEL_TEST_SUITE whose path is not under */bashunit/parallel/* — guards against accidental wipes when the env var is overridden

Background

Came out of a security/bug audit of src/. Eval-based findings (assert_duration, bashunit assert "<cmd>", --debug FILE) were verified as intentional CLI APIs, not vulnerabilities — only the temp-dir issues were real. No public API changes.

…risks

- learn.sh: replace predictable /tmp/bashunit_learn_$$ with mktemp -d
- coverage.sh: replace $$-$RANDOM path with mktemp -d
- parallel.sh: cleanup() refuses to rm -rf a TEMP_DIR_PARALLEL_TEST_SUITE
  that is not under */bashunit/parallel/*

Adds regression test asserting cleanup leaves an out-of-tree path intact.
@Chemaclass Chemaclass added the bug Something isn't working label May 12, 2026
@Chemaclass Chemaclass self-assigned this May 12, 2026
@Chemaclass Chemaclass enabled auto-merge (squash) May 12, 2026 11:56
@Chemaclass Chemaclass disabled auto-merge May 12, 2026 11:58
@Chemaclass Chemaclass merged commit 7b85bd2 into main May 12, 2026
30 checks passed
@Chemaclass Chemaclass deleted the fix/security-temp-dirs branch May 12, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant