Harden numeric parsing and command overrides - #276
Open
M0nd0R wants to merge 1 commit into
Open
Conversation
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.
Summary
strtoumax(..., base 0)consumption instead of accepting any digits/xmixturex,0x,08, and1xinstead of letting them silently parse as UID/GID 0 or a truncated value--clear the configured command path/args so the CLI override documented insetupArgv()actually winsSecurity impact
This hardens privilege-boundary parsing. Before the change, malformed numeric ID strings could pass
isANumber()and then be truncated bystrtoimax(..., base 0), so values such asxor0xbecame UID/GID 0. Also, a configexec_bin.pathcontinued to win even when the caller provided a replacement command after--, contrary to the override behavior described in the code.Verification
make -j2git diff --cached --check-u x:x -g x:xnow exits 255;0x10still runs as uid/gid 16;tests/command-override.cfg -- /bin/falseexits 1make testpassed through the new regression tests and then stopped at the existing pasta network test becausepastais not installed in this local environment