fix(security): validate untrusted values before git, fs and logs - #10
Merged
Merged
Conversation
Proven RCE: a .gitmodules branch value like --upload-pack=<cmd> is parsed by git as an option despite shell quoting (demonstrated with git 2.43, issue #9). Untrusted values are now validated with a warn + safe fallback contract: - sanitize_branch: .gitmodules branch read + submodule add -b - validate_module_path: pathspecs for git rm / submodule deinit - validate_dir_name: dir option clone/install targets - sanitize_url/sanitize_cmd: userinfo stripped from commit messages, error messages, traces and sidebar output Closes #9
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
Closes the four injection/leak vectors of issue #9 with a warn + safe fallback contract (no hard throw): invalid values are logged at WARN and replaced by the safe default, nothing breaks, the degraded state is visible.
Type of change
Related issue
Fixes #9
How was this tested?
make test-cipasses (206/206, +7 security tests)make test-asyncpasses (16/16)The injection was proven before the fix (documented in #9): a
.gitmodulesbranch = --upload-pack=/tmp/pwned.shpassed throughgit pull origin '<branch>' --ff-onlyexecuted the script despite shell quoting (git 2.43). After the fix, the hostile value is refused at the read point, warns, and falls back to default branch resolution.sanitize_branch.gitmodulesbranch read (update pull flow),git submodule add -bvalidate_module_paths:remove_modulepathspecs (coversremove+gc)validate_dir_namediroption, dict + positional formssanitize_url/sanitize_cmdChecklist
type(scope): subject)g:plugin_manager_*flag defaulting to off)v:version < 802untouched)