Skip to content

Pin the update logger shell - #14601

Open
wickthumb wants to merge 1 commit into
omacom:quattrofrom
wickthumb:fix/pin-update-script-shell
Open

wickthumb wants to merge 1 commit into
omacom:quattrofrom
wickthumb:fix/pin-update-script-shell

Conversation

@wickthumb

@wickthumb wickthumb commented Oct 8, 2026 •

Copy link
Copy Markdown

omarchy-update passes a Bash-escaped command to script(1), but script selects its command interpreter from the inherited SHELL. An uncommon shell or wrapper can therefore intercept or misinterpret the logging re-exec.

Pin the logging boundary to /usr/bin/script and /usr/bin/bash, then restore the caller's exported SHELL only inside the trusted Bash command. The update keeps the caller's existing PATH through the logging and lock re-execs, and preserves an unset SHELL as unset.

The Omarchy security team classified the original report as same-user hardening and invited a regular pull request.

Validation

  • bash test/shell.d/update-user-path-test.sh
  • bash test/shell.d/update-hook-security-test.sh
  • bash test/shell.d/update-sequence-test.sh
  • bash test/shell.d/security-entrypoint-symlink-test.sh
  • bash -n on the changed shell files
  • git diff --check

The regression covers exported and unset SHELL, the logging and lock re-execs, caller-installed tools on PATH, and a checkout path containing =. It fails on unpatched quattro and passes with this change.

./test/all exercised all 322 shell-test files. The changed-path tests passed; 19 unrelated environment or companion-checkout failures remained. Both updater-area failures reproduce unchanged on current quattro.

Related: #11630 reports a silent exit at the same script -qefc boundary. Its environment does not identify the inherited shell, so this change does not claim to close it.

🤖 Generated by Codex (GPT-6) on behalf of Steven Brown (@wickthumb).

@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High risk] Changes how the update script invokes its logging shell.

The PR appears safe to merge, with the previous test issue fixed and no new actionable findings.

What we checked:

  • Caller shell changes the logger: The updater gives /usr/bin/script a fixed SHELL=/usr/bin/bash. It restores the caller’s value only inside the quoted command.
  • Hooks lose user tools: Both restarts carry OMARCHY_UPDATE_USER_PATH. The updater restores that path when it runs hooks and mise.

Summary

The PR pins the update logger to /usr/bin/script and /usr/bin/bash. It restores the caller’s exported SHELL inside the quoted command and preserves the caller’s PATH for hooks and mise.

  • The regression checks exported and unset SHELL, logging and locking, and checkout paths containing =.
  • The earlier login-shell-dependent assertion is fixed.
  • No new actionable issues were found. Review checks were read-only; tests were not run.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Caller starts updater] --> B[Save caller PATH and SHELL export state]
  B --> C[Run /usr/bin/script with SHELL=/usr/bin/bash]
  C --> D[Bash reads quoted command]
  D --> E[Restore exported SHELL or remove it]
  E --> F[Run /usr/bin/bash -p with updater and arguments]
  F --> G[Acquire update lock]
  G --> H[Run update phases]
  H --> I[Run hooks and mise with caller PATH]
Loading

Reviews (3) · Last reviewed commit: "Pin the update logger shell" · Reviewed by Greptile

Comment thread bin/omarchy-update Resolved
@wickthumb
wickthumb force-pushed the fix/pin-update-script-shell branch from 71c33e7 to 97c43c2 Compare October 8, 2026 16:10
Comment thread test/shell.d/update-user-path-test.sh Resolved
@wickthumb
wickthumb force-pushed the fix/pin-update-script-shell branch from 97c43c2 to ad2530b Compare October 8, 2026 16:25
@jandrusk

Copy link
Copy Markdown

Pinning the logger to /usr/bin/bash -p (and unsetting/re-exporting SHELL appropriately) is the right fix — script(1) picking $SHELL was a real footgun for uncommon wrappers. Tests for inherited wrapper SHELL and unset SHELL look good.

NIT only: the log path is still /tmp/omarchy-update.log (related claim work in #13937); out of scope here given the standing call on that class.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 16, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at ad2530b, and nothing needs changing.

I reproduced the bug on a worker built from the Omarchy ISO, with the real bin/omarchy-update and the real util-linux script 2.42.4, no mocks: with SHELL pointing at a wrapper that fails, quattro hands the logging re-exec to that wrapper and the update exits with the wrapper's status before doing anything. With this branch the wrapper is never used as the logger's interpreter and the update carries on to its confirmation prompt. Your regression in update-user-path-test.sh fails when bin/omarchy-update is put back to quattro's and passes on this head.

The re-exec still passes omarchy_security_require_privileged_bash_startup (argv is /usr/bin/bash -p -- ...), and the -- keeps a checkout path starting with - or containing = from being read as an option or an assignment.

On the worker, ./test/cli passed, and the updater, lock, hook, sequence, entrypoint and channel-boundary tests all passed. The full shell suite had 9 failing files, none in the updater, and all 9 fail the same way on quattro. quattro has moved since this branch was cut and changed both bin/omarchy-update and the boundary fixture; the branch merges cleanly with it, and the updater tests and the reproduction pass on the merged tree too.

Codex at medium effort reviewed the diff as a second opinion, with the same questions: proportionality, the security startup checks, the quoting, and whether the test could pass vacuously. It found no defects. It agreed with my review, and its independence is not guaranteed.

This doesn't close #11630. That report has the update exit 0 without creating a log. Here the update exits with the shell's status, and the log is created.

This is now waiting on a maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 31, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This branch no longer merges into quattro, and the conflict isn't one I can resolve mechanically, so I haven't pushed anything.

#17000, merged on 31 October, turned bin/omarchy-update back into a plain Bash script. It dropped the #!/bin/bash -p startup check, the environment scrubbing and the saved OMARCHY_UPDATE_USER_PATH. Its commit says those protections only guarded against code already running as the user. This PR builds on that machinery. It re-enters through /usr/bin/bash -p to satisfy a startup check that no longer exists, and it passes OMARCHY_UPDATE_USER_PATH="$user_path", a variable quattro no longer defines or reads. Both conflicts, in bin/omarchy-update and test/shell.d/update-user-path-test.sh, are in exactly those lines. Porting it would mean deciding again which parts of the hardening to keep, and #17000 has just settled that direction the other way.

quattro does still run the logger through the caller's $SHELL (bin/omarchy-update:56-59). I checked whether that breaks a normal update on its own, apart from the hardening. For an ordinary install path and -y, printf %q produces no quoting, so fish, zsh and nushell all run the command as written. It could only go wrong with unusual characters in a checkout path under a non-Bash shell. No open issue reports that.

The reproduction from 16 October still holds for this head against the quattro of that date. Nothing was run again today, because the head hasn't changed and the merged tree can't be built without that design decision.

Codex at medium effort and muse-wonder (via pi, high thinking) reviewed the conflict, #17000 and the shell question as second opinions. Both agreed that #17000 removed the protections this PR relies on, that ordinary updates from fish, zsh and nushell don't fail on quattro, and that resolving the conflict is a design decision rather than a port. Their independence is not guaranteed.

This is waiting on a maintainer to decide whether it is still wanted after #17000. If it is, the version that fits quattro is small: set SHELL=/usr/bin/bash for script only, with no -p, no /usr/bin/ absolute paths and no user-path plumbing, plus a regression for a non-Bash SHELL.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants