|
| 1 | +from comfy import high |
| 2 | + |
| 3 | + |
| 4 | +@high( |
| 5 | + name='rule_cve202220623', |
| 6 | + platform=['cisco_nxos'], |
| 7 | + commands=dict( |
| 8 | + show_version='show version', |
| 9 | + check_bfd='show running-config | include feature bfd' |
| 10 | + ), |
| 11 | +) |
| 12 | +def rule_cve202220623(configuration, commands, device, devices): |
| 13 | + """ |
| 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. |
| 19 | + """ |
| 20 | + # Extract the platform information |
| 21 | + platform_output = commands.show_version |
| 22 | + |
| 23 | + # Check if the device is a Nexus 9000 Series |
| 24 | + is_n9k = 'Nexus 9000' in platform_output |
| 25 | + |
| 26 | + # If not a Nexus 9000 device, it's not vulnerable |
| 27 | + if not is_n9k: |
| 28 | + return |
| 29 | + |
| 30 | + # Extract the output of the command to check BFD configuration |
| 31 | + bfd_output = commands.check_bfd |
| 32 | + |
| 33 | + # Check if BFD is enabled |
| 34 | + bfd_enabled = 'feature bfd' in bfd_output |
| 35 | + |
| 36 | + # Assert that the device is not vulnerable |
| 37 | + assert not bfd_enabled, ( |
| 38 | + 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" |
| 44 | + ) |
0 commit comments