
When using functions like subprocess.Popen etc to launch an external executable, the full path should be given. This prevents an attacker from manipulting the search path or placing a bogus executable that will be launched instead of the intended one. Change-Id: I4a11f988bc3e954331ab0f0902ea849c6ec31888
25 lines
642 B
Python
25 lines
642 B
Python
import subprocess
|
|
from subprocess import Popen as pop
|
|
|
|
|
|
def Popen(*args, **kwargs):
|
|
print('hi')
|
|
|
|
pop('/bin/gcc --version', shell=True)
|
|
Popen('/bin/gcc --version', shell=True)
|
|
|
|
subprocess.Popen('/bin/gcc --version', shell=True)
|
|
subprocess.Popen(['/bin/gcc', '--version'], shell=False)
|
|
subprocess.Popen(['/bin/gcc', '--version'])
|
|
|
|
subprocess.call(["/bin/ls",
|
|
"-l"
|
|
])
|
|
subprocess.call('/bin/ls -l', shell=True)
|
|
|
|
subprocess.check_call(['/bin/ls', '-l'], shell=False)
|
|
subprocess.check_call('/bin/ls -l', shell=True)
|
|
|
|
subprocess.check_output(['/bin/ls', '-l'])
|
|
subprocess.check_output('/bin/ls -l', shell=True)
|