Skip to content

Commit 8c850ea

Browse files
updated software version checks for CVE-2022-20623
1 parent c5cbd10 commit 8c850ea

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

CVEasy/Cisco/2022/cve202220623.py

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from comfy import high
2-
2+
import re
33

44
@high(
55
name='rule_cve202220623',
@@ -11,34 +11,45 @@
1111
)
1212
def rule_cve202220623(configuration, commands, device, devices):
1313
"""
14-
This rule checks for the CVE-2022-20623 vulnerability in Cisco NX-OS Software.
15-
The vulnerability is due to a logic error in the BFD rate limiter functionality of Nexus 9000 Series Switches.
16-
An unauthenticated, remote attacker could exploit this vulnerability by sending a crafted stream of traffic
17-
through the device, causing BFD traffic to be dropped and resulting in BFD session flaps, route instability,
18-
and a denial of service condition.
14+
CVE-2022-20623: BFD DoS vulnerability in Cisco NX-OS.
15+
Affects Nexus 9000 Series if BFD is enabled and version ≤ 7.0(3)I7(10) or ≤ 9.3(8).
1916
"""
20-
# Extract the platform information
2117
platform_output = commands.show_version
18+
bfd_output = commands.check_bfd
2219

23-
# Check if the device is a Nexus 9000 Series
20+
# 1. Check if device is a Nexus 9000
2421
is_n9k = 'Nexus 9000' in platform_output
25-
26-
# If not a Nexus 9000 device, it's not vulnerable
2722
if not is_n9k:
2823
return
2924

30-
# Extract the output of the command to check BFD configuration
31-
bfd_output = commands.check_bfd
32-
33-
# Check if BFD is enabled
25+
# 2. Check if BFD is enabled
3426
bfd_enabled = 'feature bfd' in bfd_output
27+
if not bfd_enabled:
28+
return
29+
30+
# 3. Extract NX-OS version
31+
match = re.search(r'NXOS:\s+version\s+([\w\.\(\)]+)', platform_output, re.IGNORECASE)
32+
if not match:
33+
return # Can't extract version
34+
35+
version = match.group(1)
36+
37+
def parse_version(ver):
38+
return [int(x) if x.isdigit() else x for x in re.split(r'[\.\(\)I]+', ver) if x]
39+
40+
v = parse_version(version)
41+
is_vulnerable = False
42+
43+
# 4. Compare version against vulnerable builds
44+
if version.startswith("7.0.3") and 'I' in version:
45+
is_vulnerable = v <= parse_version("7.0.3.I7.10")
46+
elif version.startswith("9.3"):
47+
is_vulnerable = v <= parse_version("9.3.8")
3548

36-
# Assert that the device is not vulnerable
37-
assert not bfd_enabled, (
49+
# 5. Assert only if BFD is enabled and version is affected
50+
assert not is_vulnerable, (
3851
f"Device {device.name} is vulnerable to CVE-2022-20623. "
39-
"The device is a Nexus 9000 Series switch with BFD enabled, "
40-
"which could allow an unauthenticated attacker to cause BFD session flaps and a denial of service "
41-
"through crafted traffic. "
42-
"For more information, see"
43-
"https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-nxos-bfd-dos-wGQXrzxn"
52+
f"Nexus 9000 Series switch with NX-OS version {version} has BFD enabled, "
53+
"which could allow a remote attacker to cause BFD session flaps and a denial of service. "
54+
"See: https://sec.cloudapps.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-nxos-bfd-dos-wGQXrzxn"
4455
)

0 commit comments

Comments
 (0)