-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Labels
Azure CLI TeamThe command of the issue is owned by Azure CLI teamThe command of the issue is owned by Azure CLI teamOKR CandidateThis label is used to track how many GitHub issues we have resolved for OKR purpose.This label is used to track how many GitHub issues we have resolved for OKR purpose.common issuefeature-request
Milestone
Description
Python possesses many mechanisms to invoke an external executable.
However, doing so may present a security issue if appropriate care is not taken to sanitize any user provided or variable input.
Consequences
-
If you use shell=True, your code is extremely likely to be vulnerable
-
Even if your code is not vulnerable, the next person who maintains can easily introduce a vulnerability.
-
Shell injections are arbitrary code execution - a competent attacker will use these to compromise the rest of your system.
How to Avoid
- Stop using the following commands that may cause shell injection according to Bandit rule B605
- os.system
- os.popen
- os.popen2
- os.popen3
- os.popen4
- popen2.popen2
- popen2.popen3
- popen2.popen4
- popen2.Popen3
- popen2.Popen4
- commands.getoutput
- commands.getstatusoutput
- Use subprocess securely
def ping(myserver):
args = ['ping', '-c', '1', myserver]
return subprocess.check_output(args, shell=False)
jiasli, Himan10 and AllyW
Metadata
Metadata
Assignees
Labels
Azure CLI TeamThe command of the issue is owned by Azure CLI teamThe command of the issue is owned by Azure CLI teamOKR CandidateThis label is used to track how many GitHub issues we have resolved for OKR purpose.This label is used to track how many GitHub issues we have resolved for OKR purpose.common issuefeature-request