Skip to content

[Security] Stage diagnostics where only their owner can read them - #8370

Closed
chessing234 wants to merge 9 commits into
omacom:quattrofrom
chessing234:security/diagnostics-tmp-paths
Closed

chessing234 wants to merge 9 commits into
omacom:quattrofrom
chessing234:security/diagnostics-tmp-paths

Conversation

@chessing234

@chessing234 chessing234 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #8367.

omarchy-debug wrote sudo dmesg, the journal and a full hardware inventory to /tmp/omarchy-debug.log, and omarchy-upload-log assembled what it publishes at /tmp/upload-log.txt / /tmp/system-info.txt. Under the default umask those land mode 0644 in a world-writable directory, so any other local account can read them for as long as they remain. Separately, if another account creates the upload name first, every redirect in omarchy-upload-log fails closed (no set -e) while curl still uploads their file and prints the URL as this user's log.

(fs.protected_regular=1 / fs.protected_symlinks=1 and the sticky bit already stop the planted-0666, symlink-redirect, and mid-flight swap variants that an earlier draft of this body claimed.)

  • omarchy-debug now writes under $XDG_RUNTIME_DIR (0700, per-user), falling back to $XDG_STATE_HOME/omarchy where there is no session runtime dir, and pre-creates the file at mode 600 (install -T) so the fallback is not exposed by a traversable home either.
  • omarchy-upload-log stages in a mktemp -d directory and removes it on exit. Nothing about what gets uploaded changes.
  • Migration 1788398495.sh removes leftover /tmp/omarchy-debug.log, /tmp/upload-log.txt, and /tmp/system-info.txt when they are regular files owned by the current user (symlinks and other-owned files are left alone).

The two agent-skill docs that named /tmp/omarchy-debug.log are updated to match.

Verification

test/shell.d/diagnostics-staging-test.sh stubs the collectors and curl, then runs both real commands:

ok - omarchy-debug writes its log under the per-user runtime directory
ok - the debug log is readable only by its owner
ok - the debug log still collects what it collected before
ok - omarchy-debug no longer names a world-writable path
ok - the uploaded payload is not staged at a shared, predictable name
ok - the staging directory is reachable only by its owner
ok - the staging directory is cleaned up after the upload
ok - omarchy-debug fails loudly when the log file cannot be created

test/shell.d/legacy-diagnostics-tmp-migration-test.sh covers the migration (owned leftovers removed, idempotent, unrelated files kept, symlinks refused, other-owned skipped).

It asserts on the path curl was actually handed, not just on the source, and it fails on the unfixed scripts at the first assertion.

Two related paths I did not touch here, to keep this to one change — say the word and I will follow up: omarchy-update logs the whole update through script to /tmp/omarchy-update.log, and omarchy-install-gaming-battlenet writes /tmp/omarchy-battlenet-installer.log.

September 12 review follow-up

The diagnostic heredoc write is now checked separately from empty-file creation. A failure to write the body exits nonzero with an error, preventing successful empty/partial --print output after an exhausted filesystem. The existing legacy-file migration was verified again.

Current focused checks: 9 diagnostics assertions pass; migration checks pass (other-owner case skipped because chown is unavailable). These ran on macOS with stubbed collectors/upload and a local install compatibility wrapper for GNU -T; native Arch validation remains outstanding. Bash syntax and diff checks pass.

omarchy-debug wrote `sudo dmesg`, the journal and a full hardware
inventory to /tmp/omarchy-debug.log, and omarchy-upload-log assembled
what it publishes at /tmp/upload-log.txt and /tmp/system-info.txt. /tmp
is world-writable, so any other local account can create those names
first and read what the command collected, plant a symlink and redirect
the write, or swap the upload payload between the last append and the
POST.

Put the debug log under the per-user runtime directory at mode 600, and
stage the upload in a mktemp directory that is removed on exit.
Copilot AI balanced review requested due to automatic review settings August 26, 2026 11:36

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

Secures diagnostic staging against predictable /tmp path attacks.

Changes:

  • Stores debug logs in a private per-user location.
  • Uses a temporary upload staging directory with cleanup.
  • Adds regression tests and updates documentation.

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 3 comments.

Show a summary per file
File Description
bin/omarchy-debug Secures debug-log storage.
bin/omarchy-upload-log Privately stages upload payloads.
test/shell.d/diagnostics-staging-test.sh Tests staging security and cleanup.
default/agents/skills/omarchy/contributing.md Updates diagnostic-path guidance.
default/agents/skills/diagnose-crash/reporting.md Updates crash-reporting guidance.

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

GNU mktemp -d with no template creates its directory inside /tmp, so the
test rejected the very implementation it was meant to check. The
boundary is that the directory is unpredictable and only its owner can
enter it, so read its mode from inside the upload, while it still
exists, and keep rejecting the shared fixed name it replaced.

Name the state-directory fallback in both skill docs too: without a
session runtime directory the log is written there, not under
XDG_RUNTIME_DIR.
@chessing234

Copy link
Copy Markdown
Contributor Author

good catch on the mktemp one — gnu mktemp -d puts its dir under /tmp, so that assertion would have failed on arch against the fixed script. now checks the staging dir is 0700 and isn't the old shared name, read from inside the upload while it still exists. docs name the state-dir fallback too.

Moving off /tmp gives the log a directory that can fail to exist: a stale XDG_RUNTIME_DIR from a revoked session, an inherited one belonging to another uid, a full runtime tmpfs, a read-only home on the fallback path. The script runs without `set -e`, so `mkdir -p` and `install` failing left every later write failing too and `omarchy debug --no-sudo --print` -- the form the agent skills tell agents to use -- exiting 0 with nothing on stdout. Verified on an Omarchy machine before and after: an unwritable log_dir printed four unrelated errors and returned success, and now returns 1 with one error.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 56842ec by Claude Opus 5 in Claude Code, with a second pass from Codex at xhigh reasoning. Everything executed ran on a disposable Omarchy VM, never on the machine doing the review. The change is right; I pushed one fix to your branch and there are two things worth correcting in the text rather than the code.

Pushed: 56842ec — Fail loudly when the debug log cannot be created. Moving off /tmp gives omarchy-debug a log directory that can fail to exist — a stale XDG_RUNTIME_DIR from a revoked session, one inherited from another uid, a full runtime tmpfs, a read-only home on the fallback path — and the script has no set -e, so mkdir -p and install failing left every later write failing too. Measured on a worker with an unusable XDG_RUNTIME_DIR: omarchy debug --no-sudo --print printed four filesystem errors and exited 0 with nothing on stdout. That is the form default/agents/skills/omarchy/SKILL.md:222 tells agents to always use, so a diagnostic collector would get an empty string and a success code. With the guard it exits 1 with one error, and the normal path is unchanged. Codex reached the same defect independently and traced the rest of the menu: "View log" reported a missing file and exited 0, and "Save in current directory" printed ✓ Log saved to … after cp had failed. That last one is pre-existing at line 103 and is unreachable through this path once creation is checked, so I left it alone.

The threat model overstates what /tmp allowed. I tested each claimed vector on an Omarchy machine with a real second unprivileged account. fs.protected_regular=1 and fs.protected_symlinks=1 are both on by default there, so an attacker who pre-creates /tmp/omarchy-debug.log mode 0666 makes the victim's redirect fail with Permission denied rather than succeed into their file; the symlink variant fails the same way; and the sticky bit stops them unlinking or swapping the upload payload between the last append and curl. What is real, and is enough on its own, is the plain disclosure — the old code created the file 0644 under the default umask and left it there until reboot, and I confirmed a second local user simply reading a victim's /tmp/omarchy-debug.log full of sudo dmesg and journal output. Worth rewording the body and the comment at bin/omarchy-debug:29-33 so the next reader is not relying on a mechanism the kernel already blocks. #8367 carries the same three claims.

bin/omarchy-upload-log:14 is inaccurate. It says mktemp "picks an unpredictable name and creates it 0600". mktemp -d creates the directory 0700; the two staging files inside land 0644 from the redirections under the default umask — checked on a worker. The protection is the directory, which is exactly what your revised test now asserts, so only the comment is wrong. Codex contributed this one.

Checked and clean. Nothing else in the repo or in what it ships reads the three old paths; the only remaining mentions are the negative assertions in the new test. The install upload is unaffected — its payload comes from /var/log/archinstall/install.log and the two omarchy-install.log locations at bin/omarchy-upload-log:75-77, with TEMP_LOG purely an output buffer — and running omarchy-upload-log install end to end against a stubbed curl handed the upload 10354 bytes containing both the system-info header and the install log, with nothing left in /tmp. The EXIT trap is safe: bash resets traps in the command-substitution subshell that runs curl, so it fires only after the upload returns. And install -m 600 /dev/null defeats a pre-planted symlink where a plain > follows it — I planted one both ways and only the redirect followed.

Tests, all on a disposable Omarchy VM: test/shell.d/diagnostics-staging-test.sh 7/7 at the pushed head, ./test/cli clean, and the same test run against the base versions of the two scripts fails at its first assertion — so it is a real regression test, not a tautology.

Related: #7995, open since 24 Aug, changes the same two scripts, both of the same doc files, and adds a test at the identical path test/shell.d/diagnostics-staging-test.sh. The two cannot both merge. It reaches wider — it also moves /tmp/omarchy-update.log and the Battle.net installer log, the two paths your body says you deliberately left — and it makes the debug log ephemeral, mktemp plus a delete-on-exit trap, where yours keeps a stable per-user path a user can still point someone at afterwards. Which shape is wanted is the maintainer's call, so both are waiting on that rather than on either author.

Codex's independence is not currently guaranteed — it can read this session's own working notes — so treat its agreement on the ignored-failure defect as agreement rather than confirmation. The mktemp -d mode correction is something it found that this review had not, and stands on its own.

Two claims in the comments were wrong, both caught on a live worker with
protected_regular and protected_symlinks on by default: a pre-created
world-writable /tmp file makes the redirect fail closed rather than
succeed into it, and the same for a symlink. What is real on its own is
plain disclosure of the file left behind at the default umask, and (for
the upload) the payload swap between the last write and the POST, which
the staging directory's own mode -- not a directory outside /tmp -- is
what stops.

@itz4blitz itz4blitz 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.

Reviewed against issue #8367 — this is solid and I'd merge it. Specifics worth keeping when it lands:

  • The threat model in the comment is precise: it isn't just the clobber, it's that /tmp/omarchy-debug.log holds sudo dmesg, the journal and a hardware inventory the invoking uid can't otherwise read, world-readable by umask, surviving until reboot. Relocating to the 0700 per-user runtime dir fixes both halves at once.
  • The install -m 600 /dev/null pre-create is the right trick — it guarantees the mode regardless of umask and lets the writers truncate an already-private file.
  • The fail-fast on an unusable log_dir (stale XDG_RUNTIME_DIR, full tmpfs, read-only home) with --print exiting nonzero instead of silently printing nothing is the kind of thing that's invisible until it eats someone's bug report.
  • The upload-log half closing the swap-window between staging and publishing is a real fix, not belt-and-braces: the payload is what gets published under the user's name, and a fixed /tmp name made it replaceable by anyone between the last write and the curl.
  • The curl-stub test asserting the payload path and the directory mode rather than implementation details is well aimed.

Two non-blocking suggestions:

  1. The fallback branch (XDG_RUNTIME_DIR unset → state dir) has no test coverage — only the runtime-dir branch is exercised. A env -u XDG_RUNTIME_DIR run with a fake HOME asserting the state-dir path would pin the resolution that omarchy-debug --print's own error message depends on.
  2. diagnose-crash/reporting.md now tells agents the log is at $XDG_RUNTIME_DIR/omarchy-debug.log; if a helper ever needs to find that file programmatically, the resolution is now duplicated in prose in two docs. Worth a shared note if a third copy appears.

For coverage of the same class in files this PR doesn't touch: #8429 (update transcript, also feeds omarchy-update-analyze-logs on readback) and #8430 (Battle.net installer log) follow this PR's resolution and test style.

@chessing234

Copy link
Copy Markdown
Contributor Author

leaving the unset-runtime-dir test; the fallback path is the same as the error message.

The comment claimed another account could pre-create the fixed name and read what the upload gathered, or replace the staged file before the POST. Neither works on a stock Omarchy. Measured with a second unprivileged account on an Omarchy VM: fs.protected_regular makes the victim's redirect into an attacker-owned file fail with EACCES, the symlink variant fails the same way, and /tmp's sticky bit refuses the attacker an in-place write, an unlink and a rename over the 0644 file the victim did create. The only attempt that succeeded was reading that file, which is the vector the sibling comment in omarchy-debug already names.

What pre-creating the name does do is worse than the comment said and in the other direction. Nothing here runs under `set -e`, so every failed redirect is ignored and `curl -F file=@/tmp/upload-log.txt` sends the attacker's file instead: run end to end against the base script with a stubbed curl, the upload was handed 55 bytes of attacker text and printed it as a successful upload of the user's log, at a URL the user then shares in a bug report. Staging in mktemp's directory closes that with the rest of it.

Co-Authored-By: Codex XHigh <noreply@openai.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at b715f947 by Claude Opus 5 in Claude Code, with a second pass from Codex at xhigh reasoning. Everything executed ran on a disposable Omarchy VM. Only the delta since 56842ec is covered here.

Both previous findings on the code are answered. bin/omarchy-upload-log no longer claims mktemp creates the files 0600 — that one is fixed. The threat model is fixed in bin/omarchy-debug:29-34, which now names the disclosure vector and no blocked one. The upload comment b715f947 wrote in its place kept two vectors that do not work, so I pushed a correction.

Pushed: ac8e454 — Name the /tmp vectors this actually closes. The comment said another account could "create the file first and read what the upload gathered", or "replace it after the fact". Measured on a worker with a real second unprivileged account: the pre-create makes the victim's redirect fail with Permission denied (fs.protected_regular=1, on by default), the symlink variant fails the same way, and against the 0644 file the victim did create the attacker's in-place write, rm and mv-over were all refused by the sticky bit. Reading that file is the only thing that worked — which is exactly what your omarchy-debug comment now says, so the two were contradicting each other, and the upload one was contradicting b715f947's own commit message.

What pre-creating the name actually does is worse, and in the other direction. Codex went after this and it holds up end to end. omarchy-upload-log has no set -e, so on the base script an attacker-owned /tmp/upload-log.txt makes every redirect fail and be ignored, and curl -F file=@/tmp/upload-log.txt then uploads their file. Run against the base version with a stubbed curl on the worker, the upload was handed 55 bytes of attacker text and printed ✓ Log uploaded successfully! with a URL — a user pastes that into a bug report believing it is their own journal. Your change closes it along with the disclosure, and the comment now says so.

Still open, and only you can fix them. The PR body carries the same two disproved mechanisms — "redirect the write through a symlink, or swap the upload payload between the last append and the curl -F file=@" — and so do points 1 and 2 of #8367. The real case is stronger than the one written there, so it is worth the edit rather than a retraction. The body's Verification block is also stale: it lists six assertions including "the uploaded payload is staged outside /tmp", and the test now runs seven, having correctly dropped that claim in cdf1ee9e.

One finding I did not push, because it is unchanged from the base and fixing it would widen a security change into general error handling: bin/omarchy-debug:52 ignores the here-document's own exit status. The guard at :41 covers a log directory that cannot be created, which is what this PR introduced, but a write that fails partway — a full runtime tmpfs, a quota, a remount — still leaves --print printing a truncated file and exiting 0. Codex found it; your call whether it belongs here or in a follow-up.

Your three replies check out. GNU mktemp -d does stage under /tmp, and the test now asserts mode 700 and rejects the old shared name rather than requiring the path to leave /tmp; both skill docs name the state-directory fallback. Nothing there needed changing.

Tests, all on a disposable Omarchy VM, at the pushed head: test/shell.d/diagnostics-staging-test.sh 7/7 through the shell-test wrapper, ./test/cli clean. Codex could not run anything — its sandbox has a read-only /tmp — so its threat-model conclusions are reasoning from the kernel source, and the measurements above are mine. It reached the comment defect and the ignored-error upload path independently of this review, and its independence is not currently guaranteed, but the second of those is something this review had not reasoned about and stands on its own.

Waiting on the maintainer, not on you. #7995 is still open and still changes the same two scripts, both doc files, and adds a test at the identical path, so the two cannot both merge. Which shape is wanted is a call for the maintainer.

@ErikMelton

Copy link
Copy Markdown
Member

The new paths secure future runs, but existing /tmp/omarchy-debug.log, /tmp/upload-log.txt, and /tmp/system-info.txt remain readable after upgrading; potentially until reboot or tmpfiles cleanup. Please add a migration that safely removes legacy files owned by the current user.

The new staging paths secure future runs, but existing
/tmp/omarchy-debug.log, /tmp/upload-log.txt, and /tmp/system-info.txt
stay readable until reboot or tmpfiles cleanup. Drop ones owned by the
current user, leaving symlinks and other-owned files alone.
@chessing234

Copy link
Copy Markdown
Contributor Author

@ErikMelton added a migration that deletes those three /tmp leftovers when they are regular files owned by the current user; symlinks and other-owned files are left alone.

The comment credited the -L guard with stopping a redirected unlink of someone else's target. That cannot happen: `rm` never follows a symlink, and with fs.protected_symlinks=1 the `-f` test does not resolve another uid's link in sticky /tmp either -- measured on an Omarchy VM with a second unprivileged account, where the migration no-ops with the guard and without it. What the guard does prevent is the ordinary case: `-f` and `-O` both follow a symlink, so a link this user left at a legacy name passes both and gets unlinked in place of a leftover, which the same measurement showed happening once the guard is removed. Also stop calling 0644 a umask.

Co-Authored-By: Codex XHigh <noreply@openai.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 8029186 by Claude Opus 5 in Claude Code, with a second pass from Codex at xhigh reasoning. Everything executed ran on a disposable Omarchy VM. Only the delta since ac8e454 is covered here — the migration and its test.

The migration is right. Run the way omarchy-migrate runs it (bash -euo pipefail) against a real /tmp on a worker: the three 0644 leftovers go, a second run exits 0 with nothing to do, a symlink at omarchy-debug.log and the file it points at are both left alone. The guards are safe under errexit — a false [[ -L ]] is the non-final command of an && list, so it does not fire, and only rm can leave the function non-zero, which is the right thing to stop the queue on. Mode 0644, no shebang, timestamp after the previous migration. The test is not a tautology: a no-op migration fails it at the first assertion, and removing the -L guard fails leaves a symlink at the legacy name.

Pushed: 8029186 — Say what the symlink guard actually prevents. The comment credited the -L guard with stopping a redirected unlink of someone else's target. Measured on an Omarchy VM with a second unprivileged account: with a nobody-owned symlink at /tmp/omarchy-debug.log pointing into this user's home, fs.protected_symlinks=1 already makes [[ -f ]] false, so the migration no-ops with the guard and without it — and rm never follows a symlink anyway. What the guard does prevent is the ordinary case, which is a better reason than the one written: -f and -O both follow a symlink, so a link this user left at a legacy name passes both, and with the guard removed the same run unlinked it while the target survived. The comment now says that. Codex found this one; it is the third time in this PR that a mechanism the kernel already blocks got written down next to code that is correct for a different reason.

One thing worth knowing, not pushed. bin/omarchy-debug:108 still writes ./omarchy-debug.log for "Save in current directory". Someone who ran omarchy debug from /tmp and saved there owns a regular /tmp/omarchy-debug.log, and the migration will delete it on the next omarchy update. It is a regenerable log in a scratch directory and there is no way to tell it apart from a leftover, so this may well be the right trade — but it is a deliberate one, and it is not written down anywhere. Codex found it.

Two test blind spots, also from Codex, both non-blocking. The symlink fixture at test/shell.d/legacy-diagnostics-tmp-migration-test.sh:42 is left in place for the last block, so on a runner that can chown (root) the other-owner assertion never reaches upload-log.txt and passes vacuously; and there is no owned-directory fixture, so dropping the -f guard would leave the test green even though a directory at a legacy name would make rm fail and strand the migration permanently pending. Neither is a defect in the shipped code.

Previous findings. The mktemp comment at bin/omarchy-upload-log is fixed and stays fixed. Two are still open and only you can close them: the PR body still carries the two disproved mechanisms — "redirect the write through a symlink, or swap the upload payload between the last append and the curl -F file=@" — as do points 2 and 3 of #8367, unedited since 26 Aug. The body's Verification block still lists six assertions under the old wording, the test now runs seven, and the body does not mention the migration at all. The unchecked here-document status at bin/omarchy-debug:52 is unchanged and still your call; it is inherited from the base script, not introduced here.

No new review comments since the last pass. The three from Copilot and your three replies all predate it and were checked then; I re-read both skill docs and the staging test against this head and they still hold.

Tests, on a disposable Omarchy VM at the pushed head: ./test/cli clean, test/shell.d/legacy-diagnostics-tmp-migration-test.sh 5/5 and test/shell.d/diagnostics-staging-test.sh 7/7 through the shell-test wrapper. Codex could not run anything — its sandbox has a read-only /tmp — so its conclusions are reasoning and every measurement above is mine. Its independence is not currently guaranteed, but the symlink rationale, the Save in current directory collision and the two test gaps are all things this review had not reasoned about, and they stand on their own.

Waiting on the maintainer. #7995 is still open and still changes both scripts, both doc files, and adds a test at the identical path, so the two still cannot both merge. One thing has changed in the comparison: this PR now cleans up the leftovers on existing installs and #7995 does not — it adds no migration — while #7995 still reaches wider, covering omarchy-update and the Battle.net installer log, which here are split out as #8429 and #8430.

The guard that fails loudly when the debug log cannot be created calls `install` without `-T`, so a directory at `$LOG_FILE` is treated as a destination directory: `install` writes `$LOG_FILE/null`, reports success, and the guard passes. The heredoc then fails, and because nothing here runs under `set -e`, `omarchy debug --no-sudo --print` exits 0 having printed nothing — measured end to end, and the exact outcome the guard was added to prevent. `-T` makes `install` require that the destination be one file, so the guard fires instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Codex XHigh <noreply@openai.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 8029186 by Claude Opus 5 in Claude Code, with a second pass from Codex at xhigh reasoning. Everything executed ran on a disposable Omarchy VM, never on the machine doing the review. The head had not moved since the last pass, so this covers one defect in a commit I pushed earlier and one thing in the review thread that would mislead whoever reads it next.

Pushed: c9d6707 — Reject a directory at the debug log path. The guard I added in 56842ec calls install without -T. GNU install treats an existing directory at the destination as a destination directory: with a directory at $XDG_RUNTIME_DIR/omarchy-debug.log it writes omarchy-debug.log/null at mode 600 and returns success, so the guard passes. The heredoc at bin/omarchy-debug:54 then fails, and with no set -e the script reaches the explicit exit 0 at :82 — measured on a worker, omarchy debug --no-sudo --print returned status 0 with zero bytes on stdout, which is precisely the failure 56842ec was written to stop. -T makes install require a single-file destination, so the guard fires instead. A new eighth assertion in diagnostics-staging-test.sh pins it: with -T removed the suite fails there with status: 0, bytes: 0. Only you or root can create that directory, so it is not attacker-reachable — it is a hole in my own guard rather than in your change. Codex reached it independently and the -T form is its suggestion, so it is on the commit as a co-author.

@itz4blitz's review of 26 Aug, which I should have answered then. The endorsement holds and the reading of the disclosure is right, but one mechanism in it is not. It credits the upload half with closing "the swap-window between staging and publishing", on the grounds that "a fixed /tmp name made it replaceable by anyone between the last write and the curl". Measured on an Omarchy VM with a real second unprivileged account: against a victim-owned 0644 /tmp/upload-log.txt, the attacker's in-place write, rm and mv-over were all refused by the sticky bit. There is no swap window. What the fixed name actually allowed runs the other way and is worse — the attacker creates the name first, every redirect in this script then fails silently for want of set -e, and curl -F file=@ uploads their file under the user's name and prints the URL as a success. This PR closes that along with the plain 0644 disclosure, which is a stronger case than the one in the review. The separate suggestion there — that the unset-XDG_RUNTIME_DIR fallback branch has no test coverage — is fair and still true at this head; I have not added one, since you have already said you would rather leave it.

Two from Codex I checked and did not act on. mktemp -d honours $TMPDIR, so a TMPDIR naming a directory another account owns lets them rename the staging directory out from under the fixed child names before the first write. That is true of mktemp everywhere and needs the user's own environment to already point at attacker-owned storage, which is a lost machine well before this script runs; nothing here introduces or could reasonably defend it. And migrations/1788398495.sh:12 reads OMARCHY_LEGACY_DIAGNOSTICS_TMP from the environment, which omarchy-migrate passes through to the migration, so a stale export under that exact name would aim the three rms at another directory. It stays bounded to regular files this user owns carrying those three basenames, and no other account can set it — worth knowing the test seam is live in production, not worth a change.

Tests at the pushed head, all on a disposable Omarchy VM: ./test/cli clean, test/shell.d/diagnostics-staging-test.sh 8/8 and test/shell.d/legacy-diagnostics-tmp-migration-test.sh 5/5 through the shell-test wrapper. Codex ran no tests of the suite, so its conclusions are reasoning and every measurement above is mine. Its independence is not currently guaranteed, but the TMPDIR parent race and the migration environment seam are things this review had not reasoned about, and it reached the install defect on its own terms.

Unchanged since the last pass, and only you can close them: the PR body and points 2 and 3 of #8367 still carry the two disproved mechanisms, and the body's Verification block still lists six assertions for a suite that now runs eight and no longer claims the payload leaves /tmp. #7995 still changes both scripts, both doc files and adds a test at the identical path, so the two still cannot both merge — that one is the maintainer's call, not yours.

@chessing234

Copy link
Copy Markdown
Contributor Author

migration is on the tip (1788398495.sh) — removes those three /tmp leftovers when they are regular files this user owns; symlinks and other-owned files left alone. also updated the pr body / #8367 to match the measured threat model.

@ErikMelton

Copy link
Copy Markdown
Member

Hello,

  • P2: Verify the diagnostic body was written; bin/omarchy-debug lines 43-45. Writing /dev/null with install can succeed on an exhausted runtime tmpfs because it requires no data blocks. The later heredoc can then fail, but its status is ignored, and --print exits successfully with an empty or partial log.

@chessing234

Copy link
Copy Markdown
Contributor Author

@ErikMelton Fixed the unchecked diagnostic body write in 8d0d802: failure now exits nonzero before print/upload. The requested legacy-file migration is already included and was verified again. Nine diagnostics assertions pass; migration checks pass with the other-owner case skipped locally. The body records the macOS compatibility runner and remaining native Arch validation. Could you re-review the update?

@chessing234

Copy link
Copy Markdown
Contributor Author

folded into #12109 for easier review.

chessing234 added a commit to chessing234/omarchy that referenced this pull request Sep 25, 2026
chessing234 added a commit to chessing234/omarchy that referenced this pull request Sep 25, 2026
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.

[Security] omarchy debug and omarchy upload log stage root-collected diagnostics at predictable /tmp paths

5 participants