Repository navigation
Take privileged usernames from id -un, not USER - #8534
marty-schneider wants to merge 12 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Hardens privileged commands by deriving usernames from the effective UID rather than the mutable $USER environment variable.
Changes:
- Secures passwordless sudo identity and validates usernames.
- Updates Docker, fingerprint, Tailscale, and ydotool account handling.
- Adds regression coverage for privileged identity usage.
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 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
bin/omarchy-sudo-passwordless |
Secures sudoers subject selection. |
bin/omarchy-sudo-docker |
Changes Docker group lookup identity. |
bin/omarchy-setup-security-sudoless-docker |
Secures Docker group addition. |
bin/omarchy-remove-security-sudoless-docker |
Secures Docker group removal. |
bin/omarchy-setup-security-fingerprint |
Secures fingerprint enrollment identity. |
bin/omarchy-install-service-tailscale |
Secures Tailscale operator selection. |
bin/omarchy-dev-install-ydoo |
Secures input-group membership changes. |
test/shell.d/privileged-user-identity-test.sh |
Adds identity-source regression checks. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The remaining usermod call sites still interpolated $USER. Derive the account from the euid so a spoofed environment cannot add nobody (or anyone else) to input/nordvpn.
quattro rewrote omarchy-sudo-passwordless to resolve the account from id -u through getent and validate the name before it reaches sudoers, which is what this branch set out to do there. Take quattro's copy and drop the test's assertions about the old shape; the other call sites this branch fixes are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both stubs printed the group list whatever id was asked, so once the commands took the account from id -un they got "wheel input docker" as a username and the two tests failed. The stubs now name the account for -un, and USER is set to a different name, so the tests fail if either command goes back to trusting the environment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed and tested on a disposable Omarchy VM. The fix works. I pushed two commits to this branch, and it now waits on a second review before it goes to the maintainer. Reproduced. I stubbed Pushed to your branch:
Tests. I ran the full shell suite and Second opinion. None. Codex Medium answered a ping, but the day's review budget was used up before it could review this PR. Nobody but me has checked it, so it is not marked verified or ready. It waits on that review, and nothing is needed from you. |
|
Rechecked on current One regression to fix before merging: id -nG "$(id -un)" 2>/dev/null | grep -qw docker && exit 1The same goes for The grep in Patch on top of 4bdb44adiff --git a/bin/omarchy-dev-install-ydoo b/bin/omarchy-dev-install-ydoo
--- a/bin/omarchy-dev-install-ydoo
+++ b/bin/omarchy-dev-install-ydoo
@@ -13,7 +13,7 @@ if ! getent group input >/dev/null; then
fi
user=$(id -un)
-if ! id -nG | tr ' ' '\n' | grep -x input >/dev/null; then
+if ! id -nG "$user" | tr ' ' '\n' | grep -x input >/dev/null; then
echo "Adding $user to the input group. You may need to log out and back in before this applies."
pkexec usermod -aG input "$user"
fi
diff --git a/bin/omarchy-sudo-docker b/bin/omarchy-sudo-docker
--- a/bin/omarchy-sudo-docker
+++ b/bin/omarchy-sudo-docker
@@ -28,7 +28,7 @@ DOCKER_SOCKET="${OMARCHY_DOCKER_SOCKET:-/var/run/docker.sock}"
case "${1:-}" in
--configured)
# An account in the docker group will not need sudo after the next login.
- id -nG 2>/dev/null | grep -qw docker && exit 1
+ id -nG "$(id -un)" 2>/dev/null | grep -qw docker && exit 1
exit 0
;;
"")
diff --git a/test/shell.d/privileged-user-identity-test.sh b/test/shell.d/privileged-user-identity-test.sh
--- a/test/shell.d/privileged-user-identity-test.sh
+++ b/test/shell.d/privileged-user-identity-test.sh
@@ -7,8 +7,23 @@ source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
! grep -Fq '${USER}' "$ROOT/bin/omarchy-sudo-passwordless" ||
fail "passwordless sudo does not interpolate USER into sudoers"
-grep -Fq 'id -nG 2>/dev/null' "$ROOT/bin/omarchy-sudo-docker" ||
- fail "sudoless Docker --configured reads groups of the current euid"
+# --configured answers from the account's configured groups (not the session's,
+# which are fixed at login) and for the euid's account, whatever USER says.
+stub_dir=$(mktemp -d)
+trap 'rm -rf "$stub_dir"' EXIT
+cat >"$stub_dir/id" <<'STUB'
+#!/bin/bash
+case "$*" in
+ -un) echo alice ;;
+ "-nG alice") echo "alice wheel docker" ;;
+ -nG) echo "alice wheel" ;;
+ *) echo "nobody" ;;
+esac
+STUB
+chmod +x "$stub_dir/id"
+if USER=nobody PATH="$stub_dir:$PATH" "$ROOT/bin/omarchy-sudo-docker" --configured; then
+ fail "sudoless Docker --configured reads the euid account's configured groups"
+fi
for cmd in \
"$ROOT/bin/omarchy-setup-security-sudoless-docker" \ |
A bare id -nG reports the running process's groups, which are fixed at login, not the account's entry in /etc/group. omarchy-sudo-docker --configured exists to answer about the account in the window between toggling sudoless Docker and the reboot, so it must name the euid's account; and omarchy-dev-install-ydoo would otherwise ask pkexec again on every run until the next login. The test now runs --configured against a stub id whose bare and named answers differ, with USER set to someone else, so it fails if either regression comes back. Co-Authored-By: Alexander Holbreich <16252784+aholbreich@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Any non-zero status satisfied the check, so a syntax error or a missing command in omarchy-sudo-docker would have passed it without proving the account's configured groups were read. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The branch was 239 commits behind quattro, and three tests it carries (kernel-headers-migration, network-captive-portal and the vscode theme check in test/cli) had since been fixed there, so the branch alone failed them. Merging brings the tested tree and the head into line; it merged without conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@aholbreich is right about Pushed to your branch:
Reproduced on the VM. I stubbed Tests. Second opinion. Codex Medium reviewed it in three rounds. It flagged the exit-status check fixed above and found nothing else in the diff. It also named places outside this PR that still trust
This is now marked verified. It waits on the maintainer, and nothing is needed from you. |
[Medium impact] The PR appears safe to merge. SummaryPrivileged account changes now use
Reviews (4) · Last reviewed commit: "Test the account lookup in sudo-docker-t..." · Reviewed by Greptile |
Enrollment now names the euid's account, but omarchy-apply-lock still fell back to USER when deciding whether a print is enrolled. With USER naming another account, setup enrolled the real one, then apply-lock found no prints for the other, removed /etc/pam.d/omarchy-lock-fingerprint and the command failed. Pass the enrolled name through OMARCHY_INSTALL_USER, which apply-lock reads first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This branch stopped merging cleanly into quattro, so I merged quattro in, and fixed the fingerprint problem Greptile raised above. Pushed to your branch:
Reproduced on a disposable Omarchy VM, with the fingerprint tools stubbed and Tests. Second opinion. Codex Medium reviewed the merge and the fingerprint fix and found no defects, including when setup runs under sudo or from a root shell. It agreed with my reading rather than adding a finding of its own, and its independence is not guaranteed. The places outside this PR that still trust This is verified again at this head and waits on the maintainer. Nothing is needed from you. |
quattro rewrote fingerprint enrollment to pipe fprintd-enroll through a progress filter. Keep that, and keep enrolling and configuring the lock screen for id -un's account rather than USER's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This branch stopped merging cleanly into quattro again, so I merged quattro in once more. Pushed to your branch: Reproduced on a disposable Omarchy VM, with the fingerprint tools stubbed and Tests. Second opinion. Codex Medium reviewed the merge and found no defects. It checked that nothing from quattro or this branch was lost, that This is verified at this head. It waits on CI for the new commit, and then on the maintainer. Nothing is needed from you. |
quattro removed the migration tests (omacom#16302), so the docker group migration test this branch had adapted to id -un goes with them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sites privileged-user-identity-test.sh grepped the scripts for the lines this branch adds and for a passwordless sudo change quattro already carries, which AGENTS.md rules out. sudo-docker-test.sh now runs --configured with USER naming another account, so its existing assertions fail when the groups are read for USER; setup and remove are already covered the same way by sudoless-docker-toggle-test.sh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This branch stopped merging cleanly into quattro again, so I merged quattro in once more and replaced the identity test with one that runs the command. Pushed to your branch:
Reproduced on a disposable Omarchy VM. I added the account to Second opinion. Codex Medium and muse-wonder (pi, thinking high) reviewed both commits and found no defects. They checked that the merge lost nothing, that no privileged call in the touched files still takes Waiting on you: the PR description no longer matches the diff. It describes an |
What was wrong
Several privileged commands interpolate
$USERinto sudoers,usermod,gpasswd,fprintd-enroll, andtailscale set --operator.$USERis the environment, not the euid. Anything in the session can export it.The one that writes policy is
omarchy-sudo-passwordless:USER=ALLproduces a valid drop-in named99-omarchy-nopasswd-ALLwhose body isALL ALL=(ALL) NOPASSWD: ALL. After the gum confirm and one sudo prompt (or a cached timestamp), every local account is passwordless root for the grant window.The same environment is inherited by Setup > Security > Passwordless Sudo from the session. A plugin, hook, or
exportin~/.bashrcis enough; the user sees the usual warning and thinks they are granting only themselves.Sibling commands have a smaller version of the same bug:
usermod -aG docker "$USER"withUSER=nobodyaddsnobodyto the docker group (root-equivalent) instead of the person who typed the password.Does not overlap #7990, which clears the grant at boot. This change is who the grant names.
The change
omarchy-sudo-passwordlesstakesid -un, refuses anything outside first-boot's username pattern and the sudoers aliasALL, then writes that subject.omarchy-sudo-docker --configuredusesid -nGwith no name, so it answers about this euid.usermod, fingerprint enroll, and Tailscale--operatortakeid -un.test/shell.d/privileged-user-identity-test.shgreps those call sites.test/shell.d/sudo-docker-test.shstill passes (itsidstub ignores arguments).