Command coming from incoming request このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、
お気軽にご連絡ください 。
このルールを試す ID: python-django/subprocess-from-request
Language: Python
Severity: Error
Category: Security
CWE : 20
Description Execute a process using unsanitized and unvalidated user-inputs. The user data should be sanitized and validated before being used to launch a new process.
Learn More Non-Compliant Code Examples import subprocess
def execute_command ( request ):
cmd = request . GET . get ( "cmd" )
print ( "foobar" )
subprocess . run ( cmd )
subprocess . call ( cmd )
subprocess . capture_output ( cmd )
subprocess . call ([ "bash" , cmd ])
bli = subprocess . run ( cmd )
bla = subprocess . call ( cmd )
ble = subprocess . capture_output ( cmd )
blo = subprocess . call ([ "bash" , cmd ])
blip = subprocess . call ( "bash {0} " . format ( cmd ))
blop = subprocess . call ( "bash " + cmd )
Compliant Code Examples import subprocess
def execute_command ( request ):
cmd = request . GET . get ( "cmd" )
print ( "foobar" )
subprocess . run ( shlex . escape ( cmd ))
Seamless integrations. Try Datadog Code Analysis