Command Substitution Execution Medium

Using '$(..)' captures and executes the output of a command. This can lead to unintended command execution or errors. To prevent this, remove the '$(..)' wrapper or use eval cautiously when intentionally executing dynamic commands.

Detector ID
shell/command-substitution-execution@v1.0
Category
Common Weakness Enumeration (CWE) external icon
-
Tags
-

Noncompliant example

1
2# Noncompliant: Attempts to execute the output of 'ls' instead of running 'ls'
3$(ls -l /tmp)

Compliant example

1
2# Compliant: Simply runs the 'ls' command without trying to execute its output
3ls -l /tmp