Skip to content

Subprocess call with untrusted argument

Description

The subprocess call includes dynamic or potentially untrusted argument values, which can lead to command injection attacks.

Examples

Insecure Code

python
subprocess.run(['ls', user_input])

Secure Code

python
subprocess.run(['ls', '--', user_input])

Remediation

Validate and sanitize all user-influenced input before passing it to subprocess calls.

Rule Details

FieldValue
IDCODE-0268
CategoryInjection
SeverityHIGH
CWECWE-78
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityEASY
Tagscommand injection, user input validation
OWASPA03:2021-Injection