Skip to content

Commit

Permalink
(for 4.9.3) CVE-2018-14464/LMP: Add a missing bounds check
Browse files Browse the repository at this point in the history
In lmp_print_data_link_subobjs().

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).
  • Loading branch information
fxlb committed Aug 18, 2019
1 parent a152aeb commit d97e942
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
20 changes: 16 additions & 4 deletions print-lmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ lmp_print_data_link_subobjs(netdissect_options *ndo, const u_char *obj_tptr,
"Unknown",
EXTRACT_8BITS(obj_tptr + offset + 3)),
EXTRACT_8BITS(obj_tptr + offset + 3)));
ND_TCHECK_32BITS(obj_tptr + offset + 4);
bw.i = EXTRACT_32BITS(obj_tptr+offset+4);
ND_PRINT((ndo, "\n\t Min Reservable Bandwidth: %.3f Mbps",
bw.f*8/1000000));
Expand All @@ -419,6 +420,8 @@ lmp_print_data_link_subobjs(netdissect_options *ndo, const u_char *obj_tptr,
offset+=subobj_len;
}
return (hexdump);
trunc:
return -1;
}

void
Expand All @@ -429,7 +432,7 @@ lmp_print(netdissect_options *ndo,
const struct lmp_object_header *lmp_obj_header;
const u_char *tptr,*obj_tptr;
u_int tlen,lmp_obj_len,lmp_obj_ctype,obj_tlen;
int hexdump;
int hexdump, ret;
u_int offset;
u_int link_type;

Expand Down Expand Up @@ -731,7 +734,10 @@ lmp_print(netdissect_options *ndo,
ipaddr_string(ndo, obj_tptr+8),
EXTRACT_32BITS(obj_tptr+8)));

if (lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12))
ret = lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12);
if (ret == -1)
goto trunc;
if (ret == TRUE)
hexdump=TRUE;
break;

Expand All @@ -751,7 +757,10 @@ lmp_print(netdissect_options *ndo,
ip6addr_string(ndo, obj_tptr+20),
EXTRACT_32BITS(obj_tptr+20)));

if (lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 36, 36))
ret = lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 36, 36);
if (ret == -1)
goto trunc;
if (ret == TRUE)
hexdump=TRUE;
break;

Expand All @@ -771,7 +780,10 @@ lmp_print(netdissect_options *ndo,
EXTRACT_32BITS(obj_tptr+8),
EXTRACT_32BITS(obj_tptr+8)));

if (lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12))
ret = lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12);
if (ret == -1)
goto trunc;
if (ret == TRUE)
hexdump=TRUE;
break;

Expand Down
1 change: 1 addition & 0 deletions tests/TESTLIST
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ vrrp-vrrp_print-oobr vrrp-vrrp_print-oobr.pcap vrrp-vrrp_print-oobr.out -v -c3
vrrp-vrrp_print-oobr-2 vrrp-vrrp_print-oobr-2.pcap vrrp-vrrp_print-oobr-2.out -v
bgp-bgp_capabilities_print-oobr-1 bgp-bgp_capabilities_print-oobr-1.pcap bgp-bgp_capabilities_print-oobr-1.out -v -c1
bgp-bgp_capabilities_print-oobr-2 bgp-bgp_capabilities_print-oobr-2.pcap bgp-bgp_capabilities_print-oobr-2.out -v -c1
lmp-lmp_print_data_link_subobjs-oobr lmp-lmp_print_data_link_subobjs-oobr.pcap lmp-lmp_print_data_link_subobjs-oobr.out -v -c2
# The .pcap file is truncated after the 1st packet.
hncp_dhcpv6data-oobr hncp_dhcpv6data-oobr.pcap hncp_dhcpv6data-oobr.out -v -c1
hncp_dhcpv4data-oobr hncp_dhcpv4data-oobr.pcap hncp_dhcpv4data-oobr.out -v -c1
Expand Down
22 changes: 22 additions & 0 deletions tests/lmp-lmp_print_data_link_subobjs-oobr.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
IP (tos 0xfd,ECT(1), ttl 254, id 45839, offset 0, flags [+, DF, rsvd], proto UDP (17), length 56871, bad cksum fe07 (->ddf0)!)
17.8.8.255.701 > 40.184.42.8.12:
LMPv1, msg-type: unknown, type: 249, Flags: [none], length: 212
Data Link Object (12), Class-Type: Unnumbered (3) Flags: [non-negotiable], length: 20
Flags: [none]
Local Interface ID: 2435832538 (0x912fdada)
Remote Interface ID: 3657433088 (0xda000000)
Subobject, Type: Interface Switching Type (1), Length: 4
Switching Type: Unknown (0)
Encoding Type: Unknown (0)
packet exceeded snapshot
IP (tos 0xfd,ECT(1), ttl 254, id 45839, offset 0, flags [+, DF, rsvd], proto UDP (17), length 56871, bad cksum fe07 (->ddf0)!)
17.8.8.255.701 > 40.184.42.8.12:
LMPv1, msg-type: unknown, type: 249, Flags: [none], length: 212
Data Link Object (12), Class-Type: Unnumbered (3) Flags: [non-negotiable], length: 20
Flags: [none]
Local Interface ID: 2435832538 (0x912fdada)
Remote Interface ID: 3657433088 (0xda000000)
Subobject, Type: Interface Switching Type (1), Length: 4
Switching Type: Unknown (0)
Encoding Type: Unknown (0)
packet exceeded snapshot
Binary file added tests/lmp-lmp_print_data_link_subobjs-oobr.pcap
Binary file not shown.

0 comments on commit d97e942

Please sign in to comment.