Package: krb5 / 1.10.1+dfsg-5+deb7u7

upstream/0036-Fix-build_principal-memory-bug-CVE-2015-2697.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 9cd283c2be3969b50bfde47a2bd2a74e7435e228 Mon Sep 17 00:00:00 2001
From: Greg Hudson <ghudson@mit.edu>
Date: Fri, 25 Sep 2015 12:51:47 -0400
Subject: Fix build_principal memory bug [CVE-2015-2697]

In build_principal_va(), use k5memdup0() instead of strdup() to make a
copy of the realm, to ensure that we allocate the correct number of
bytes and do not read past the end of the input string.  This bug
affects krb5_build_principal(), krb5_build_principal_va(), and
krb5_build_principal_alloc_va().  krb5_build_principal_ext() is not
affected.

CVE-2015-2697:

In MIT krb5 1.7 and later, an authenticated attacker may be able to
cause a KDC to crash using a TGS request with a large realm field
beginning with a null byte.  If the KDC attempts to find a referral to
answer the request, it constructs a principal name for lookup using
krb5_build_principal() with the requested realm.  Due to a bug in this
function, the null byte causes only one byte be allocated for the
realm field of the constructed principal, far less than its length.
Subsequent operations on the lookup principal may cause a read beyond
the end of the mapped memory region, causing the KDC process to crash.

CVSSv2: AV:N/AC:L/Au:S/C:N/I:N/A:C/E:POC/RL:OF/RC:C

ticket: 8252 (new)
target_version: 1.14
tags: pullup

(cherry picked from commit f0c094a1b745d91ef2f9a4eae2149aac026a5789)
k5memdup0() is not available on the 1.10 branch, so inline the
implementation manually at the one call site.  k5alloc() always
returns zeroed memory via calloc().

Patch-Category: upstream
---
 src/lib/krb5/krb/bld_princ.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/src/lib/krb5/krb/bld_princ.c
+++ b/src/lib/krb5/krb/bld_princ.c
@@ -48,8 +48,9 @@ krb5int_build_principal_va(krb5_context
     if (!data) { retval = ENOMEM; }
 
     if (!retval) {
-        r = strdup(realm);
-        if (!r) { retval = ENOMEM; }
+        r = k5alloc(rlen + 1, &retval);
+        if (r != NULL && rlen > 0)
+            memcpy(r, realm, rlen);
     }
 
     if (!retval && first) {