-
Notifications
You must be signed in to change notification settings - Fork 964
fix(#3577): remove shell=True and convert commands to argument lists to prevent command injection #3578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(#3577): remove shell=True and convert commands to argument lists to prevent command injection #3578
Conversation
shlokgilda
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
took a look at this - the fix is solid. nice catch on the shell=True issue.
couple notes from testing:
- git itself actually blocks the injection chars (backticks,
$(),;) in branch names - so the real attack surface was narrower than we initially thought. but|and&are still allowed, which could be exploited withshell=True, so this fix is still the right call. - please confirm the intent behind the switch from
git remote show origin | sedtogit symbolic-ref. - tiny nit:
cmd: listcould becmd: list[str]for better type hints
…lists to prevent command injection Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
…trict typing Replaces git symbolic-ref with git remote show origin parsed in Python to ensure accuracy while preventing command injection. Updates type hints. Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
b1913f4 to
3da58ce
Compare
shlokgilda
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good. Once you create the helper function, I think we are GTG
…code Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
1ca8aad to
a71e04f
Compare
shlokgilda
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
MoralCode
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall i like the move to the list-based args and not using shell=True. Theres a couple unrelated changes in here though
|
|
||
| getremotedefault = ( | ||
| f"git -C {absolute_path} remote show origin | sed -n '/HEAD branch/s/.*: //p'") | ||
| getremotedefault = ["git", "-C", absolute_path, "symbolic-ref", "refs/remotes/origin/HEAD"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to confirm that this is functionally the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
b14e877 to
bd88239
Compare
Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
bd88239 to
8d7d2a3
Compare
shlokgilda
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| return_code_remote, remotedefault = facade_helper.run_git_command( | ||
| return_code_remote, output = facade_helper.run_git_command( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels like we are maybe duplicating a lot of code here. Can we maybe refactor some of this git access type of stuff into shared functions?
Description
this PR fixes #3577 by removing
shell=Truefrom git command execution and converting all f-string commands to argument lists infacade worker.Signed commits