Platform

Platform overview How it works Authorization testing Evidence & reports Private scanning Integrations

Solutions

Security agencies Product teams Regulated industries Partner programme

Learn

Blog Knowledge hub Compare

Resources

Pricing Documentation Help centre FAQ Security & data What we haven’t proved

Company

About Contact Careers Sign in to the platform Start a $199 pilot →

Home / Knowledge hub / Command injection

Knowledge hub

Command injection

Input that ends up run as an operating system command on your server.

Illustration explaining Command injection

What it means

Command injection happens when your application passes user-controlled text to the operating system's shell and the shell treats part of it as a command. A feature meant to ping a host or convert a file ends up running whatever an outsider typed after it.

It is the same family as SQL injection, aimed at the server instead of the database. Characters such as semicolons, pipes and backticks let the attacker end the intended command and start another, with the same rights as your application.

Why it matters

The result is often remote code execution: reading files, stealing secrets from environment variables, installing software, moving to other systems and staying there quietly. A flaw in one small feature can become control of the whole server. A flaw in one small feature can become control of the server and everything it can reach.

For a business, that means customer data, cloud credentials and a long, expensive investigation. Because the command runs inside your own infrastructure, it also bypasses controls such as firewalls that watch only traffic coming in from outside. The first you hear of it may be a cloud provider's abuse notice.

How it shows up

It appears wherever code builds a command string: image and PDF conversion, network diagnostic tools, archive handling, backup scripts, calls to command-line utilities in the language's shell function. Filenames, URLs, form fields and even the text inside an uploaded file are the usual carriers, so the risky code is often far from the page that took the input.

The strongest fix is not to use the shell at all: call a library, or run the program with arguments passed as a list rather than joined into a string. If you must, accept only values from a strict allowlist. Blacklists of bad characters fail, because there are too many ways to write the same command.

Questions people ask

Command injection, answered

Is command injection the same as remote code execution?

It is one common way to get it. Remote code execution is the outcome: running the attacker's code on your server. Command injection is a flaw that can lead there.

Other flaws, such as unsafe deserialisation, lead to the same result.

How is it different from SQL injection?

The mechanism is similar, but the target differs. SQL injection changes a database query. Command injection changes a command run by the operating system.

The fix is similar in principle too: keep data and instructions apart.

Does input validation stop it?

It helps, if it is strict, but it should not be the only defence. Trying to block dangerous characters misses cases and breaks legitimate input.

Avoid calling a shell, and pass arguments safely, so input cannot become a command.

Can a WAF protect us?

A WAF may block obvious payloads, but encodings and variations get around many rules. Treat it as a speed bump, not the fix.

The flaw remains in your code until you correct it.

How do we test for it?

Look for features that run external programs, then send characters that end commands and observe the result, such as a delay or output from a harmless command.

Test with permission, in a non-production copy where possible.

Cyberlop mark

Where does input reach the shell?

We test inputs that reach server-side commands and report only what we exploited, with the request and the response that proved it. In white-box mode the finding names the file and line. Book a pilot on one app.

Or start with a $199 pilot on one application: thirty days, success criteria agreed before day one, credited against the annual if you convert.