Skip to content

Use unpredictable /tmp paths for log and upload temporary files - #14109

Closed
MBemera wants to merge 1 commit into
omacom:quattrofrom
MBemera:fix/tmp-predictable-paths
Closed

MBemera wants to merge 1 commit into
omacom:quattrofrom
MBemera:fix/tmp-predictable-paths

Conversation

@MBemera

@MBemera MBemera commented Oct 3, 2026

Copy link
Copy Markdown

Five scripts write temporary files to fixed, predictable paths under /tmp: the upload payload in omarchy-upload-log (/tmp/upload-log.txt, /tmp/system-info.txt), the debug log in omarchy-debug (/tmp/omarchy-debug.log), the Battle.net installer log in omarchy-install-gaming-battlenet (/tmp/omarchy-battlenet-installer.log), and the update transcript in omarchy-update (/tmp/omarchy-update.log, read back by omarchy-update-analyze-logs). Since /tmp is world-writable and the sticky bit only stops deletion, not creation, another local account can pre-create any of these names as a symlink to a file in the victim's home; the next run of the script then clobbers that file through the redirect, as the victim. I wrote these as mktemp in each case, with a trap to remove the files on exit where the script owns the whole lifecycle, and omarchy-update now hands the transcript path to its logged instance through OMARCHY_UPDATE_LOG instead of both sides agreeing on a fixed name.

fs.protected_symlinks and fs.protected_regular block the symlink and swap variants on default kernel configurations, but those are kernel policy rather than a property of the scripts; mktemp is safe regardless of the host's sysctls. This is the same class the stay-awake state path fix moved into a validated private directory, and #14078 covers the debug and upload-log sites with the same approach — this PR adds the update transcript, the Battle.net installer log, and the analyze step.

I verified this on the current quattro in a Try Omarchy VM. All five scripts pass bash -n, and omarchy-upload-log this-boot and omarchy-debug --print --no-sudo run to completion with the temp files gone on exit. The new test/shell.d/tmp-predictable-path-test.sh scans bin/, install/, and migrations/ for fixed /tmp paths as a net rather than a proof, following unowned-system-paths-test.sh: every literal fixed path is flagged, with an allowlist for the validated stay-awake state base and paths named only in comments. It passes on this branch, and putting any of the five old paths back — e.g. TEMP_LOG=/tmp/upload-log.txt — fails it with that file and line.

Happy to adjust. -MB

Fixed, predictable paths under /tmp let another local account pre-create
them: as symlinks (so the victim's write clobbers a victim file through
the redirect) or as readable files (so log content is disclosed to them).
fs.protected_symlinks and fs.protected_regular block both on default
configurations, but those are kernel policy, not a property of these
scripts; mktemp is safe regardless of the host's sysctls.

- omarchy-upload-log: payload and system-info files via mktemp, removed
  on exit
- omarchy-debug: debug log via mktemp, removed on exit
- omarchy-install-gaming-battlenet: detached installer log via mktemp
- omarchy-update: script(1) transcript via mktemp, path handed to the
  logged instance through OMARCHY_UPDATE_LOG, removed on exit
- omarchy-update-analyze-logs: read the transcript from OMARCHY_UPDATE_LOG
  instead of guessing a fixed location

Adds test/shell.d/tmp-predictable-path-test.sh: scans bin/, install/, and
migrations/ for fixed /tmp paths so a new one cannot be reintroduced,
with an allowlist for the validated state base and comment references.
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.

1 participant