Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netipsec Fix a vulnerability in IPsec-IPv6-AH, that allo...



details:   https://anonhg.NetBSD.org/src/rev/f70b99ac437d
branches:  trunk
changeset: 829275:f70b99ac437d
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Jan 24 13:30:47 2018 +0000

description:
Fix a vulnerability in IPsec-IPv6-AH, that allows an attacker to remotely
crash the kernel with a single packet.

In this loop we need to increment 'ad' by two, because the length field
of the option header does not count the size of the option header itself.

If the length is zero, then 'count' is incremented by zero, and there's
an infinite loop. Beyond that, this code was written with the assumption
that since the IPv6 packet already went through the generic IPv6 option
parser, several fields are guaranteed to be valid; but this assumption
does not hold because of the missing '+2', and there's as a result a
triggerable buffer overflow (write zeros after the end of the mbuf,
potentially to the next mbuf in memory since it's a pool).

Add the missing '+2', this place will be reinforced in separate commits.

diffstat:

 sys/netipsec/xform_ah.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (33 lines):

diff -r 5d3e4d002eee -r f70b99ac437d sys/netipsec/xform_ah.c
--- a/sys/netipsec/xform_ah.c   Wed Jan 24 13:13:11 2018 +0000
+++ b/sys/netipsec/xform_ah.c   Wed Jan 24 13:30:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xform_ah.c,v 1.75 2018/01/24 13:13:11 maxv Exp $       */
+/*     $NetBSD: xform_ah.c,v 1.76 2018/01/24 13:30:47 maxv Exp $       */
 /*     $FreeBSD: src/sys/netipsec/xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $   */
 /*     $OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.75 2018/01/24 13:13:11 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.76 2018/01/24 13:30:47 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -523,12 +523,12 @@
                                                return EINVAL;
                                        }
 
-                                       ad = ptr[count + 1];
+                                       ad = ptr[count + 1] + 2;
 
                                        /* If mutable option, zeroize. */
                                        if (ptr[count] & IP6OPT_MUTABLE)
                                                memcpy(ptr + count, ipseczeroes,
-                                                   ptr[count + 1]);
+                                                   ad);
 
                                        count += ad;
 



Home | Main Index | Thread Index | Old Index