Repository navigation
Pin trusted PATH in privileged DNS helper - #8172
Conversation
There was a problem hiding this comment.
Pull request overview
Hardens privileged DNS operations against PATH hijacking.
Changes:
- Pins root execution to trusted system paths.
- Adds poisoned-PATH regression coverage.
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 1 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
bin/omarchy-dns |
Pins PATH after privilege elevation. |
test/shell.d/dns-sudoers-test.sh |
Tests trusted PATH behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
A dev link prepends a user-writable checkout bin/ to sudo's secure_path, so the passwordless `omarchy-dns Cloudflare` sudoers rule lets root resolve a bare helper (dirname, install, tee, nmcli, ...) out of that checkout — turning checkout-write access into arbitrary root execution. Pin PATH to trusted system directories once EUID is 0, leaving the unprivileged wrapper phase free to locate sudo/pkexec on the caller's PATH. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01YUWoHbBoKMjsjV6X3nu1H5
464f59c to
e7d8f89
Compare
The EUID assertion matched `(( EUID == 0 ))` anywhere in the file, and require_root has carried that exact test since long before the pin existed. Deleting the pin left the assertion passing, so it stood for nothing: a run with the pin neutered reached the behavioural probe with both greps green. Anchor on the unindented guard and require the pin to be the line it opens, which no other construct in the script satisfies. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Co-Authored-By: Codex XHigh <[email protected]>
`fail` ends the file, so a sandbox or hardened kernel that refuses unprivileged user namespaces did not just lose the probe — it took the two elevation assertions below it down as well, reporting a product defect where there was only a missing capability. The non-graphical suites are meant to run on any machine and treat a skip as a passing test, the way require_compositor and plugin-add-test.sh already do. Gate the probe on the namespace it needs and say so when it is absent; the static checks above and the elevation checks below run either way. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Co-Authored-By: Codex XHigh <[email protected]>
|
Reviewed, and the escalation is real. Two defects in the new test, both fixed and pushed to this branch.
The behavioural probe itself earns its place and I left it alone: neuter the pin and the poisoned One thing left to you rather than fixed, since it is your prose: the comment at Your two Copilot comments were both fair against A second opinion from Codex at xhigh reasoning reached the same two test findings and no others, found no defect in the production change, and contributed the Everything ran on a disposable VM rather than a machine that matters: 🤖 Generated by Opus 5 in Claude Code. Reviewed by Codex XHigh. |
Backport of the DNS PATH pin (PR #8172 by @mdisec, merged to quattro as 4637735) onto the v4-0-1 release branch. omarchy dev link prepends a user-writable checkout's bin/ to sudo's secure_path so privileged Omarchy commands resolve to the development versions, and that reaches the subprocesses they launch too. This branch carries the same passwordless grant -- etc/sudoers.d/omarchy-dns lets wheel run /usr/bin/omarchy-dns Cloudflare, Google and DHCP without a password -- so the packaged script ran as root while resolving bare helpers (dirname, install, tee, rm, nmcli, systemctl, awk) through the caller's secure_path. Write access to a dev checkout became arbitrary root execution, with no password prompt in the way. Pin PATH to trusted system directories once EUID is 0. The restriction lands only after elevation, so the unprivileged wrapper phase keeps the caller's PATH and can still find sudo or pkexec; every helper the privileged half uses is a system utility, so it needs nothing from the checkout. Clean cherry-pick: both files are byte-identical to quattro, so merging v4-0-1 into quattro resolves without a conflict. Verified by mutation: with the pin removed, test/shell.d/dns-sudoers-test.sh fails at the poisoned-helper case; restored, all four of its cases pass. test/shell (189 files) and test/cli pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018DEMYa9UWtroz93DhMTtcV
* Pin PATH to trusted dirs when omarchy-dns holds root A dev link prepends a user-writable checkout bin/ to sudo's secure_path, so the passwordless `omarchy-dns Cloudflare` sudoers rule lets root resolve a bare helper (dirname, install, tee, nmcli, ...) out of that checkout — turning checkout-write access into arbitrary root execution. Pin PATH to trusted system directories once EUID is 0, leaving the unprivileged wrapper phase free to locate sudo/pkexec on the caller's PATH. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01YUWoHbBoKMjsjV6X3nu1H5 * Assert the trusted-PATH pin is gated on root, not merely present The EUID assertion matched `(( EUID == 0 ))` anywhere in the file, and require_root has carried that exact test since long before the pin existed. Deleting the pin left the assertion passing, so it stood for nothing: a run with the pin neutered reached the behavioural probe with both greps green. Anchor on the unindented guard and require the pin to be the line it opens, which no other construct in the script satisfies. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Co-Authored-By: Codex XHigh <[email protected]> * Skip the DNS trusted-PATH probe where user namespaces are unavailable `fail` ends the file, so a sandbox or hardened kernel that refuses unprivileged user namespaces did not just lose the probe — it took the two elevation assertions below it down as well, reporting a product defect where there was only a missing capability. The non-graphical suites are meant to run on any machine and treat a skip as a passing test, the way require_compositor and plugin-add-test.sh already do. Gate the probe on the namespace it needs and say so when it is absent; the static checks above and the elevation checks below run either way. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Co-Authored-By: Codex XHigh <[email protected]> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: David Heinemeier Hansson <[email protected]> Co-authored-by: Codex XHigh <[email protected]>
Harden omarchy-dns against PATH hijacking when it runs with root privileges.
Once the script has an effective UID of root, it now replaces PATH with trusted system directories before invoking helpers such as dirname, install, tee, rm, nmcli, systemctl, and awk.
Security issue
omarchy dev link adds the user-writable checkout’s
bin/directory to sudo’ssecure_path. This ensures privileged Omarchy commands resolve to development versions, but it also affects subprocesses launched by those commands.Omarchy permits wheel users to run the following commands without a password:
Although sudo executes the packaged
/usr/bin/omarchy-dns, the script previously inherited the dev-linked
secure_path. Its bare helper commands could therefore resolve from the user-writablecheckout.
An attacker able to write to the checkout could place a malicious executable such as install in its
bin/ directory and trigger a permitted DNS change. The helper would then execute as root without
requiring a password.
Fix
When
omarchy-dnsdetects that it is running as root, it sets:PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbinThe restriction is applied only after elevation. The unprivileged wrapper phase retains the caller’s
PATH so it can continue locating sudo or pkexec normally.
All helpers used by the privileged portion are system utilities, so it does not need access to the
dev checkout.
Tests
Added regression coverage which:
Validation performed: