Repository navigation
[codex] OM-SEC-17: Allowlist update restart markers and commands - #9472
AFOliveira wants to merge 55 commits into
Conversation
|
2 Changes:
exec /usr/bin/sudo -N -- "$@" The -- makes subsequent arguments command arguments rather than sudo options. For example, omarchy-update-stay-awake calls sudo -v, which becomes: /usr/bin/sudo -N -- -v This attempts to execute a command named -v and aborts a normal terminal update under set -e. The wrapper needs to preserve supported sudo options, with regression coverage for sudo -v.
|
There was a problem hiding this comment.
🟡 Changes recommended
The sudo validation flow can break sleep inhibition, existing update tests bypass their stubs, and the claimed marker security regression test is absent.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Hardens update restart handling against attacker-controlled markers and reusable sudo authorization.
Changes:
- Allowlists restart markers and resolves fixed command paths.
- Adds non-reusable sudo and trusted-source boundaries.
- Reorders privileged and user-controlled update phases.
File summaries
| File | Description |
|---|---|
AGENTS.md |
Documents secure bash -p exceptions. |
bin/omarchy-update |
Adds trust validation, sudo isolation, and sequencing. |
bin/omarchy-update-restart |
Validates markers and separates restart phases. |
default/omarchy/sudo-no-update/sudo |
Wraps sudo with --no-update. |
test/shell.d/update-sequence-test.sh |
Extends update-order and boundary testing. |
Review details
- Files reviewed: 3/5 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…view-9469-20260906
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The refresh hook can precede later cache-populating sudo calls in omarchy-reinstall-pkgs, reopening the authorization-reuse window.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 26/37 changed files
- Comments generated: 1
- Review effort level: Balanced
| ├── post-update.d/ # During `omarchy update`, after system packages and migrations | ||
| ├── pre-refresh-pacman.d/ # Before `omarchy refresh pacman` re-syncs packages | ||
| ├── post-update.d/ # At the end of `omarchy update`, after privileged work | ||
| ├── pre-refresh-pacman.d/ # After `omarchy refresh pacman` finishes (legacy name) |
|
LGTM, pending hook doc fix. |
Upstream now runs every Omarchy-owned pacman transaction through the hidden omarchy-update-pacman helper so a mid-transaction systemd reexec cannot kill it. Keep the deferred pre-refresh-pacman hook and the command-scoped sudo wrapper, and call the helper from the refresh and channel commands; the wrapper still applies to the helper's own sudo. The sudo boundary fixture copies the helper into its root and runs a systemd-run stand-in that execs the wrapped pacman step in place. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The legacy command wrote the caller's unvalidated name into both the sudoers filename and the rule. Cleanup applied the current lower-case account pattern to that suffix, so an exact legacy grant for an account such as Alice was classified as administrator policy, left active, and the machine-wide migration marker was written anyway. Match a legacy grant by its exact filename and rule relationship instead of the account policy, and cover it in the lifecycle suite through both the unit cleanup and the real migration runner. The account pattern itself stays lower-case: sudoers reads an upper-case word such as ALICE as a User_Alias reference, and ALL as every user, so such names must never reach the generated rule. Pin that with a test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Matching a legacy grant by its filename and rule relationship is not a complete fingerprint: the legacy writer took the filename from $USER but produced the rule with echo, and under BASH_ENV with xpg_echo a name such as ali\0143e yields an alice rule in a mismatched file. Preserving that as administrator policy let the migration certify success with an unrestricted grant still live until the next boot. The prefix is reserved anyway: boot cleanup and the package hook remove everything under it. Move any file the classifier does not recognize into a fresh root-only directory under /var/lib/omarchy/sudoers-quarantine/ as `policy`, with the original name stored beside it, so nothing there stays live, the administrator keeps the content, and a legacy filename already close to NAME_MAX still fits. An untrusted quarantine directory keeps the migration pending. Cover the mismatched and maximum-length legacy files in the unit cleanup and through the real migration runner. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Bring in the legacy-grant classifier fix and the reserved-prefix quarantine from omacom#9457 so this branch no longer carries a stale copy of that command. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…rough user work Three review findings on the update-hook boundary: The pre-refresh-pacman hook had been moved after the refresh transaction and, during a channel switch, deferred to the very end. That defeated the hook's purpose: custom repositories and IgnorePkg entries were not in place when the downgrade-capable -Syyuu ran. Run the hook where it used to run, after the package config is re-synced and before the transaction, but cold: revoke the timestamp, run it behind the no-update wrapper with the caller's original PATH, and revoke again before continuing. Every later privileged command authenticates with --no-update, so a detached child left by the hook has no reusable timestamp to wait for. Channel switching hands the caller's PATH to the refresh the same way the updater receives it, and no longer defers or re-runs the hook. Stay Awake was released before AUR builds, hooks and mise, so the machine could sleep during the longest part of an update. Releasing the inhibitor needs no privilege because the held command already dropped to the user, so stop it after mise and before the reboot prompt, as before. A packaged channel destination cannot be inspected before its package is installed, and a transaction can replace the running tree with a release that predates the command-scoped wrapper; from then on a bare sudo would resolve to /usr/bin/sudo and publish a timestamp, and the destination's own updater authenticates the same way. The switch used to abort only after the packages had changed, with generic rerun advice. Now it checks for the wrapper after each transaction before any further privileged step, completes what it safely can, and stops cold with instructions to run that release's update from a fresh session instead of launching it. Boundary tests pin the hook between the config copies and the transaction with a cold timestamp on both sides, the older-destination stop with its guidance and no launched updater, the new inhibitor position, and the post-update hook staying unreached on failures and signals. Docs, the manual and the sample hook describe the restored timing. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Restarting the shell waited for the notification bus name to reappear before it would re-acquire a lock whose client had died. A slow or failed notification plugin then left the user stranded behind Hyprland's failsafe even though the lock service worked. Wait for the shell's core IPC, re-secure the lock immediately, and only then wait for a previously running notification service, reporting it separately if it never returns. Cover the never-returning case: the lock comes back and the restart still reports the missing service. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…robe The protected entrypoints revoked the sudo timestamp before installing their cleanup traps, so a signal or failure during that first sudo -k exited without the cleanup path. Install the traps first. The shell restart probed the notification bus name with busctl's default 25 second timeout, so an unresponsive user bus could stall the restart by that much per probe. Bound each probe to one second. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
pacman continues a transaction after a failed scriptlet. Model that in the shared package-scriptlet contract: a failed pre_upgrade followed by post_upgrade must keep the removal blocker while a rule remains, a clean retry recovers, a stranded blocker with a live rule is cleaned by the next completed installation, a fresh install that cannot remove a leftover rule leaves publication refused, and the sweep does not depend on inherited glob state. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The settings package's pre-transaction hook runs this command under pacman's transaction. Its lock wait was unbounded, so a stalled grant operation could hang pacman indefinitely before AbortOnFail ever saw a result. Grant operations are short; wait at most 60 seconds. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Keep inhibitor state in validated private directories and verify the recorded owner, PID, start time and launch token before signaling. Authenticate the held command before detaching and drop it back to the invoking user. Serialize launch and cancellation, identify the child before publishing its state, and preserve caller-owned idle choices. Cover cross-account fallback state, process identity, cancellation, retry, and update-lock handling with isolated regressions.
|
Reviewed at What changed underneath it. After this branched, #13323 ( What was run, on a disposable Omarchy worker, against a local merge of
Whether the restriction is still worth its size on Second opinion: none. Nothing was pushed to the branch. This waits on the maintainer to decide whether the pull request is still wanted after #13323. If it is, the author needs to merge |
Writable restart markers select only supported, zero-argument component commands through an explicit allowlist. Commands resolve inside the validated source tree, including matching packaged links to
/usr/bin. Unsupported names, generic dispatchers and non-regular markers cannot select a command. Failed restarts keep their marker for retry; a shell marker causes only the single normal shell refresh.Finding: OM-SEC-17, reported and remediated by Afonso Oliveira. The #9469 prerequisite retains Roger Piñol's and Sean Huber's credits for their update/Pacman and Stay Awake reports.
Order: #9457 → #9469 → #9467 → this PR. The integration includes the actual #9467
6af052fccommit through an ordinary merge, including first-upgrade compatibility and the isolated idle-toggle fixture. Shared authorization code, the updater, inhibitor and their tests are byte-identical to that prerequisite. Erik's hook-documentation feedback is addressed by the current foundation's manual, reference and sample hook timing. #9474 remains a separate downstream migration change; #9473 is closed.At
b9336ce8, this PR's own delta over #9467 is four files: the restart dispatcher, its documentation and two restart test files. Seven focused suites pass both locally and in a fresh vanilla Arch VM: 111 groups, plus 112 CLI checks, with no skipped cross-account coverage. The VM had no installed Omarchy commands when the suites ran.Native tests on the same VM exercised the actual restart dispatcher and tmux in both checkout and packaged symlink layouts. Supported markers reload the real tmux configuration; malicious PATH commands and unsupported markers are not dispatched; failed reloads retain their marker and succeed on retry; non-regular markers are refused; cached sudo authorization is revoked. This headless guest also exercises the non-blocking missing-desktop path; it does not establish graphical shell or every hardware component restart.
Daybreak's final scoped review of exact
b9336ce8found no blocker; inherited SSH/AUR changes were excluded. Full historical update/migration prompt counts and the coordinated runtime/settings release remain separate validation work; earlier excessive prompt counts are not release-readiness evidence.