Repository navigation
fix(factory-reset): forward gum theme vars as single-line assignments - #94
Closed
mark-groves wants to merge 2 commits into
Closed
mark-groves wants to merge 2 commits into
mark-groves wants to merge 2 commits into
Conversation
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]>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. Comment |
This was referenced Oct 27, 2026
This was referenced Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
omarchy-system-factory-resetrebuilt gum theme variables by scraping the text ofenv. GNUenvprints a value that contains a newline as extra lines, andgrep '^GUM_'keeps a line such asGUM_/pwn. GNUenvtreats the first argument without=as the program. After the sudo password, root can run./GUM_/pwnfrom 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-gumonly overwrites keys ingum_env.lua, so extraGUM_*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/sudoand/usr/bin/envare absolute paths.What changed
omarchy-system-factory-resetbuilds the forwarded list from environment records.GUM_CONFIRM_PROMPT_FOREGROUND=$'6\nGUM_/pwn'and checks that the packaged reset stays the program and thatGUM_/pwnnever reaches argv.Scope
bin/,install/,migrations/,shell/, anddefault/. No other script scrapesenvtext into argv.omarchy-update-pacman,omarchy-launch-docker-tui, andomarchy-lifecycle-dispatchalready pass caller values as oneNAME=valueword. A newline inLC_ALL,TERM, orHOMEleft the intended program in place. Measured with/usr/bin/envand/usr/bin/printf.Tradeoffs
The whole newline-bearing variable is dropped. Keeping the text before the newline would still forward a truncated color.
/usr/bin/env -0is the source because bash still exposes invalid names such asGUM_/pwntoenv.compgen -vwould 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
sudoreplaced by a logger.Before, the program was
GUM_/pwn. A separate GNUenvrun of those words exited 127 trying to executeGUM_/pwn.After, the program was the packaged reset, the command was
/usr/bin/env, andGUM_/pwnwas absent.bash test/shell.d/factory-reset-elevation-test.shfailed on the old script at "a newline in a gum value leaves the packaged reset as the elevated program", withGUM_/pwnin 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, andbash test/shell.d/pr-shape-check-test.shpassed.bash -npassed on both edited files.factory-reset-accessory-trust-test.shfails on the unchanged script too (ESP_MNT: unbound variable).Sibling probe, each value containing a newline and
/tmp/pwn./usr/bin/envstill ran/usr/bin/printf, which printed the intended program. Exit status 0 in each case.