Skip to content

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.

3 participants