Wireshark is a hugely popular tool used by network professionals around the globe. But like any software, it’s not immune to security risks. In early 2023, security experts identified and reported a serious vulnerability, now known as CVE-2023-0666, affecting Wireshark versions up to 4..5.
This vulnerability lies in how Wireshark handles a particular network protocol—RTPS (Real-Time Publish-Subscribe Protocol). If you use Wireshark to open a malicious "pcap" file or sniff real traffic, you might be at risk. Let's walk through how this flaw works, show you relevant code, detail what attackers could do, and explain how to stay safe.
What Is CVE-2023-0666?
CVE-2023-0666 is a heap-based buffer overflow in Wireshark, triggered by opening or analyzing a crafted RTPS packet. RTPS is used for fast, reliable data sharing—like with robotics, IoT, or industrial controls.
Wireshark’s RTPS dissector, which interprets RTPS packets for the user, fails to check that the length fields in a packet match the actual size of the packet. If a field claims there are more bytes than exist, Wireshark could end up writing past the end of a memory buffer. This is called a heap overflow.
A remote attacker could potentially use this flaw to crash Wireshark (a denial of service, or DoS), or even run malicious code as the user running Wireshark—dangerous if you analyze untrusted packet data (like malware traffic or capture files from someone else).
Understanding the Vulnerability
When Wireshark parses RTPS packets, it reads a length field provided by the attacker. The process looks a bit like this (simplified C code):
uint16_t length = tvb_get_letohs(tvb, offset); // Reads length from packet
guint8* data = (guint8*) g_malloc(length); // Allocates buffer of 'length' bytes
tvb_memcpy(tvb, data, offset+2, length); // Copies 'length' bytes from packet
The problem is that length is attacker-controlled, but Wireshark’s code does not verify if the packet actually contains enough data to fill length bytes. If length is bigger than the real data, the tvb_memcpy will read and write outside the bounds of the allocated memory.
Example
Suppose length=512, but the packet only contains 32 bytes after the header. Wireshark still tries to copy 512 bytes, overrunning the buffer.
Exploitation
An attacker could create a .pcap file containing a malicious RTPS packet with a length field longer than the actual packet data. When Wireshark opens this pcap—or captures live malicious traffic—it tries to process the packet and overruns memory. What happens next depends on luck:
- Best (for attacker): Carefully crafted packets and heap grooming allow execution of malicious code within the Wireshark process. That’s game over—arbitrary code could steal files, drop malware, etc.
- Normal: Wireshark crashes due to memory corruption. This can be used in denial of service attacks against network analysts.
Here’s a minimalist hexadecimal RTPS packet that could trigger the overflow
ab cd 10 00 02 00 [attacker sets length field to high value] [malicious data]
The important part: the "length" field is set higher than the data available.
If you want to try a safe test in a lab, you can craft a .pcap file with such a packet using Scapy:
from scapy.all import *
pkt = Ether()/IP()/UDP()/Raw(b"\xab\xcd\x10\x00\x02\x00" + b"\xff"*512)
wrpcap("rtps_crash.pcap", pkt)
Warning: Only test with patched Wireshark, NOT production systems—this is real exploitation.
Wireshark Security Advisory:
https://www.wireshark.org/security/wnpa-sec-2023-07.html
CVE Details:
https://nvd.nist.gov/vuln/detail/CVE-2023-0666
Bug Report - Wireshark RTPS Buffer Overflow:
https://gitlab.com/wireshark/wireshark/-/issues/18885
- Official Patch / Fix Commit:
https://gitlab.com/wireshark/wireshark/-/commit/35dfe945
How Was It Fixed?
The Wireshark team issued a fix in Wireshark 4..6 and later. The patch added checks like this before allocating memory or copying data:
if (remaining_data < length) {
proto_tree_add_expert_format(..., "Invalid length field (%u > %u)", length, remaining_data);
return;
}
This simple conditional ensures that Wireshark will NOT read or write past the buffer size declared in the packet, preventing overflows and the associated exploits.
Remediation: What Should You Do?
- Upgrade Wireshark: Download latest release here.
Conclusion
*CVE-2023-0666* is a prime example of why thorough input validation is key in packet parsers. Heap overflows like this can have devastating consequences, from app crashes to remote code execution. Thanks to the Wireshark team’s fast response, the flaw is fixed—but it’s up to you to stay protected.
Always keep security tools up to date—and never trust a length field from the network.
*Exclusive long read by OpenAI's ChatGPT. For safe learning and awareness. Do not exploit on production systems.*
Timeline
Published on: 06/07/2023 03:15:00 UTC
Last modified on: 06/16/2023 04:15:00 UTC