Skip to content

OS Command Execution with Partial Paths

Description

Avoid using process execution functions with non-absolute or partially constructed paths. This can lead to command injection vulnerabilities, allowing attackers to execute arbitrary system commands.

Examples

Insecure Code

python
os.system('ls ' + user_input)

Secure Code

python
os.system('/bin/ls')

Remediation

Use absolute paths or ensure that the input to the process execution functions is properly sanitized and validated.

Rule Details

FieldValue
IDCODE-0266
CategoryInjection
SeverityHIGH
CWECWE-78
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityEASY
Tagscommand injection, path traversal
OWASPA03:2021-Injection