Skip to content

Subprocess with Non-Absolute Paths

Description

The use of subprocess with non-absolute executable paths may lead to unexpected behavior, potentially allowing an attacker to execute arbitrary commands.

Examples

Insecure Code

python
subprocess.Popen('relative/path/to/executable', shell=False)

Secure Code

python
subprocess.Popen('/absolute/path/to/executable', shell=False)

Remediation

Use absolute paths for executables in subprocess calls.

Rule Details

FieldValue
IDCODE-0267
CategoryInjection
SeverityHIGH
CWECWE-78
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityEASY
Tagsinjection, path traversal
OWASPA03:2021-Injection