Kuboid
Open Luck·Kuboid.in
Black Hat2023
Open in YouTube ↗

BGP Implementation Vulnerabilities and Fuzzing

Black Hat1,307 views35:19about 2 years ago

This talk demonstrates multiple memory corruption vulnerabilities, specifically out-of-bounds reads, within the BGP implementation of the FRRouting (FRR) suite. The researchers analyze the BGP state machine and message parsing logic to identify flaws in how extended optional parameters are handled. The presentation highlights the risks of 'shotgun parsing' in complex network protocols and provides a custom fuzzer, 'boofuzz', to help security professionals identify similar issues in other BGP implementations. The findings underscore the critical need for rigorous input validation in network infrastructure software.

BGP Implementation Vulnerabilities: Why Your Routing Stack is a Memory Corruption Goldmine

TLDR: Researchers at Black Hat 2023 demonstrated that modern BGP implementations, including FRRouting, are susceptible to memory corruption vulnerabilities like out-of-bounds reads due to "shotgun parsing" of complex messages. These flaws allow attackers to trigger denial-of-service conditions by sending malformed BGP packets, even before a full BGP session is established. Security professionals should audit their network infrastructure for these vulnerable routing stacks and utilize the newly released boofuzz tool to test their own environments.

Network security often focuses on the perimeter, but the infrastructure that directs traffic across the internet is frequently overlooked. While we obsess over web application firewalls and endpoint detection, the BGP implementations running on our routers and virtual appliances are often treated as "black boxes" that just work. The research presented at Black Hat 2023 by Vedere Labs shatters this assumption, proving that even critical routing software like FRRouting suffers from classic memory corruption issues that can be exploited to take down entire network segments.

The Danger of Shotgun Parsing in BGP

The core issue identified in this research is a classic case of "shotgun parsing." This occurs when a program attempts to parse a complex, structured input—in this case, a BGP message—without first validating the integrity or bounds of the data. BGP is a stateful protocol, but the researchers found that several implementations attempt to parse message fields, such as extended optional parameters, before the BGP session is even fully authenticated or established.

By sending a malformed BGP OPEN message, an attacker can trigger an out-of-bounds read. Because the BGP daemon often runs with high privileges, these crashes are not just minor bugs; they result in a complete reset of the BGP session. In a production environment, this leads to the dropping of all BGP sessions and routing tables, rendering the peer unresponsive. The impact is a self-inflicted denial-of-service that can be sustained indefinitely by repeatedly sending the malformed packets.

Technical Breakdown: CVE-2022-40302 and Friends

The researchers identified three specific vulnerabilities in FRRouting, cataloged as CVE-2022-40302, CVE-2022-40318, and CVE-2022-43681. These flaws stem from insufficient bounds checking when reading extended length octets in BGP messages.

Consider the logic for handling optional parameters. The code reads a length field and then attempts to read the corresponding number of bytes. If the length field is manipulated to be larger than the actual packet size, or if the logic fails to account for the specific encoding of extended parameters, the parser reads past the end of the buffer.

// Simplified representation of the vulnerable logic
if (opt_type == EXTENDED_TYPE) {
    // Reads length from packet, then attempts to read 'len' bytes
    // without verifying if 'len' exists within the remaining buffer
    read_bytes(packet, len); 
}

In the case of these vulnerabilities, the parser assumes the packet is well-formed. When it encounters an unexpected length value, it attempts to access memory outside the allocated buffer. Because these checks happen early in the message processing flow, an attacker does not need to be a trusted peer. They only need to be able to route a packet to the target router and spoof a valid IP address to initiate the connection.

Real-World Applicability for Pentesters

For those of us on the offensive side, this research changes how we approach network infrastructure assessments. We are no longer just looking for misconfigurations or weak passwords on management interfaces. We now have a clear path to testing the resilience of the routing stack itself.

If you are conducting an engagement where you have access to the internal network, you should identify all devices running BGP. Tools like Shodan can help you map the external footprint, but internal discovery is key. Once you have identified the targets, you can use the boofuzz framework released by the researchers to test for similar parsing flaws. The tool is designed to establish a BGP session and then inject malformed payloads, monitoring the target for crashes.

This is particularly relevant for organizations adopting Network Function Disaggregation (NFD). As hardware and software become decoupled, the number of vendors and open-source projects involved in the routing stack increases, expanding the attack surface. If a vendor is using an outdated or unpatched version of FRRouting or Quagga, they are effectively inheriting these vulnerabilities.

Defensive Hardening

Defenders must prioritize the patching of routing software. While routing security initiatives like MANRS are essential for preventing route leaks and hijacks, they do not protect against memory corruption in the daemon itself.

Ensure that your BGP daemons are running in a restricted environment where possible, and strictly limit which IP addresses are allowed to initiate BGP sessions. If you are using open-source routing platforms, you must have a process for tracking upstream security advisories and pushing those patches down to your specific appliances. Relying on a vendor to provide these updates is often a slow process, and as the researchers noted, the time between a fix being committed to an open-source project and it reaching a downstream appliance can be significant.

The era of assuming that routing protocols are "too simple to be broken" is over. As we continue to push more intelligence into the network edge, we must apply the same rigor to the software running on our routers that we apply to our web applications. If you aren't fuzzing your network infrastructure, you are leaving a massive, unmonitored hole in your security model.

Talk Type
research presentation
Difficulty
advanced
Has Demo Has Code Tool Released


Black Hat USA 2023

118 talks · 2023
Browse conference →
Premium Security Audit

We break your app before they do.

Professional penetration testing and vulnerability assessments by the Kuboid Secure Layer team. Securing your infrastructure at every layer.

Get in Touch
Official Security Partner
kuboid.in