Skip to content
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

Fix a possible shell command injection in the linux.service action #4675

Merged
merged 5 commits into from
May 14, 2019

Conversation

Kami
Copy link
Member

@Kami Kami commented May 13, 2019

This pull request fixes a possible shell command injection in linux.service action.

Background, Context

The code didn't escape service and action parameter passed to subprocess.Popen and used shell=True.

This pull request fixes the action to use shell=False and passes command to subprocess.Popen as a list of arguments instead of as a string (in this scenario, values are automatically escaped by subprocess.Popen).

This issue was reported to us by James Robinson (Netskope and Veracode).

@Kami Kami added this to the 3.0.1 milestone May 13, 2019
if len(sys.argv) < 3:
raise ValueError('Usage: service.py <action> <service>')

args = {'act': quote_unix(sys.argv[1]), 'service': quote_unix(sys.argv[2])}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now not strictly needed since subprocess.Popen already takes case of that when a list of args and shell=False is used.

@Kami Kami merged commit 070b23a into master May 14, 2019
@Kami Kami deleted the service_action_fix branch May 14, 2019 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants