seladb / PcapPlusPlus

PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use. It provides C++ wrappers for the most popular packet processing engines such as libpcap, Npcap, WinPcap, DPDK, AF_XDP and PF_RING.
https://pcapplusplus.github.io/
The Unlicense
2.68k stars 652 forks source link

Fuzzing PcapPlusPlus about packet file analyzing #1263

Open Hyeong-Uk opened 9 months ago

Hyeong-Uk commented 9 months ago

I'm a student of Seoul National University(Korea), and I tried to fuzz this library(only for file analyzing, not for analyzing live communication) for exercise.. I think I found heap overflow and few different minor weak points... Please check it and report some details to me.

I used PcapPlusPlus v23.09 on Linux(Ubuntu 20.04LTS 64bit) and AFL fuzzer 2.57b. Test code: test1.txt There are Initial test pcap file and crashed test file but can't upload because github issue doesn't support .pcap uploading... If you want inputs, contact me with kohowo1999@snu.ac.kr or kohowo2000@gmail.com(recommended) .

Crashes: crash.log The crash id of heap buffer overflow is 42.

seladb commented 9 months ago

Thank you @Hyeong-Uk for reporting this issue!

Maybe you can upload the pcap file with a different extension (i.e .txt)?

Also - would you consider providing a fix to this issue?

Hyeong-Uk commented 9 months ago

@seladb Here are pcap files: Initial pcap input(afl fuzzing): datafin3.txt Crashed pcap input: id:000042,sig:11,src:000000,op:flip2,pos:57.txt

+Sorry for (can)not providing a fix +Would you report me about results? I'm curious whether it is really a weak point or not.

Thank you.

seladb commented 9 months ago

Thank you @Hyeong-Uk ! We'll comment on this ticket once we have a fix

cc @sashashura

sashashura commented 9 months ago

@Hyeong-Uk Could you provide your harness?

tigercosmos commented 7 months ago

@Hyeong-Uk is this still an issue? or I will close the ticket.

Hyeong-Uk commented 7 months ago

@sashashura I'm very sorry for seeing your comment now. I'm just a novice for this field, so I don't understand what does 'provide harness' mean. Does it mean 'provide my execution environment'? @tigercosmos Could you delay closing a little bit? Or if you.. judge that this issue is meaningless, you can close the ticket, of course.

sashashura commented 7 months ago

Hi @Heysunk, harness is the code you used to trigger the crash. I must apologize, I didn't notice the test1.txt first. This is what I meant. We have a backlog of security issues to fix, but it seems the item 42 with this stack is not in the list of already known issues:

==1942299==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x611000000b19 at pc 0x0000004c0dda bp 0x7ffecbca39f0 sp 0x7ffecbca31b8
READ of size 256 at 0x611000000b19 thread T0
    #0 0x4c0dd9 in __asan_memcpy (/home/hyeonguk/SNU4_2/opensrc/PcapPlusPlus/examples_bin/test1+0x4c0dd9)
    #1 0x6820ce in pcpp::PayloadLayer::PayloadLayer(unsigned char const*, unsigned long, bool) /home/hyeonguk/SNU4_2/opensrc/PcapPlusPlus/Packet++/src/PayloadLayer.cpp:14:2
    #2 0x51a39b in splitIPPacketToFragmentsBySize(pcpp::RawPacket*, unsigned long, pcpp::PointerVector<pcpp::RawPacket>&) /home/hyeonguk/SNU4_2/opensrc/PcapPlusPlus/Examples/test1/test1.cpp:891:22
    #3 0x51b9a6 in processPacketsIPF(pcpp::IFileReaderDevice*, pcpp::IFileWriterDevice*, int, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::map<unsigned short, bool, std::less<unsigned short>, std::allocator<std::pair<unsigned short const, bool> > >, bool, FragStats&) /home/hyeonguk/SNU4_2/opensrc/PcapPlusPlus/Examples/test1/test1.cpp:993:4
    #4 0x545eda in main /home/hyeonguk/SNU4_2/opensrc/PcapPlusPlus/Examples/test1/test1.cpp:2353:2
    #5 0x7fd362bae082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
    #6 0x44924d in _start (/home/hyeonguk/SNU4_2/opensrc/PcapPlusPlus/examples_bin/test1+0x44924d)

Could you please send the initial pcap and the test file that triggers the crash to my email (listed in my profile)?

Hyeong-Uk commented 5 months ago

@sashashura Hello, I has been busy for preparing graduate school in SNU(Seoul National University(Korea)), and fortunately my acceptance to graduate school was decided. And now that I have some free time, I'm going to focus on this work. I sent those files to your email, so if you are still interested in this issue, please check and report me whether it is really a weak point or not(and if it is real weak point, then how crash occured in detail.). Thank you very much.

tigercosmos commented 5 months ago

@Hyeong-Uk I think you can put the files here for more people to review. (simply click the "Paste, drop, or click to add files" button)

Hyeong-Uk commented 5 months ago

@tigercosmos Thank you for your comment. ^^ However, all the basic files are here(above), for example: test code(test1.txt), crash log(crash.log), fuzzed initial pcap file(datafin3.txt), etc.(and also, environment information.). Though, anyone who are interested in this issue can request me for additional files or information - then I will send them to your email.

sashashura commented 5 months ago

Hi @Hyeong-Uk, we fully understand the reason for changing file extensions. This is very common practice.

It seems there was confusion from my side which file is which, so I'll just iterate to be sure we have all we need:

Optional files that are not strictly needed to reproduce the crash:

I'll look into it when time permits.

Hyeong-Uk commented 4 months ago

@sashashura Thanks for your comment, that's all true. I'll look forward to your report. Thanks.

tigercosmos commented 1 month ago

@sashashura Is there any update?