mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 14:08:20 +00:00
Prevent IP fragment reassembly on packets without minimal IP header
The IP fragment reassembly process assumes a packet contains at least the minimum IP header, but such a check did not previously occur, resulting in a heap buffer over-read. For example, a self-reported IPv4 IHL field with a value less than minimum IPv4 header length of 20 bytes. Such packets likely aren't routable on their own, but one can create an artifical pcap like that or possibly encapsulate it within another protocol to trigger this bug.
This commit is contained in:
parent
1fe5454603
commit
a2f2f7a0dd
1 changed files with 17 additions and 0 deletions
|
@ -247,6 +247,23 @@ void NetSessions::DoNextPacket(double t, const Packet* pkt, const IP_Hdr* ip_hdr
|
|||
return;
|
||||
}
|
||||
|
||||
if ( ip_hdr->IP4_Hdr() )
|
||||
{
|
||||
if ( ip_hdr_len < sizeof(struct ip) )
|
||||
{
|
||||
Weird("IPv4_min_header_size", pkt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ip_hdr_len < sizeof(struct ip6_hdr) )
|
||||
{
|
||||
Weird("IPv6_min_header_size", pkt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore if packet matches packet filter.
|
||||
if ( packet_filter && packet_filter->Match(ip_hdr, len, caplen) )
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue