Back to Overview
CRITICAL SEVERITYCWE-78OWASP A03:2021
Command Injection
OS Command Injection allows attackers to execute arbitrary operating system commands on the server. This occurs when applications pass unsafe user data to system shells, potentially leading to complete server compromise.
9.8
CVSS Score
30+
Payloads
RCE
Impact
Critical
Risk Level
Payload Database
Simple command injection payloads for initial testing
; ls -laSemicolon separator
| cat /etc/passwdPipe output
& whoamiBackground execution
`id`Backtick substitution
$(whoami)Command substitution
|| lsOR operator
&& idAND operator
; sleep 10Time-based detection
Vulnerable Code Example
Secure Code Example
Prevention Checklist
Avoid system commands when possible - use libraries
Validate and sanitize all user input
Use allowlists for acceptable characters
Escape shell metacharacters properly
Use parameterized commands (subprocess arrays)
Run applications with minimal privileges
Implement proper input length restrictions
Use containerization and sandboxing