PcapPlusPlus
PcapPlusPlus copied to clipboard
Heap buffer overflow (read) in RadiusLayer::isDataValid(unsigned char const*, unsigned long) at RadiusLayer.cpp:246:19
There is a buffer overflow at the specified location:
==902091==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x606000000420 at pc 0x0000005c944c bp 0x7fff0bdc72c0 sp 0x7fff0bdc72b8
READ of size 2 at 0x606000000420 thread T0
#0 0x5c944b in pcpp::RadiusLayer::isDataValid(unsigned char const*, unsigned long) /home/vivin/Projects/phd/subjects/pcapplusplus/PcapPlusPlus-master/Packet++/src/RadiusLayer.cpp:246:19
#1 0x57207b in pcpp::UdpLayer::parseNextLayer() /home/vivin/Projects/phd/subjects/pcapplusplus/PcapPlusPlus-master/Packet++/src/UdpLayer.cpp:128:89
#2 0x54a40b in pcpp::Packet::setRawPacket(pcpp::RawPacket*, bool, unsigned long, pcpp::OsiModelLayer) /home/vivin/Projects/phd/subjects/pcapplusplus/PcapPlusPlus-master/Packet++/src/Packet.cpp:80:13
#3 0x54d82b in pcpp::Packet::Packet(pcpp::RawPacket*, bool, unsigned long, pcpp::OsiModelLayer) /home/vivin/Projects/phd/subjects/pcapplusplus/PcapPlusPlus-master/Packet++/src/Packet.cpp:126:2
#4 0x4f33c3 in main /home/vivin/Projects/phd/resources/archives/pcapplusplus/readpcap.cpp:30:20
#5 0x7fa2062e60b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#6 0x4441bd in _start (/home/vivin/Projects/phd/workspace/smartdsf/pcapplusplus/binaries/vanilla-asan/readpcap+0x4441bd)
0x606000000420 is located 0 bytes to the right of 64-byte region [0x6060000003e0,0x606000000420)
allocated by thread T0 here:
#0 0x4f05ed in operator new[](unsigned long) (/home/vivin/Projects/phd/workspace/smartdsf/pcapplusplus/binaries/vanilla-asan/readpcap+0x4f05ed)
#1 0x4f942d in pcpp::PcapFileReaderDevice::getNextPacket(pcpp::RawPacket&) /home/vivin/Projects/phd/subjects/pcapplusplus/PcapPlusPlus-master/Pcap++/src/PcapFileDevice.cpp:306:27
#2 0x4f3328 in main /home/vivin/Projects/phd/resources/archives/pcapplusplus/readpcap.cpp:28:17
#3 0x7fa2062e60b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/vivin/Projects/phd/subjects/pcapplusplus/PcapPlusPlus-master/Packet++/src/RadiusLayer.cpp:246:19 in pcpp::RadiusLayer::isDataValid(unsigned char const*, unsigned long)
Shadow bytes around the buggy address:
0x0c0c7fff8030: fa fa fa fa fd fd fd fd fd fd fd fd fa fa fa fa
0x0c0c7fff8040: fd fd fd fd fd fd fd fd fa fa fa fa fd fd fd fd
0x0c0c7fff8050: fd fd fd fd fa fa fa fa fd fd fd fd fd fd fd fd
0x0c0c7fff8060: fa fa fa fa fd fd fd fd fd fd fd fd fa fa fa fa
0x0c0c7fff8070: fd fd fd fd fd fd fd fd fa fa fa fa 00 00 00 00
=>0x0c0c7fff8080: 00 00 00 00[fa]fa fa fa 00 00 00 00 00 00 00 00
0x0c0c7fff8090: fa fa fa fa 00 00 00 00 00 00 00 00 fa fa fa fa
0x0c0c7fff80a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c0c7fff80b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c0c7fff80c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c0c7fff80d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==902091==ABORTING
Aborted
I have attached the input that triggers the vulnerability. radiuslayer.pcap.zip
Hi @vivin !
In this issue and the other issues you opened you didn't specify the code you're running so I don't know how to reproduce them. Please provide the code, otherwise I'm not sure what to do with it.
Sorry about that. I have provided it in #856.
@sashashura would you consider fixing this issue?
Thank you @sashashura for providing a fix! 🙏