Skip to content

Stage diagnostics logs privately instead of at fixed /tmp paths - #7995

Closed
Adolanium wants to merge 5 commits into
omacom:quattrofrom
Adolanium:diagnostics-tmp-staging
Closed

Adolanium wants to merge 5 commits into
omacom:quattrofrom
Adolanium:diagnostics-tmp-staging

Conversation

@Adolanium

@Adolanium Adolanium commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

omarchy-debug gathers the machine's diagnostics into a file at a fixed name:

`�ash
LOG_FILE="/tmp/omarchy-debug.log"

if [[ = "true" ]]; then
DMESG_OUTPUT="(skipped - --no-sudo flag used)"
else
DMESG_OUTPUT=""
fi

cat > "" <<EOF
`

The redirect creates that file under the caller's umask, which is 022, so it lands mode 0644 in a directory every local user can reach. The interesting part is what goes in it. sudo dmesg is elevated on purpose, because the kernel ring buffer is not readable by an ordinary user, and the script then writes it somewhere an ordinary user can read. The boot journal at -p 4..1 and the full package inventory go in alongside it. Nothing removes the file, so the last run's log sits there until reboot.

omarchy-upload-log does the same thing with /tmp/upload-log.txt and /tmp/system-info.txt. Those hold the assembled bundle, including the install logs and the journal, and are likewise never removed.

A planted symlink is not the way this goes wrong. s.protected_symlinks and s.protected_regular are on by default, so another user planting a symlink or a regular file makes the redirect fail rather than succeed somewhere unintended. For the upload bundle that failure is still a problem: curl uploads the file already at the name and prints the URL as this user's log. What remains either way is disclosure: a predictable name, a readable mode, and content the machine went out of its way to elevate for. Omarchy is a single-user desktop, so this only matters on machines with more than one local account.

All three now go through mktemp, which creates at 0600 under a name nobody can guess, with a trap clearing them on the way out. Every use of the files is a read by path, so nothing else in either script had to change. omarchy-debug has no set -e, so a failed write is checked on its own and the command exits nonzero. Without that check --print would exit 0 with an empty log.

Two more fixed /tmp paths in �in/ get the same treatment:

  • omarchy update wrote its transcript to /tmp/omarchy-update.log. It is read back by omarchy-update-analyze-logs after the run, so it keeps a stable name at ~/.local/state/omarchy/update.log, which is still there after logout. The directory is created mode 0700, and chmodded 0700 if it already exists. The transcript is mode 0600 before script opens it. A symlink at the directory is refused. A symlink at the log path is removed, because script would follow it. docs/update-process.md names the new path.
  • omarchy-install-gaming-battlenet wrote the installer log to /tmp/omarchy-battlenet-installer.log. It is written by a detached process after the script exits, so a trap cannot clean it up. It now lives at ~/.cache/omarchy/battlenet-installer.log, next to the installer itself. The script sets that directory to mode 0700 first. mkdir -p does not change the mode of a directory that already exists, and ~/.cache is not mode 0700 on its own. Each run overwrites the last log.

Moving these two off /tmp has a side benefit. With s.protected_regular on, a second local user running the same command got "Permission denied" on the file the first user left behind. Per-user paths remove that collision.

Migration 1790092800.sh removes /tmp/omarchy-debug.log, /tmp/upload-log.txt, and /tmp/system-info.txt when they are regular files owned by the current user. Symlinks, directories, and files owned by someone else are left alone.

Two agent skill docs mentioned /tmp/omarchy-debug.log as a side effect of omarchy debug --no-sudo --print. The primary route there is --print, which puts the same content on stdout, and the interactive menu still offers "Save in current directory" for anyone who wants a file. Both mentions are updated rather than left pointing at a path that no longer exists.

Tests: est/shell.d/diagnostics-staging-test.sh stubs the collectors and points TMPDIR at a directory the test owns. It checks --print still prints what was gathered, that the run removes the file it staged, that nothing is left behind, and that neither script names a /tmp literal. The cleanup case is checked through an
m stub that records what it was asked to remove, because an empty staging directory on its own would also pass for a script that never staged there, which is exactly what the old fixed path did. Further cases cover a failed debug write, the transcript landing under XDG_STATE_HOME, the fallback to ~/.local/state when it is unset, directory mode 0700 and file mode 0600, an existing transcript kept and tightened rather than emptied, a symlink state directory refused, a symlink transcript dropped without writing through it, a directory at the transcript path refused, omarchy-update-analyze-logs reading from the new path, staying quiet on a good run, ignoring a symlink, and staying quiet when the file is missing, and the Battle.net log pointing at the fixed name in a cache directory that was mode 0755 and is now 0700, including a symlink cache directory that is refused. est/shell.d/diagnostics-tmp-migration-test.sh covers owned leftovers removed, a rerun, symlinks left alone, and a directory at the legacy name left alone. The other-owner case skips where chown is unavailable. Both files pass. I ran them directly; the rest of ./test/shell and ./test/cli depend on tools my environment does not have (jq, lua, magick), so I did not run them.

Fixes #8367

Fixes #11204

Copilot AI balanced review requested due to automatic review settings August 24, 2026 04:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Privately stages sensitive diagnostic data and removes temporary files after use.

Changes:

  • Replaces fixed /tmp paths with mktemp files and cleanup traps.
  • Updates diagnostics documentation.
  • Adds shell tests for staging and cleanup behavior.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
bin/omarchy-debug Secures temporary diagnostic logs.
bin/omarchy-upload-log Secures and cleans upload staging files.
test/shell.d/diagnostics-staging-test.sh Tests private staging behavior.
default/agents/skills/omarchy/contributing.md Removes obsolete fixed-path guidance.
default/agents/skills/diagnose-crash/reporting.md Updates diagnostic reporting instructions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Adolanium

Copy link
Copy Markdown
Contributor Author

The same treatment now covers the other two fixed /tmp paths in bin/:

  • omarchy update wrote its whole transcript to /tmp/omarchy-update.log. That one is read back by omarchy-update-analyze-logs after the run, so it keeps a stable name, but the name moves to ~/.local/state/omarchy/update.log, where no other local user can pre-create it or read along. docs/update-process.md names the new path.
  • omarchy-install-gaming-battlenet wrote the installer log to /tmp/omarchy-battlenet-installer.log. It is written by a detached process after the script exits, so a trap cannot clean it up. It now stages with mktemp inside the user's own cache directory, next to the installer itself.

Tests: diagnostics-staging-test.sh grows from 4 to 12 cases. The new ones cover the transcript landing under XDG_STATE_HOME, the fallback to ~/.local/state when it is unset, analyze-logs reading from the new path and staying quiet on a good run, and the Battle.net log reaching the detached writer at an unguessable name in the cache directory. All pass. ./test/shell shows the same failing files before and after this commit. Those are tools missing from my environment and not anything this touches.

@Adolanium

Copy link
Copy Markdown
Contributor Author

One more round on the comments and the Battle.net log.

A correction to my earlier comment: I said another local user could "pre-create it as a link". That is wrong on a default systemd system. fs.protected_symlinks and fs.protected_regular make the redirect fail instead. The real problems with the fixed /tmp names were that another local account could read the file, and that a second user running the same command got "Permission denied" on the file the first user left. The code comments in omarchy-update, omarchy-update-analyze-logs, and omarchy-install-gaming-battlenet now say that instead.

The Battle.net log drops mktemp. ~/.cache is already 0700 on Arch, so a random name there added nothing except a new leftover file per run. It is now a fixed ~/.cache/omarchy/battlenet-installer.log, overwritten each run. The test checks for that name. diagnostics-staging-test.sh still has 12 cases, all passing.

@chessing234

Copy link
Copy Markdown
Contributor

hey, this is already covered in #12109 (private diagnostics staging out of shared /tmp). mind closing this as a duplicate?

omarchy-debug wrote sudo dmesg output and the boot journal to
/tmp/omarchy-debug.log, and omarchy-upload-log built its bundle at
/tmp/upload-log.txt and /tmp/system-info.txt. All three were created under the
default umask, so any local user could read them, and none was removed
afterwards.

Stage all three with mktemp and clear them on exit.
…p paths

omarchy update wrote its transcript to /tmp/omarchy-update.log and
omarchy-install-gaming-battlenet wrote the installer log to
/tmp/omarchy-battlenet-installer.log. At a fixed name in /tmp another
local account could read the file, and with fs.protected_regular a second
user running the same command got "Permission denied" on the file the
first user left behind.

The transcript is read back by omarchy-update-analyze-logs, so it keeps a
stable name but moves to ~/.local/state/omarchy/update.log. The Battle.net
log is written by a detached process after the script exits, so a trap
cannot clean it up; it now lives at a fixed name in ~/.cache/omarchy,
which is already private to the user, and each run overwrites the last.
docs/update-process.md names the new transcript path.
omarchy-debug has no set -e, so a failed log write still exited 0 and
--print showed an empty log. The update transcript and the Battle.net
installer log had moved off /tmp, but script and the detached installer
create those files at the caller's umask, and mkdir -p does not tighten a
directory that already exists.

Exit nonzero when the debug log cannot be written. Create the update
state directory mode 0700, refuse a symlink there, drop a symlink at the
log path, and make the transcript mode 0600 before script opens it.
chmod ~/.cache/omarchy to 0700 before the Battle.net installer writes.
Remove leftover world-readable diagnostics files this user still owns
in /tmp.
@Adolanium
Adolanium force-pushed the diagnostics-tmp-staging branch from 7ca81eb to 1fbc6b6 Compare September 22, 2026 15:38
@Adolanium

Adolanium commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request was opened on August 24, three weeks before #12109.

#12109 leaves /tmp/omarchy-battlenet-installer.log in place. The detached installer writes that log after the script exits, so it is still world-readable on quattro.

The debug log, the upload bundle, and the update transcript overlap, and the fixes differ. This branch removes the debug and upload files on exit. The update transcript stays at ~/.local/state/omarchy/update.log so it is still there after logout. The branch now checks a failed debug write, creates that state directory mode 0700, makes the transcript mode 0600, sets ~/.cache/omarchy to mode 0700 before the Battle.net log is written, and migrates leftovers this user still owns in /tmp.

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
omarchybot and others added 2 commits September 28, 2026 17:28
Resolves the conflicts with the update security foundation on quattro: the transcript path from prepare_update_log is passed to script alongside the preserved OMARCHY_UPDATE_USER_PATH, and the paths table keeps quattro's stay-awake row and restart description.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On quattro, omarchy-update resets PATH to $OMARCHY_PATH/bin and checks its source root before the logging exec, so the stub script on the caller's PATH was never reached: the test ran the real script(1) and the real update, and stopped at its confirmation prompt. The transcript cases now run a boundary copy of omarchy-update with the stand-in in its bin/, as update-user-path-test.sh does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Sep 28, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and run on a disposable Omarchy worker. The fix holds on quattro, and I pushed two commits to make it land there.

Reproduction. I ran my own check on the worker against quattro (b18ab49) and against this branch. On quattro, omarchy debug --no-sudo --print leaves /tmp/omarchy-debug.log at mode 0644. omarchy-upload-log this-boot uploads from /tmp/upload-log.txt at 0644, and leaves that file and /tmp/system-info.txt behind. omarchy update hands script(1) /tmp/omarchy-update.log. On this branch, none of those files appear, nothing is left in TMPDIR, and the upload is staged at 0600. The transcript goes to ~/.local/state/omarchy/update.log at 0600 in a 0700 directory, and omarchy-update-analyze-logs reads it back from there. I stubbed curl so nothing was uploaded.

Pushed:

  • A merge of quattro into the branch (26470aa). This resolves the conflicts in bin/omarchy-update and docs/update-process.md. The transcript path is passed to script alongside the OMARCHY_UPDATE_USER_PATH that quattro now preserves. The paths table keeps quattro's stay-awake row.
  • 4b587a2 moves the omarchy-update cases out of diagnostics-staging-test.sh into diagnostics-update-transcript-test.sh. On quattro, omarchy-update resets PATH to $OMARCHY_PATH/bin and checks its source root before the logging exec. That means the stub script on the caller's PATH was never reached: on the worker, the test ran the real script and the real update, and sat at "Continue with update?". The cases themselves are unchanged. They now run a copy of omarchy-update on the sudo boundary fixture, as update-user-path-test.sh does. They pass, and they fail with bin/omarchy-update reverted to quattro's.

Tests. I ran ./test/cli and the full ./test/shell on the worker at 4b587a2. The new and changed diagnostics tests pass. Every other failing file also fails on quattro, or passes when rerun on its own. The migration test's other-owner case skips there, as its own test says it will.

Second opinion. Codex Medium ran two rounds. The first found the test bypass above, which I confirmed on the worker before fixing. It also flagged two things I left alone. One was the migration skipping /tmp/omarchy-update.log: that migration runs inside omarchy update, while the pre-upgrade updater is still writing that file. The other was a possible empty 0600 leftover if the second mktemp in omarchy-upload-log fails. The second round, on the pushed head, found nothing left and agreed with both of those calls. It can read this session's work, so its agreement is not a guaranteed independent check.

Related. This PR now says it closes #8367, which describes exactly this bug. It also closes #11204, because omarchy-update-analyze-logs exits quietly when there is no transcript. Other open PRs cover parts of the same ground: #12109 (these paths plus many unrelated ones), #12957 and #8429 (update transcript only), #8430 (Battle.net log only), and #11217 (#11204 only). This one is the oldest, and it is the only one that covers all four diagnostic files and nothing else. Choosing between them is the maintainer's call.

This is waiting on the maintainer.

@dhh

dhh commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Closing after maintainer review. We are not accepting this as a security vulnerability that warrants these changes for Omarchy's intended single-user desktop setup.

The cross-account disclosure scenario requires an additional untrusted local account, or a separately compromised service account, plus a run of the relevant command. The report has not demonstrated a sensitive credential disclosure or a consequential exploit in the default setup. Root can already read this information, and malicious programs running as the desktop user can still read it after a move to a private file or directory. Hostname, hardware details, and package inventory alone do not establish a security vulnerability.

The default systemd protections (fs.protected_symlinks and fs.protected_regular) block the described cross-user symlink redirect and writes into another user's pre-created regular file in sticky /tmp. World-writable /tmp by itself is not evidence of arbitrary file overwrite or privilege escalation. These protections do not prevent reading an existing 0644 file; that narrow cross-account exposure is acknowledged.

The default /tmp is tmpfs-backed and is cleared on reboot. These logs are not permanently retained: the exposure, where an untrusted second account exists, lasts only while the files remain during that boot. Reboot limits the exposure; it does not make cross-account reads impossible before then.

Private staging and explicit cleanup can be reasonable housekeeping, but we do not consider the demonstrated behavior a security priority for the default Omarchy threat model. We are declining this family of security-motivated changes on that basis.

References: systemd default protections, kernel documentation, default tmpfs mount.

The author has already corrected the earlier symlink exploit claim. The remaining diagnostics disclosure and cross-user filename collisions require the additional local-account scenario above. The missing-transcript behavior tracked in #11204 is a separate functional issue and is not being closed by this decision.

Omabot on behalf of DHH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

5 participants