OS command injection

The admin-only bug that needed no admin

Rated in isolation, it needed an administrator. Chained with an authentication bypass, it needed nothing at all. Ivanti Connect Secure is a lesson in scoring what an attacker can actually reach.

On 10 January 2024 Ivanti disclosed two vulnerabilities in Connect Secure and Policy Secure, its VPN and network-access gateways. CVE-2023-46805 was an authentication bypass rated 8.2. CVE-2024-21887 was a command injection rated 9.1 — but its CVSS vector requires high privileges, because only an authenticated administrator should be able to reach the vulnerable function. On paper, one bug leaked access and the other needed an admin.

The same day, Volexity published its investigation. An attacker it tracks as UTA0178 had been chaining the two as zero-days to get unauthenticated remote code execution, with suspicious activity on its customer's gateway as early as 3 December 2023. The bypass delivered the request to the admin-only function; the injection ran the commands. Ivanti issued a temporary mitigation that day, CISA added both to its Known Exploited Vulnerabilities catalogue, and on 19 January CISA issued Emergency Directive 24-01. Its later supplemental direction noted that some actors had developed workarounds to earlier mitigations and detection methods.

CVE
CVE-2024-21887 (command injection), chained with CVE-2023-46805 (authentication bypass)
Product
Ivanti Connect Secure and Ivanti Policy Secure, 9.x and 22.x.
Class
Command injection (CWE-77); the bypass is improper authentication (CWE-287).
Severity
NVD CVSS 3.1: 9.1 (Critical) for the injection, with high privileges required; 8.2 (High) for the bypass. Together: unauthenticated remote code execution.
Timeline
Disclosed and added to CISA's KEV catalogue 10 January 2024, already exploited as zero-days. First patches 31 January and 1 February; replaced by updates on 8 February 2024.
Fix
Apply Ivanti's updates and follow its recovery guidance. Mitigation does not remove an existing compromise.

The root cause, in one sentence

Part of a request path was concatenated into a command string that the server ran through a shell, so shell syntax in the request became new commands.

Rapid7's analysis traced the injection to a Python REST service that started a Perl helper script by building one command string — with a value taken from the URL appended to the end — and executing it with the shell enabled. A shell treats separators, substitutions and redirections as instructions, so whatever followed in that value ran with the service's privileges. The authentication bypass was a separate path-handling flaw: an unauthenticated route prefix combined with traversal segments reached administrative API endpoints. Neither bug alone was unauthenticated code execution. Together they were.

We are not publishing an exploit request. Ivanti's advisory, Volexity's investigation and CISA's directives cover detection and recovery. This post is about the bug class and how to test for it safely.

The five shapes command injection takes

1. A command built as a string and handed to a shell

shell=True, os.system, PHP's exec and system, backticks, sh -c: whenever input is joined into a string that a shell parses, quoting becomes the only defence, and quoting is easy to get wrong. The fix is structural — call the program directly with an argument list so no shell ever sees the input.

2. Argument injection without a shell

An argument list stops shell syntax, not options. If a value starting with a hyphen is passed to tar, git, curl or a converter, the program may read it as a flag that writes files, fetches URLs or runs hooks. MITRE tracks this separately as CWE-88. Validate the value against what it should be, and end options explicitly with -- where the program supports it.

3. Administrative and diagnostic features

Ping and traceroute pages, licence checks, certificate generation, backups and log exports are where products most often call operating-system tools — and they sit behind an admin login, so they receive less scrutiny. CVE-2024-21887 lived in exactly this kind of function.

4. One language validates, another executes

Ivanti's path ran from a Python web service into a Perl script via a shell. Each hop is a chance for one layer to assume another did the checking. Second-order variants are similar: a hostname, filename or display name stored safely today is fed into a script or scheduled job tomorrow.

5. An authorisation boundary that path handling can walk around

The injection was only reachable without credentials because a router decided authentication on a URL prefix, before the path was fully normalised. Any admin-only command injection is exactly as exposed as the weakest route to it: an authentication bypass, a cross-site request from a logged-in admin, a stolen session or a server-side request forgery reaching an internal API.

"Admin only" is a precondition, not a mitigation. CVSS scores each vulnerability on its own. An attacker scores the chain. When a test finds a high-privilege injection, we look for the route that removes the privilege and rate the combination we can show.

How we test for it

  1. Inventory the features likely to call the operating system. Diagnostics, conversions, archive handling, imports, integrations, licensing and anything that mentions a hostname, file or path.
  2. Probe with harmless inputs. We use benign values that reveal whether shell or option syntax is interpreted rather than handled literally — and, where agreed, an out-of-band DNS canary to our own infrastructure. Never commands that change state, and never long delays on production.
  3. Test argument injection separately. A leading hyphen or an unexpected option is a different failure from shell metacharacters, and needs its own probe.
  4. Test the route, not only the function. For every privileged feature we check whether a lower-privileged or unauthenticated request can reach it: path normalisation, alternative prefixes, method changes and missing per-route checks.
  5. Score the chain. If a bypass and an injection combine, the report says so, rates the demonstrated combination and lists both fixes — closing either link breaks this chain, but both need fixing.
  6. Report the exact fix. The finding names the endpoint, parameter and called program, with evidence and a regression check.

A chained finding is only useful if developers can reproduce it. Our reporting approach shows how we make that possible without publishing dangerous material.

Six things to check in your application this week

  • Search the code for shell=True, os.system, exec, system, proc_open, backticks and Runtime.exec calls built from strings.
  • Replace string-built commands with argument lists, and end options with -- where the called program supports it.
  • Validate values passed to commands against a strict allowlist, such as a known node name or a numeric ID.
  • Enforce authentication and authorisation in each admin route, after path normalisation, rather than with prefix-based allowlists.
  • Run helper processes as a low-privileged account and alert on unexpected child processes from web services.
  • For appliances, apply vendor mitigations immediately, then patch; if exploitation is suspected, follow the vendor's rebuild guidance rather than relying on an integrity check alone.

Command injection is rarely hidden in the main workflow. We look in the administrative corners, then check who can really reach them.

Build your quote