Skip to content

Harden omarchy-refresh-limine's privileged read against a caller-controlled OMARCHY_PATH - #14073

Open
Josehbr wants to merge 4 commits into
omacom:quattrofrom
Josehbr:harden-refresh-limine
Open

Josehbr wants to merge 4 commits into
omacom:quattrofrom
Josehbr:harden-refresh-limine

Conversation

@Josehbr

@Josehbr Josehbr commented Oct 2, 2026 •

Copy link
Copy Markdown

What

Applies the privileged-startup validation chain already used by
omarchy-refresh-pacman (and omarchy-update, omarchy-channel-set,
omarchy-update-stay-awake) to omarchy-refresh-limine: -p startup check,
environment sanitization, OMARCHY_PATH source-root validation, and sudo
timestamp revocation on exit.

Why

omarchy-refresh-limine copies $OMARCHY_PATH/default/limine/limine.conf
into /boot as root and then rebuilds the bootloader. omarchy-refresh-pacman
performs the equivalent privileged copy out of the same tree and validates the
source root first; omarchy-refresh-limine is the one privileged refresh that
still trusts the caller's environment for that read.

Every current caller is interactive (omarchy-reinstall-configs, the menu),
so this is consistency and defense-in-depth rather than a fix to an
exploitable path.

Behavior notes

  • Adds set -e; the backup mv is now guarded by an existence check so the
    fresh-install path (no /boot/limine.conf yet) behaves as before.
  • After the entry revocation it authorizes once (/usr/bin/sudo /usr/bin/true)
    and runs the remaining steps behind the command-scoped sudo wrapper
    (omarchy_security_enable_no_update_sudo), like omarchy-update. sudo no
    longer resolves from the caller's PATH.
  • Cached sudo credentials are revoked on exit, matching the rest of the family.
  • omarchy-reinstall-configs therefore asks for the sudo password twice now:
    it runs omarchy-refresh-limine and then omarchy-refresh-plymouth, and
    omarchy-plymouth-set's sudo re-authenticates after limine's exit
    revocation. The family already re-authorizes between chained privileged
    steps (omarchy-channel-set runs omarchy-refresh-pacman,
    omarchy-update-pacman, and omarchy-update, each starting cold), and
    avoiding the second prompt would mean dropping one of the revocations. With
    the opt-in omarchy-sudo-passwordless mode active there is no prompt at all.

Test

Extends the protected-entrypoint loop in test/shell.d/security-source-root-test.sh
to cover omarchy-refresh-limine.
Adds a fixture-backed success-path test for existing and missing boot configs,
checking backup, copy, rebuild commands, and sudo timestamp cleanup.
The sudo boundary fixture now falls back to /tmp when the runner's TMPDIR
contains whitespace, since it splices fixture paths into script text.

Follow-up (not here)

Other privileged commands read $OMARCHY_PATH without the source-root check
(omarchy-apply-hardware, omarchy-apply-system, omarchy-reinstall-pkgs,
omarchy-voxtype-install, ...). Happy to migrate those in separate PRs if
this pattern is wanted there too.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Critical risk] Hardens a privileged bootloader configuration script against environment injection.

The PR appears safe to merge; no outstanding findings or new actionable failures were identified.

Summary

The PR adds privileged-startup and source-root validation to omarchy-refresh-limine, then performs its bootloader operations through a command-scoped sudo wrapper. It also adds success-path tests for existing and missing boot configurations and adjusts the shared fixture for whitespace in TMPDIR.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Start refresh-limine] --> B[Validate Bash startup and source root]
  B --> C[Revoke sudo timestamp]
  C --> D[Authorize once]
  D --> E[Enable no-update sudo wrapper]
  E --> F[Back up existing config if present]
  F --> G[Copy default config to boot]
  G --> H[Rebuild and sync Limine]
  H --> I[Revoke sudo timestamp on exit]
Loading

Reviews (3) · Last reviewed commit: "Run omarchy-refresh-limine's sudo steps ..."

Comment thread test/shell.d/refresh-limine-test.sh Resolved
@jandrusk

jandrusk commented Oct 6, 2026

Copy link
Copy Markdown

Thanks for this. Two notes:

  • omarchy-reinstall-configs calls omarchy-refresh-limine and then omarchy-refresh-plymouth. With sudo -k on entry and exit, the reset flow now asks for the password twice (once for limine, again for plymouth). That might be fine, but worth calling out or handling in the caller.
  • For context: Stop privileged copies from following a caller-controlled OMARCHY_PATH #9317 tried the same OMARCHY_PATH hardening for these refresh commands and was closed by its author. The reasoning was that the caller is the same wheel user who types the sudo password, and no NOPASSWD rule covers these commands, so no privilege boundary is crossed. Framing this as consistency with the omarchy-refresh-pacman family (as you did) is the right pitch. The maintainers will need to decide whether they want it.

Josehbr and others added 2 commits October 6, 2026 12:16
copy_boundary_file splices fixture paths into the copied script text, quoted
or not, so a runner TMPDIR with whitespace broke the sudo stand-in before any
assertion ran. Fall back to /tmp for the fixture root in that case.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…pper

The other privileged entrypoints authorize once and then run behind the
sudo-no-update wrapper with a fixed PATH. Do the same here so sudo does not
resolve from the caller's PATH and no step refreshes the cached credential.
The test now expects the single authorization followed by -N invocations.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Josehbr

Josehbr commented Oct 6, 2026

Copy link
Copy Markdown
Author

Thanks for taking the time to look at this, and for the #9317 context.

On the double prompt: you're right, and I've added it to the PR description. omarchy-refresh-limine revokes the sudo timestamp when it exits, so the first sudo in omarchy-plymouth-set asks again. I didn't change the caller. Reordering doesn't help because the revocation on entry resets things either way, and dropping one of the revocations would put limine out of step with the other privileged entrypoints. If the maintainers would rather batch the authorization in omarchy-reinstall-configs, I'm happy to rework it.

While going through this I also pushed two small commits. The first fixes the test fixture, which broke when the runner's TMPDIR contained a space (the second Greptile note). The second brings the limine script closer to the rest of the family: it authorizes once, then runs the remaining steps through the sudo-no-update wrapper with a fixed PATH, the same way omarchy-update does. It still costs a single prompt, and sudo no longer resolves from the caller's PATH.

On #9317: agreed. Someone who can poison OMARCHY_PATH as the user can run sudo cp directly, and with the default sudoers nothing is passwordless for these commands. The one exception is the opt-in omarchy-sudo-passwordless mode, which only strengthens the argument. That's why I framed this as consistency and defense in depth rather than a fix. Whether to adopt it is up to the maintainers.

@jandrusk

jandrusk commented Oct 7, 2026

Copy link
Copy Markdown

Thanks, re-checked: the double prompt is documented, the TMPDIR fixture is fixed, and the sudo steps now go through the fixed-PATH wrapper. Looks good to me. Whether to adopt it is up to the maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants