-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve exploit/linux/misc/cisco_ios_xe_rce (CVE-2023-20198 + CVE-2023-20273) #19934
Open
sfewer-r7
wants to merge
10
commits into
rapid7:master
Choose a base branch
from
sfewer-r7:bugfix-cisco-iosxe-rce
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… appliences (C8000v) need the _http portion of this URI path to be cchanges from all lowercase for CVE-2023-20198 to work as expected.
…to not be vulnerable to CVE-2023-20273. Inspecting the Lua code shows this appliance has additional command injection filtering in place (see pexec_setsid in /usr/binos/openresty/nginx/conf/pexec.lua) which prevents the injection from working
…0198 to show it working on C1000v and C8000v targets.
…ebui path, we must have the trailing slash (seen in a C8000v target, verified to work in both C8000v and C1000v targets)
…in, CVE-2023-20198, to perform a version based check. However the second vuln in the chain, CVE-2023-20273, was not verified as to working, so a return code of CheckCode::Vulnerable may no have been acurate if the target was vulnerable to CVE-2023-20198 but not CVE-2023-20273. Now we leverage both CVE-2023-20198 and CVE-2023-20273 to ensure the target is actually vulnerable. For example, it has been observed that the C8000v series appliance version 17.6.5 is vulnerable to CVE-2023-20198, but not vulnerable to CVE-2023-20273, even though the IOS-XE version indicates they should be vulnerable to CVE-2023-20273. As this exploit chains both CVE-2023-20198 and CVE-2023-20273 together, the check routine must verify both CVEs work as expected in order to return CheckCode::Vulnerable (i.e. we cannot solely rely on a version based check via CVE-2023-20198).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request fixes several bugs in the
exploit/linux/misc/cisco_ios_xe_rce
module. It was reported that this module was failing for a target Cisco IOS XE device running version17.06.05
. After recreating the failure in a lab environment, several issue became apparent. The original module (pull #18507) was tested against several versions from the CSR1000v series of appliances, however when testing against a C8000v series appliance the module would fail unexpectedly. The issues when targeting a C8000v series appliance were as follows./webui
URI is made, when targeting both CSR1000v and C8000v series appliances, this URI should be/webui/
(Note the trailing path separator). Fixed in commit 4a38605.run_cli_command
the target URI/%2577ebui_wsma_https
was being used to leverage the first vulnerability in the exploit chain, CVE-2023-20198. When targeting both CSR1000v and C8000v series appliances the_https
portion must also not all be in lowercase, e.g./%2577eb%2575i_%2577sma_hTtPs
. Additionally, if targeting HTTP and not HTTPS, the URI/%2577eb%2575i_%2577sma_hTtP
must be used (Note the lack of a trailings
). Fixed in commit 60a496e.So before these changes, targeting a C8000v series appliance running IOS XE version
17.06.05
would show this in the check routine:However, after the above changes, exploitation against a C8000v series appliance running IOS XE version
17.06.05
would fail to execute a payload.Digging into the source code for the C8000v series appliance running IOS XE version
17.06.05
, shows that this series/version is vulnerable to CVE-2023-20198, and while it is also vulnerable to the OS command injection CVE-2023-20273, the command injection it is not exploitable due to additional filtering present in the Lua code that was not seen in the CSR1000v series appliances.This is because the
installAdd
REST endpoint actually callssoftwareUpgradeUtils.startInstallOp
to execute the OS command that contains the command injection (the attacker can poison theurl
variable, passed to the--remote_path
argument) and notutils.runOSCommand
like in the CSR1000v appliances.But
softwareUpgradeUtils.startInstallOp
will callutils.runPexecCommand
to execute the command.And
utils.runPexecCommand
will callpexec.pexec_setsid
.We can see that
pexec_setsid
will callgen_cmd_str
.And
gen_cmd_str
will callargs_valid
.The function
args_valid
will validate the arguments, and we fail to inject with the attacker controlledurl
argument (passed with the--remote_path
option), because we cannot satisfy any of the below checks.Given the exploit can fail against some IOS XE targets, the
check
routine will now exploit both CVE-2023-20198 and CVE-2023-20273 to ensure a target is actually vulnerable, and can be exploited to execute a payload. Fixed in commit 9c075c7.For example, we can see the new check routine working against two CSR1000v targets, then failing with a useful error message for the C8000v target.