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

Functions called with shell=1 should be flagged #157

Closed
ericwb opened this issue Apr 27, 2018 · 3 comments
Closed

Functions called with shell=1 should be flagged #157

ericwb opened this issue Apr 27, 2018 · 3 comments

Comments

@ericwb
Copy link
Member

ericwb commented Apr 27, 2018

The injection_shell plugins that look for shell=True (both in subprocess functions,
and in other functions) look for either the bool True or the string "True".
They might be able to detect more cases, like shell=1.

In the example below, the first two cases are flagged as HIGH, and the second
two are flagged as LOW. The case where shell=1 is not caught:

import subprocess

command = 'pwd'
subprocess.call(command, shell=True)
subprocess.call(command, shell='True')
subprocess.call(command, shell=1)
subprocess.call(command, shell=False)

If "shell" is set to anything other than a falsey constant, it
can be flagged. It may be possible to use bandit.core.constants.FALSE_VALUES,
without the string 'False'.

I think this is the real bug behind https://bugs.launchpad.net/bandit/+bug/1505389

@ehooo ehooo mentioned this issue May 8, 2018
@ehooo
Copy link
Contributor

ehooo commented May 9, 2018

@ericwb what do you think about the pull request?

ericwb pushed a commit that referenced this issue Jun 14, 2018
ericwb pushed a commit that referenced this issue Jun 14, 2018
- More example for shell kwarg
- Related with #157
@ehooo
Copy link
Contributor

ehooo commented Jun 14, 2018

I think this could be closed @ericwb unless you have some objection about the test case.

@ericwb
Copy link
Member Author

ericwb commented Jun 14, 2018

Fixed with PR #298

@ericwb ericwb closed this as completed Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants