Skip to content

fix(factory-reset): forward gum theme vars as single-line assignments - #94

Closed
mark-groves wants to merge 2 commits into
quattrofrom
cursor/factory-reset-gum-argv-421a
Closed

mark-groves wants to merge 2 commits into
quattrofrom
cursor/factory-reset-gum-argv-421a

Conversation

@mark-groves

@mark-groves mark-groves commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Why

omarchy-system-factory-reset rebuilt gum theme variables by scraping the text of env. GNU env prints a value that contains a newline as extra lines, and grep '^GUM_' keeps a line such as GUM_/pwn. GNU env treats the first argument without = as the program. After the sudo password, root can run ./GUM_/pwn from the home directory instead of /usr/bin/omarchy-system-factory-reset. A user who can already write the session environment, for example ~/.config/uwsm/env.d/, can plant that value. omarchy-restart-gum only overwrites keys in gum_env.lua, so extra GUM_* keys survive a theme restart.

The elevation now reads NUL-delimited records from /usr/bin/env -0. It forwards a record only when the name matches ^GUM_[A-Za-z0-9_]+$, the value contains no newline, and the word contains =. /usr/bin/sudo and /usr/bin/env are absolute paths.

What changed

  • omarchy-system-factory-reset builds the forwarded list from environment records.
  • The elevation test plants GUM_CONFIRM_PROMPT_FOREGROUND=$'6\nGUM_/pwn' and checks that the packaged reset stays the program and that GUM_/pwn never reaches argv.

Scope

  • Covers factory-reset elevation only. The same class was hunted through bin/, install/, migrations/, shell/, and default/. No other script scrapes env text into argv.
  • omarchy-update-pacman, omarchy-launch-docker-tui, and omarchy-lifecycle-dispatch already pass caller values as one NAME=value word. A newline in LC_ALL, TERM, or HOME left the intended program in place. Measured with /usr/bin/env and /usr/bin/printf.
  • This was not exercised on a live Hyprland session.

Tradeoffs

The whole newline-bearing variable is dropped. Keeping the text before the newline would still forward a truncated color. /usr/bin/env -0 is the source because bash still exposes invalid names such as GUM_/pwn to env. compgen -v would not list those names.

Blast Radius

The change runs when an unprivileged user starts a factory reset from the Setup menu or a shell. Single-line gum colors are still forwarded. A value that contains a newline is omitted, so that one color falls back. The reset body is unchanged.

Verification

This was not exercised on a live Hyprland session. The same hostile value was passed to a copy of the real elevation, with sudo replaced by a logger.

Before, the program was GUM_/pwn. A separate GNU env run of those words exited 127 trying to execute GUM_/pwn.

After, the program was the packaged reset, the command was /usr/bin/env, and GUM_/pwn was absent.

Hostile value: GUM_CONFIRM_PROMPT_FOREGROUND=$'6\nGUM_/pwn'

=== before (env | grep) ===
word[0]=env
word[1]=GUM_CONFIRM_PROMPT_FOREGROUND=6
word[2]=GUM_/pwn
word[3]=GUM_INPUT_PROMPT=Reset\ this\ computer\?\ 
word[4]=GUM_EQUALS=a=b
word[5]=/tmp/tmp.GXgWfIVqAJ/packaged-reset
word[6]=argument\ with\ spaces
program=GUM_/pwn

=== after (NUL records) ===
word[0]=/usr/bin/env
word[1]=GUM_INPUT_PROMPT=Reset\ this\ computer\?\ 
word[2]=GUM_EQUALS=a=b
word[3]=/tmp/tmp.w61F5GlbgB/packaged-reset
word[4]=argument\ with\ spaces
program=/tmp/tmp.w61F5GlbgB/packaged-reset

bash test/shell.d/factory-reset-elevation-test.sh failed on the old script at "a newline in a gum value leaves the packaged reset as the elevated program", with GUM_/pwn in argv. It passed after the fix, including the existing argument and status cases.

I18N_STRUCTURAL=1 bash test/shell.d/i18n-test.sh, python3 scripts/i18n-sync.py extract-scan --check, and bash test/shell.d/pr-shape-check-test.sh passed. bash -n passed on both edited files. factory-reset-accessory-trust-test.sh fails on the unchanged script too (ESP_MNT: unbound variable).

Sibling probe, each value containing a newline and /tmp/pwn. /usr/bin/env still ran /usr/bin/printf, which printed the intended program. Exit status 0 in each case.

LC_ALL=$'C\n/tmp/pwn'          PROGRAM pacman
TERM=$'xterm\n/tmp/pwn'        PROGRAM lazydocker
HOME=$'/home/user\n/tmp/pwn'   PROGRAM entrypoint
LC_ALL=-i                      PROGRAM pacman

Before and after argv for a newline in a gum value

Open in Web Open in Cursor 

cursoragent and others added 2 commits October 25, 2026 01:21
The elevation test only used a single-line gum value, so a newline
could become its own argv word and replace the packaged reset.

Co-authored-by: Mark Groves <[email protected]>
Read NUL-delimited environment records and pass sudo only a GUM name
with a single-line value. A newline in a value became its own argv
word, and env ran that word as root.

Co-authored-by: Mark Groves <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants