Repository navigation
Conversation
`omarchy debug` published to a fixed name in world-writable /tmp with a plain redirection, so a symlink another local process left there was written through: running `omarchy debug` truncated and replaced whatever it pointed at, in any file the invoking user could write. The log the redirection created was world-readable, and carries the hostname, the hardware inventory, every explicitly installed package and this boot's journal. `omarchy upload-log` had the same shape in two files, and is the only Omarchy script that stages host-identifying data in /tmp. Stage each log in a private file in the same directory and publish it with a rename, which replaces the name instead of following it, and publish it owner-only. The staging file stays in the destination's filesystem so mv renames rather than falling back to a copy that would open the destination the unsafe way.
[High impact] The PR appears safe to merge; no new actionable issues were found. SummaryThe PR creates private log files before publishing or uploading them.
Reviews (5) · Last reviewed commit: "Fall back to the staged log when the ren..." · Reviewed by Greptile |
… test Greptile found three problems with the previous commit: - omarchy-upload-log installed its cleanup trap only after both mktemp calls, so a second failure -- /tmp filling up between them -- exited with the first file still in place. Remove it on the failure path. - The test's cleanup removed every file matching the staging prefixes and deleted the legacy fixed paths outright, so a helper running at the same time could lose its working file and any pre-existing log was destroyed. Copy the fixed paths aside and restore them, and remove only the staging files the run itself created. - The upload assertions only checked that the old symlinks survived, so a missing or world-readable upload would still have passed. Have the curl stub report on the file it was handed and assert that it existed, carried the diagnostics, was owner-only while it sat in /tmp, and was no longer one of the fixed names. Co-Authored-By: Davedes83 <me@email.com>
|
All three addressed in P1 — tests delete unrelated logs. Real, and worse than I first wrote. The test now copies all three fixed paths aside before it starts and restores them on the way Verified by pre-seeding four artifacts — a real P2 — failed uploads leave files. Correct, and my Confirmed with a P2 — upload test ignores the file. Agreed, that assertion was hollow. The Note the mode check is now done inside the stub, at upload time — checking afterwards was never Suite is 13 assertions, passes on the fix and fails on the unpatched scripts. Full |
Greptile was right that the previous cleanup could still delete a helper's working file: snapshotting the staging names before the run only protects files that already existed, so a helper that started after the snapshot lost its file to the diff. Replace the scan with an mktemp stub that records every path it hands out. The test now removes, and asserts on, exactly those paths, so it can neither touch a concurrent helper's file nor a stale one from an earlier run. Verified by running the suite against a background process creating 400 staging-named files in /tmp throughout: all 400 survive.
|
Greptile was right that the P1 fix was incomplete — it only protected files that existed The scan of Verified by running the suite against a background process that created 400 staging-named files in And with the fixed paths plus a decoy pre-seeded before the run, all four come back One note on my own testing, since it bit me twice: Suite is now 14 assertions. Full |
|
Thanks for the thorough tests. Two things worth knowing before review:
if ! mv -fT "$STAGED_LOG" "$LOG_FILE" 2>/dev/null; then
LOG_FILE=$STAGED_LOG
trap - EXIT
echo "Note: $LOG_FILE is used instead of /tmp/omarchy-debug.log" >&2
fi |
|
Read, not yet run: the classification of this pull request is unsettled, so no class label went on and nothing was tested on a worker. Two models classified it separately and disagreed. Codex Medium read it as a bug fix, going by the description. I (Claude Opus 5.5) read it as an enhancement, because the maintainer declined this family of changes on 2026-10-04 when closing #7995, #8367 and #12109, which covered the same Not checked: @jandrusk's point that Waiting on the maintainer to decide whether this is wanted given that earlier decision. |
|
On the classification question -- both readings are fair, and I'm not going to argue the second one away. I did check the underlying claim rather than take it on trust:
What survives that is the half So I'm treating this as one robustness change: don't write through a name you don't own, don't leave the result readable, don't leave the staging file behind. Happy to re-title it that way if that's what lands. I don't want to re-open #7995 or #8367. On @jandrusk's EPERM point -- correct, and thank you, because it's a regression I introduced rather than a pre-existing wart. On #14109 and #14479: happy to fold in @jandrusk's per-user directory and drop the Still not touched, and I agree with leaving them: |
/tmp is sticky, so mv -fT fails with EPERM when the published name is already owned by another uid -- a stale log from a different account on a shared machine. The previous commit exited 1 in that case, leaving no log at all, which is worse than the behaviour it replaced: the old script always produced one, even when it followed a symlink. Keep the staged file as the log instead, say on stderr where it went, and drop the exit trap so the file survives as the published log. The test stubs mv to refuse rather than creating a second-uid-owned file, so it runs without root. The fallback deliberately survives the run, so it is removed before the "leaves no staging file behind" assertion, which would otherwise read it as a leftover. Suite is 16 assertions, passes on the fix and fails against the unpatched script. Full test/shell still 291 files with the same 10 pre-existing failures. Co-Authored-By: Davedes83 <me@email.com>
d0906fb to
ae6c3da
Compare
|
Correction: the suite is 16 assertions, not the 17 I said above and in the commit message. I miscounted when adding the refused-rename test -- it contributes two Nothing else changes: the fallback and its behaviour are as described. |
|
Looked at again because the head moved to Two models classified this head separately and still disagree. Codex Medium reads it as a bug fix. I (Claude Opus 5.5) read it as an enhancement. In the 2026-10-04 decision closing #7995, #8367 and #12109, the maintainer said the default Since the last comment, the #14479 is also open and changes the same two scripts in a different way, moving the logs to a per-user runtime directory. The two will conflict. Choosing between them, or taking neither, is the maintainer's decision. This is waiting on the maintainer to decide whether this housekeeping is wanted, given that earlier decision, and if so, which of #14078 and #14479. |
Summary
omarchy debugpublished its log to a fixed name in world-writable/tmpwith a plain redirection:Three things were wrong with that, in descending order of how much they matter in practice:
The log was world-readable. The redirection created it mode
0644, and it carries the hostname, the fullhardware inventory, every explicitly installed package and
journalctl -b -p 4..1for the boot, so every localuid could read all of that until the next reboot.
fs.protected_regulardoes not cover this — it restrictsopening for writing, not reads.
The name is fixed and shared, and a redirection follows it. Whatever another local process left at that
name was written through, so running
omarchy debugtruncated and replaced whatever it pointed at, in anyfile the invoking user can write:
On a default install this is not reachable across a uid boundary:
fs.protected_symlinks=1blocks one uidfollowing another's symlink in a sticky directory, and the demonstration above plants the link as the same
uid that then runs
omarchy debug. It is included as the invariant to hold, not as a live exploit. Amaintainer declined this family of change on 2026-10-04 in Stage diagnostics logs privately instead of at fixed /tmp paths #7995 and [Security] omarchy debug and omarchy upload log stage root-collected diagnostics at predictable /tmp paths #8367, and I am not re-opening that —
what I am asking for is the housekeeping those discussions called reasonable but not urgent.
The log stayed behind. Nothing removed it between runs.
omarchy upload-loghad the same shape in two files (/tmp/upload-log.txt,/tmp/system-info.txt) and is theonly Omarchy script that stages host-identifying data in
/tmp. It has no caller in the tree at the moment, soit is fixed here rather than left to be wired up later.
Change
Stage each log in a private
mktempfile in the destination's directory, then publish it withmv -fT. Therename replaces the name instead of following it, and keeping the staging file in the same filesystem matters:
cross-device
mvfalls back to a copy that reopens the destination the unsafe way. The published log is0600,since what it holds is the machine's identity.
/tmpis sticky, so the rename fails withEPERMwhen the published name is already owned by another uid — astale log left by a different account on a shared machine. The code falls back to the staged file and says so on
stderr, rather than exiting with no log at all, which would be worse than what the pre-fix script did: it always
produced one, even when it followed a symlink.
bin/omarchy-debugkeeps its documented/tmp/omarchy-debug.logpath —agents/skills/omarchy/SKILL.md,agents/skills/omarchy/contributing.mdandagents/skills/diagnose-crash/reporting.mdall name it — so this isa same-path fix, not a move. @jandrusk has a per-user directory approach open in #14479; I am deliberately leaving
it out of this branch rather than landing three overlapping fixes, but I would fold it in if that is the
preferred direction.
Tests
test/shell.d/debug-log-test.sh, 16 assertions:--printstill emits the logomarchy debugstill exits 0 and still produces a log when the rename is refused, and says where the logwent instead
omarchy upload-logleaves/tmp/upload-log.txtand/tmp/system-info.txtuntouched, collects into privatetemporaries, removes them, and still uploads and reports the URL
curlwas actually handed existed, carried the diagnostics, was0600while it sat in/tmp, andwas not one of the two fixed names
Collection is stubbed, so the test needs no sudo, no network and nothing installed beyond coreutils. The
refused-rename test stubs
mvto fail rather than creating a file owned by a second uid, so it runs withoutroot: that covers the fallback path, not the kernel's actual
EPERM.The new test fails against the unpatched scripts:
Full suite,
test/shell(291 files) andtest/cli: no new failures. 10test/shellfiles and 1test/cliassertion fail identically on a clean
quattrocheckout —config-test,kernel-headers-migration-test,launch-browser-test,network-captive-portal-test,omarchy-kernel-migration-test,passwordless-grant-lifecycle-test,screenshot-sanity-test,snapper-test,unowned-system-paths-test,video-background-test, andvscode generated theme references current theme file. Verified by re-running eachagainst the pre-fix scripts.
Note on severity
This is a robustness and housekeeping change, and it should be reviewed as one. The disclosure in the first
bullet above is real on a multi-user machine, but the other party is another local uid: a stock Omarchy install
has a single human account in
wheel, and the sysctls block the cross-user symlink follow in the secondbullet. I would not claim this as a privilege escalation.
The unprivileged services on the box do share the host
/tmp— only 39 of 382 shipped.serviceunits setPrivateTmp=yes— so a name left there by another process is reachable. What the sysctls prevent is thefollow, not the plant.
Two related things I did not touch, in case you want them handled separately:
bin/omarchy-update:88writes/tmp/omarchy-update.logthroughscript, which opens the typescript withO_CREAT|O_TRUNCand so follows a symlink too. Different sink, and it sits close to in-flight update work.bin/omarchy-update-analyze-logs:5reads that same fixed path.