Skip to content
ShankarStack
CriticalCommand Injection

OS Command Injection

Untrusted input is incorporated into an operating-system command, allowing the input to alter what the server executes.

Command injection occurs when an application builds a shell command from user input, so the input can change the command's structure.

Root cause

User data is passed to a shell rather than to a program as a discrete, escaped argument.

Impact

Potentially severe server-side impact, since the injected command runs with the application's privileges.

Detection methodology

Review code paths that invoke the shell or external binaries with user-influenced arguments; verify safe invocation APIs are used.

Remediation

Avoid the shell entirely — call binaries with argument arrays via safe APIs, validate against strict allow-lists, and run with least privilege.

Secure coding guidance

Never pass user input to a shell. Use parameterised process-execution APIs that separate the program from its arguments.