How to fix: OS Command Injection
A form on this page was submitted with a shell metacharacter followed by a tagged arithmetic expression, and the response contained the CALCULATED result. This proves the input reaches a shell command and is executed, not treated as inert text.
Why it matters
OS command injection typically leads to full remote code execution on the server: an attacker who can inject shell commands can read and modify files, exfiltrate secrets and environment variables, pivot to internal systems, or take over the host entirely.
This is a confirmed, active finding: the scanner submitted a value designed to remain inert if only reflected as text, and observed the shell-computed result in the live response, meaning the input actually reached and was executed by a shell. The active-probing category that produced it is opt-in and off by default, since submitting real requests to a target is a materially different action than reading its responses.
How to fix it
- 1Never build a shell command string by concatenating or interpolating user input. Use an API that runs a program directly with an argument array (e.g. Node's `execFile`/`spawn`, Python's `subprocess.run([...])`) instead of a shell-invoking `exec`/`system` call.
- 2If a shell is unavoidable, use your language's shell-escaping/quoting primitive for every user-controlled argument, and validate the input against a strict allowlist first.
- 3Apply least-privilege to the process account running the application, so even a successful injection is limited in blast radius.
- 4Re-run this scan after the fix to confirm the expression is no longer evaluated.
Code examples
Run a program directly, never through a shell string
// Bad: user input concatenated into a shell command string
exec(`ping -c 1 ${host}`);
// Good: no shell involved, arguments passed directly to the program
execFile('ping', ['-c', '1', host]);References
Detected automatically by VulnRadar. The check id is os-command-injection, stable across every scan so you can filter or diff on it.
More active probing checks
Questions
- How severe is OS Command Injection?
- VulnRadar rates this critical severity in the active probing category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id os-command-injection, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does OS Command Injection map to?
- It maps to CWE-78. In the OWASP Top 10 it falls under A03:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.