Web SecurityCriticalShell injectionCommand Injection
OS Command Injection
User input reaches a system shell, letting an attacker run OS commands on the host.
Overview
When applications build shell command strings with untrusted input, shell metacharacters (; | && $() ` ) inject additional commands that the OS executes with the app’s privileges.
How it works
When applications build shell command strings with untrusted input, shell metacharacters (; | && $() ` ) inject additional commands that the OS executes with the app’s privileges.
Example
Impact
Arbitrary command execution, file access, credential theft, and full host takeover.
Detection
Inject time-delay and OAST command payloads (sleep, nslookup to a collaborator) and confirm via latency or callback.
Prevention
- Avoid the shell - use argument arrays / exec APIs without a shell.
- Never interpolate input into command strings.
- Allowlist and strictly validate any values passed to system calls.
- Run with minimal OS privileges.