Commit Graph

4797 Commits

Author SHA1 Message Date
Guy Harris
eee0b04bcf CVE-2017-13022/IP: Add bounds checks to ip_printroute().
This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.

Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.
2017-09-13 12:25:44 +01:00
Guy Harris
67c7126062 CVE-2017-13021/ICMP6: Add a missing bounds check.
This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.

Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.
2017-09-13 12:25:44 +01:00
Guy Harris
c5dd7bef5e CVE-2017-13020/VTP: Add some missing bounds checks.
This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.

Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.
2017-09-13 12:25:44 +01:00
Guy Harris
4601c685e7 CVE-2017-13019: Clean up PGM option processing.
Add #defines for option lengths or the lengths of the fixed-length part
of the option.  Sometimes those #defines differ from what was there
before; what was there before was wrong, probably because the option
lengths given in RFC 3208 were sometimes wrong - some lengths included
the length of the option header, some lengths didn't.

Don't use "sizeof(uintXX_t)" for sizes in the packet, just use the
number of bytes directly.

For the options that include an IPv4 or IPv6 address, check the option
length against the length of what precedes the address before fetching
any of that data.

This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.

Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.
2017-09-13 12:25:44 +01:00
Guy Harris
26a6799b9c CVE-2017-13018/PGM: Add a missing bounds check.
This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.

Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.
2017-09-13 12:25:44 +01:00
Guy Harris
11b426ee05 CVE-2017-13017/DHCPv6: Add a missing option length check.
This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.

Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.
2017-09-13 12:25:44 +01:00
Guy Harris
c177cb3800 CVE-2017-13016/ES-IS: Fix printing of addresses in RD PDUs.
Always print the SNPA, and flag it as such; only print it as a MAC
address if it's 6 bytes long.

Identify the NET as such.

This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.

Add tests using the capture files supplied by the reporter(s), modified
so the capture files won't be rejected as an invalid capture.
2017-09-13 12:25:44 +01:00
Guy Harris
9851220811 CVE-2017-13015/EAP: Add more bounds checks.
This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.

Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.
2017-09-13 12:25:44 +01:00
Guy Harris
cc356512f5 CVE-2017-13014/White Board: Do more bounds checks.
This fixes a buffer over-read discovered by Yannick Formaggio.

Add a test using the capture file supplied by the reporter(s).

While we're at it, print a truncation error if the packets are
truncated, rather than just, in effect, ignoring the result of the
routines that print particular packet types.
2017-09-13 12:25:44 +01:00
Guy Harris
13ab8d1861 CVE-2017-13013/ARP: Fix printing of ARP protocol addresses.
If the protocol type isn't ETHERTYPE_IP or ETHERTYPE_TRAIL, or if the
protocol address length isn't 4, don't print the address as an IPv4 address.

This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.

Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.

Update another test file's tcpdump output to reflect this change.
2017-09-13 12:25:44 +01:00
Guy Harris
8509ef02ec CVE-2017-13012/ICMP: Add a missing bounds check.
Check before fetching the length from the included packet's IPv4 header.

This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.

Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.
2017-09-13 12:25:44 +01:00
Guy Harris
9f0730bee3 CVE-2017-13011/Properly check for buffer overflow in bittok2str_internal().
Also, make the buffer bigger.

This fixes a buffer overflow discovered by Bhargava Shastry,
SecT/TU Berlin.

Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.
2017-09-13 12:25:44 +01:00
Guy Harris
93493458ca ip6r0_reserved is an array of octets; extract the value from it.
dp0->ip6r0_reserved evaluates to a pointer to the first element of the
array, which is always non-null, so it doesn't test whether the *value*
of the field is non-zero.  Call EXTRACT_32BITS() on it to check whether
the value is zero.
2017-09-13 12:25:44 +01:00
Denis Ovsienko
95cb8ad87a Fix Linux/GCC build after the previous commit.
ip6.h now needs netdissect.h, fix includes order where required to fix:

./ip6.h:181:2: error: unknown type name ‘nd_uint8_t’
  nd_uint8_t  ip6r0_nxt;  /* next header */
  ^
./ip6.h:182:2: error: unknown type name ‘nd_uint8_t’
  nd_uint8_t  ip6r0_len;  /* length in units of 8 octets */
  ^
./ip6.h:183:2: error: unknown type name ‘nd_uint8_t’
  nd_uint8_t  ip6r0_type;  /* always zero */
  ^
./ip6.h:184:2: error: unknown type name ‘nd_uint8_t’
  nd_uint8_t  ip6r0_segleft; /* segments left */
  ^
./ip6.h:185:2: error: unknown type name ‘nd_uint32_t’
  nd_uint32_t ip6r0_reserved; /* reserved field */
  ^
2017-09-13 12:25:44 +01:00
Francois-Xavier Le Bail
1ead603da6 RT6: Fix alignment issue with Solaris Studio 12.3 on Solaris 10 SPARC
Fix the 'Bus Error - core dumped' issue with the 'ipv6-routing-header' test
when '-m64' compiling option is used.

Fix with the method described in commit 1376682.

/opt/solarisstudio12.3/bin/cc -V
gives:
cc: Sun C 5.12 SunOS_sparc Patch 148917-09 2016/08/02
2017-09-13 12:25:44 +01:00
Francois-Xavier Le Bail
78ba87d130 BGP: Fix a test invalid on a 32 bits system
The 'len - (tptr - pptr)' expression type is 'unsigned int' on a 32 bits
system.
Thus the conversion changes negative values to positive ones and the > 0
test is invalid.
Update the expression to compare two pointers.
2017-09-13 12:25:44 +01:00
Guy Harris
877b66b398 CVE-2017-13010/BEEP: Do bounds checking when comparing strings.
This fixes a buffer over-read discovered by Brian 'geeknik' Carpenter.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
db8c799f6d CVE-2017-13009/IPv6 mobility: Add a bounds check.
This fixes a buffer over-read discovered by Brian 'geeknik' Carpenter.

Add a test using the capture file supplied by the reporter(s).

While we're at it:

Add a comment giving the RFC for IPv6 mobility headers.

Clean up some bounds checks to make it clearer what they're checking, by
matching the subsequent EXTRACT_ calls or memcpy.

For the binding update, if none of the flag bits are set, don't check
the individual flag bits.
2017-09-13 12:25:44 +01:00
Guy Harris
5edf405d7e CVE-2017-13008/IEEE 802.11: Fix TIM bitmap copy to copy from p + offset.
offset has already been advanced to point to the bitmap; we shouldn't
add the amount to advance again.

This fixes a buffer over-read discovered by Brian 'geeknik' Carpenter.

Add a test using the capture file supplied by the reporter(s).

While we're at it, remove some redundant tests - we've already checked,
before the case statement, whether we have captured the entire
information element and whether the entire information element is
present in the on-the-wire packet; in the cases for particular IEs, we
only need to make sure we don't go past the end of the IE.
2017-09-13 12:25:44 +01:00
Guy Harris
ca336198e8 CVE-2017-13007/PKTAP: Pass a properly updated struct pcap_pkthdr to the sub-dissector.
The sub-dissector expects that the length and captured length will
reflect the actual remaining data in the packet, not the raw amount
including the PKTAP header; pass an updated header, just as we do for
PPI.

This fixes a buffer over-read discovered by Yannick Formaggio.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
cc4a7391c6 CVE-2017-13006/L2TP: Check whether an AVP's content exceeds the AVP length.
It's not good enough to check whether all the data specified by the AVP
length was captured - you also have to check whether that length is
large enough for all the required data in the AVP.

This fixes a buffer over-read discovered by Yannick Formaggio.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
4e430c6b0d CVE-2017-12896/ISAKMP: Add another test.
This is from Brian Carpenter for the print-isakmp bug fix.
2017-09-13 12:25:44 +01:00
Guy Harris
f96003b21e CVE-2017-12899/DECnet: Add another test.
This is from Brian Carpenter for the print-decnet bug fix.
2017-09-13 12:25:44 +01:00
Guy Harris
9aa08721e7 NFS: Check for all relevant RPC call body fields at the beginning.
If we don't have the procedure number, we'll give up eventually; might
as well give up before we do any work that'll be thrown away.
2017-09-13 12:25:44 +01:00
Francois-Xavier Le Bail
b45a9a167c CVE-2017-13005/NFS: Add two bounds checks before fetching data
This fixes a buffer over-read discovered by Kamil Frankowicz.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
35d146b7a6 CVE-2017-13004/Juniper: Add a capture file.
File from Kamil Frankowicz testing an existing fix.

(Same problem, and same fix, as the recent Juniper fixes.)
2017-09-13 12:25:44 +01:00
Guy Harris
42073d54c5 CVE-2017-13004/Juniper: Add a bounds check.
This fixes a buffer over-read discovered by Forcepoint's security
researchers Otto Airamo & Antti Levomäki.

Add tests using the capture files supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
a25211918f CVE-2017-13003/Clean up the LMP dissector.
Do a lot more bounds and length checks.

Add a EXTRACT_8BITS() macro, for completeness, and so as not to confuse
people into thinking that, to fetch a 1-byte value from a packet, they
need to use EXTRACT_16BITS() to fetch a 2-byte value and then use
shifting and masking to extract the desired byte.  Use that rather than
using EXTRACT_16BITS() to fetch a 2-byte value and then shifting and
masking to extract the desired byte.

Don't treat IPv4 addresses and unnumbered interface IDs the same; the
first should be printed as an IPv4 address but the latter should just be
printed as numbers.  Handle IPv6 addresses in more object types while
we're at it.

This fixes a buffer over-read discovered by Forcepoint's security
researchers Otto Airamo & Antti Levomäki.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
cbddb98484 CVE-2017-13002/AODV: Add some missing bounds checks.
In aodv_extension() do a bounds check on the extension header before we
look at it.

This fixes a buffer over-read discovered by Kamil Frankowicz.

Add a test using the capture file supplied by the reporter(s).

While we're at it, add the RFC number, and check the validity of the
length for the Hello extension.
2017-09-13 12:25:44 +01:00
Guy Harris
7a923447fd CVE-2017-13001/NFS: Don't copy more data than is in the file handle.
Also, put the buffer on the stack; no reason to make it static.  (65
bytes isn't a lot.)

This fixes a buffer over-read discovered by Kamil Frankowicz.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
8512734883 CVE-2017-13000/IEEE 802.15.4: Fix bug introduced two fixes prior.
We've already advanced the pointer past the PAN ID, if present; it now
points to the address, so don't add 2 to it.

This fixes a buffer over-read discovered by Forcepoint's security
researchers Otto Airamo & Antti Levomäki.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
a7e5f58f40 CVE-2017-13000/IEEE 802.15.4: Fix bug introduced by previous fix.
We've already advanced the pointer past the PAN ID, if present; it now
points to the address, so don't add 2 to it.

This fixes a buffer over-read discovered by Forcepoint's security
researchers Otto Airamo & Antti Levomäki.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
9be4e0b593 CVE-2017-13000/IEEE 802.15.4: Add more bounds checks.
While we're at it, add a bunch of macros for the frame control field's
subfields, have the reserved frame types show the frame type value, use
the same code path for processing source and destination addresses
regardless of whether -v was specified (just leave out the addresses in
non-verbose mode), and return the header length in all cases.

This fixes a buffer over-read discovered by Forcepoint's security
researchers Otto Airamo & Antti Levomäki.

Add tests using the capture files supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
b1928b44a5 That array only needs 16 elements.
No need for a 17th null terminator.

This might, or might not, give Coverity a clue that

	u_char *p;

	hex[*p >> 4]
	hex[*p & 0xf]

are both safe, no matter how "tainted" p is, because if you shift an
8-bit unsigned value right 4 bits, the result is between 0 and 15.  (See
CID 1206732.)
2017-09-13 12:25:44 +01:00
Guy Harris
761e1c4699 Clean up addrtostr6().
"Word" in "words" means "16-bit words", or "16-bit piece of an IPv6
address".  Declare it so.

Instead of going over the IPv6 address a byte at a time, process 2 bytes
at a time; it makes what the code's doing more obvious.

Should squelch Coverity CID 1324572.
2017-09-13 12:25:44 +01:00
Guy Harris
8849db237e RESP: Fix overflow check.
At that point, result is a multiple of 10, so it can at most be
2147483640, i.e. (INT_MAX / 10)*10.

If it's less than that, you can add any value between 0 and 9 to it and
it won't overflow.

If it's *equal* to that, you can only add a value between 0 and 7
without overflowing, i.e. the maximum is INT_MAX % 10.

Addresses Coverity CID 1400557.
2017-09-13 12:25:44 +01:00
Guy Harris
6b004c4e26 Just dissect the TFTP packet byte by byte.
Don't use a structure to define the layout - Coverity gets confused by
tu_stuff being 1 byte, and complains that we're going past 1 byte.

Should fix Coverity CID 1400556.
2017-09-13 12:25:44 +01:00
Guy Harris
e4f6fefdc7 CFM: There must be at least one byte of MA short name.
This should fix Coverity CID 1400555.
2017-09-13 12:25:44 +01:00
Guy Harris
a4bcef4c86 RESP: Remove some redundant checks.
Before we break out of the loop, we've already checked for those
conditions.  No need to check for them again.

This fixes Coverity CIDs 1400553 and 1400554.
2017-09-13 12:25:44 +01:00
Guy Harris
c7c515ee03 CVE-2017-13725/IPv6 R.H.: Add a capture file.
This is from Kamil Frankowicz testing an existing fix.

This is a test for the print-rt6.c fix I made after inspecting the code.
2017-09-13 12:25:44 +01:00
Guy Harris
6fca58f5f9 CVE-2017-12996/PIMv2: Make sure PIM TLVs have the right length.
We do bounds checks based on the TLV length, so if the TLV's length is
too short, and we don't check for that, we could end up fetching data
past the end of the TLV - including past the length of the captured data
in the packet.

This fixes a buffer over-read discovered by Forcepoint's security
researchers Otto Airamo & Antti Levomäki.

Add tests using the capture files supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
34cec721d3 CVE-2017-12997/LLDP: Don't use an 8-bit loop counter.
If you have a

	for (i = 0; i < N; i++)

loop, you'd better make sure that i is big enough to hold N - not N-1,
N.

The TLV length here is 9 bits long, not 8 bits long, so an 8-bit loop
counter will overflow and you can loop infinitely.

This fixes an infinite loop discovered by Forcepoint's security
researchers Otto Airamo & Antti Levomäki.

Add tests using the capture files supplied by the reporter(s).

Clean up the output a bit while we're at it.
2017-09-13 12:25:44 +01:00
Guy Harris
979dcefd7b CVE-2017-12998/IS-IS: Check for 2 bytes if we're going to fetch 2 bytes.
Probably a copy-and-pasteo.

This fixes a buffer over-read discovered by Forcepoint's security
researchers Otto Airamo & Antti Levomäki.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
3b32029db3 CVE-2017-12999/IS-IS: Add a missing length check.
This fixes a buffer over-read discovered by Forcepoint's security
researchers Otto Airamo & Antti Levomäki.

Add tests using the capture files supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
777edc563a Further fix the fix to CVE-2017-5485.
1) Take the length of the NSAP into account.  Otherwise, if, in our
search of the hash table, we come across a byte string that's shorter
than the string we're looking for, we'll search past the end of the
string in the hash table.

2) The first byte of the byte string in the table is the length of the
NSAP, with the byte *after* that being the first byte of the NSAP, but
the first byte of the byte string passed into lookup_nsap() is the first
byte of the NSAP, with the length passed in as a separate argument.  Do
the comparison correctly.

This fixes a vulnerability discovered by Kamil Frankowicz.

Add a test using the capture file supplied by the reporter(s).

While we're at it, clean up the fix to lookup_bytestring():

1) Get rid of an unused structure member and an unused #define.

2) Get rid of an incorrect "+ 1" when calculating the size of the byte
array to allocate - that was left over from the NSAP table, where the
length was guaranteed to fit in 1 byte and we used the first byte of the
array to hold the length of the rest of the array.
2017-09-13 12:25:44 +01:00
Guy Harris
3a76fd7c95 CVE-2017-12995/Check for DNS compression pointers that don't point backwards.
This is what BIND 9.11.0-P2 does; it not only detects pointers that
loop, as "point backwards" means "point before anything we've processed
so far, including what we're processing right now", so the pointer can't
point to itself (as that's what we're processing right now).

This fixes an infinite loop discovered by Forcepoint's security
researchers Otto Airamo & Antti Levomäki.

Add a test using the capture file supplied by the reporter(s).

Also, add some infinite-pointer-loop captures.

More checks should be done.  We might, for example, want to make sure
the upper 2 bits of the label length/pointer byte are 00 or 11, and that
if we encounter a pointer and jump backwards to what we think is a label
the label ends before the beginning of the last label we processed, to
make sure the pointer doesn't point backwards into the *middle* of a
label, and also make sure the entire name is <= 255 bytes long.
2017-09-13 12:25:44 +01:00
Guy Harris
866c60236c CVE-2017-13687/CHDLC: Add a test.
This is for the fix made a few commits before, which had no tests.

Add a test using the capture file supplied by Kamil Frankowicz.
2017-09-13 12:25:44 +01:00
Denis Ovsienko
d6ba8dc548 Split bgp-aigp-oobr into two custom tests too.
For the same reason as for bgp-as-path-oobr (TCP-MD5).
2017-09-13 12:25:44 +01:00
Guy Harris
ffde45acf3 CVE-2017-12994/BGP: Move a test inside a loop.
The loop can be executed more than once (that's kinda the whole point of
a loop), so the check has to be made each time through the loop, not
just once before the loop is executed.

Do some additional length checks while we're at it.

This fixes a buffer over-read discovered by Forcepoint's security
researchers Otto Airamo & Antti Levomäki.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
6ec0c6fa63 CVE-2017-12902/Zephyr: Add an additional test.
File from Kamil Frankowicz.
2017-09-13 12:25:44 +01:00