Fix argv injection in _create_user and gpasswd loop#4473
Merged
svartkanin merged 2 commits intoarchlinux:masterfrom Apr 26, 2026
Merged
Fix argv injection in _create_user and gpasswd loop#4473svartkanin merged 2 commits intoarchlinux:masterfrom
svartkanin merged 2 commits intoarchlinux:masterfrom
Conversation
Use argv list with run() instead of f-string interpolation into SysCommand, add debug logging on failure.
svartkanin
reviewed
Apr 26, 2026
Address svartkanin's review on archlinux#4473: factor the ['arch-chroot', '-S', str(self.target), ...] boilerplate into a private Installer._chroot_argv() helper, and migrate the seven existing argv-form call sites to it (useradd, gpasswd, chpasswd, chsh, chown, snapper-create-config, grub-install). Two related hardening tweaks while in the area: - Raise gpasswd failure log from debug() to warn(). The group-add loop has no return-False feedback channel for the caller, so a silent debug() means a half-configured user looks like a successful install. - Add `--` end-of-options separator for useradd and chown so a username or path starting with `-` cannot smuggle flags. The TUI validates usernames, but parse_arguments() in models/users.py does not, so config.json is the residual hole; this closes it for these two sites at zero cost.
svartkanin
approved these changes
Apr 26, 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.
Same class of bug as #4443, two sibling call sites that were missed back then.
_create_userand thegpasswdloop interpolateuser.usernameandgroupinto f-strings that reachSysCommand(f'arch-chroot -S {target} {cmd}'), whereshlex.splitparses the payload as argv. Ausernamelike--uid 0or-G wheel,rootis accepted asuseradd/gpasswdflags and gives trivial escalation. Vector is the same as #4443: custominstall.py, plugins, tampered--configJSON.Changes
_create_usernow builds an argv list and callsrun(). Failures are logged viadebug(), and theSystemErrorre-raise is kept so guided install still aborts.The
gpasswdloop gets the same switch. Also wrapped it intry/exceptwithdebug()- previously a failinggpasswdwas silently ignored.