Trustwave SpiderLabs Exposes Unique Cybersecurity Threats in the Public Sector. Learn More

Trustwave SpiderLabs Exposes Unique Cybersecurity Threats in the Public Sector. Learn More

Services
Capture
Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

twi-managed-portal-color
Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

twi-briefcase-color-svg
Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

tw-laptop-data
Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

twi-database-color-svg
Database Security

Prevent unauthorized access and exceed compliance requirements.

twi-email-color-svg
Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

tw-officer
Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

tw-network
Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Solutions
BY TOPIC
Offensive Security
Solutions to maximize your security ROI
Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

Bad Neighbors Can Break Windows (CVE-2020-16898)

On October 13th, 2020, Microsoft released a patch for a critical vulnerability (CVE-2020-16898) in the IPv6 stack, capable of causing BSOD (Blue Screen of Death). The vulnerability, codenamed “Bad Neighbor”, is a bug in the IPv6 Neighbor Discovery Protocol, particularly it’s improper handling of ICMPv6 Router Advertisement Packets. While publicly available proof of concept (PoC) code results in a denial of service, attackers can exploit this bug to perform remote code execution (RCE). This combined with ease of exploitation has earned this vulnerability a CVSS v3 score of 8.8.

Vulnerability Details and Analysis

This vulnerability results from improper handling of ICMPv6 Router Advertisements with Recursive DNS Server options (RDNSS) and an even length field value. According to RFC 8106 the length option for RDNSS is in units of 8 octets with a minimum value of 3 for one IPv6 address and every additional RDNSS address increases the length by 2. This field is used to determine the number of IPv6 addresses in the option (See Figure 1 below). The addresses field is a variable field that determines the number addresses which is equal to (Length-1)/2. Each IPv6 address is 16 bytes in length and each requires the length field to be greater than 3 and an odd number.

      0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Length | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Lifetime |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
: Addresses of IPv6 Recursive DNS Servers :
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Figure 1: RDNSS Option Format

 

The Exploit

By Sending an RDNSS option with an even length, we send an IPv6 address value which is 8 bytes short of the required 16 bytes leading the TCP/IP stack to believe it is the start of a second option leading to buffer overflow or a potential RCE. The Windows driver tcpip.sys fails to parse this type of request with an even option resulting in a denial of service or a BSOD. Tcpip.sys is a windows driver that is used to communicate amongst devices by setting the properties of TCP/IP.

McAfee Labs has a great write up explaining the vulnerability, which we recommend reading. This link also has a detailed explanation of how the exploit works as well as a proof of concept that we used for showing exploitation in the video below.

As we know Bad Neighbor lets the last 8 bytes of the RDNSS option to be interpreted as the first bytes of a new option. The PoC makes use of this misinterpretation and includes Routing Information Option (type = 24) with max length as the new option. As these 8 bytes are initially subjected to be part of the IPv6 address of the RDNSS option it does not undergo validation that includes a size of length check. Finally, the packet is fragmented (See Figure 2 below) to make sure NdisGetDataBuffer will write everything into the storage buffer. The storage buffer is a static buffer of 0x20 bytes is unable to handle all the packets causing buffer overflow leading to BSOD.

Image002
Figure 2: Exploit Packet Fragmentation

Impact

This vulnerability cannot be exploited over the Internet and the /GS(Buffer Security Check) Buffer security exploit mitigation makes it extremely hard to perform code execution on modern Windows operating systems. Weaponizing this to make it wormable will not be trivial. However, it is still potent for denial of service.

Mitigation

The best way to protect your system currently is by applying Microsoft’s October Patch Tuesday updates. If you are unable to patch you should disable ICMPV6 RDNSS with the following Powershell command.

netsh int ipv6 set int *INTERFACENUMBER* rabaseddnsconfig=disable

This workaround is only available for Windows 1709 and above and does not require a reboot. It should be noted that this disables RA-based DNS configuration. Please refer to Microsoft Security Advisory for more details.

Detection guidance

Trustwave Security Testing Services customers can detect if this vulnerability is patched via authenticated scans. Additionally, Trustwave IDPS customers are also covered with new alert signatures for this exploit.

To identify potential exploit attempts, look out for Router Advertisement (RA) packets (type =134) with the RDNSS option (option type = 25) (See Figure 3 below). Flag those that have an even value in its length field. Also, make sure the length is at least 3. In cases that try to exploit the buffer overflow watch out for fragmented IPv6 packets followed by the Router Advertisement (See Figure 2 above). Additionally, a payload size greater than 100 bytes can be a good indication of exploitation. A Windows loader shellcode can be quite small but will most likely push the payload past 100 bytes. As always, monitor your own networks to baseline what is normal to best implement this sort of detection.

Image003Figure 3: Bad Neighbor exploit packet

References

https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2020-16898
https://www.mcafee.com/blogs/other-blogs/mcafee-labs/cve-2020-16898-bad-neighbor/
http://blog.pi3.com.pl/?p=780

 

Latest SpiderLabs Blogs

2024 Public Sector Threat Landscape: Trustwave Threat Intelligence Briefing and Mitigation Strategies

Trustwave SpiderLabs’ 2024 Public Sector Threat Landscape: Trustwave Threat Intelligence Briefing and Mitigation Strategies report details the security issues facing public sector security teams as...

Read More

How to Create the Asset Inventory You Probably Don't Have

This is Part 12 in my ongoing project to cover 30 cybersecurity topics in 30 weekly blog posts. The full series can be found here.

Read More

Guardians of the Gateway: Identity and Access Management Best Practices

This is Part 10 in my ongoing project to cover 30 cybersecurity topics in 30 weekly blog posts. The full series can be found here.

Read More