aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2015-09-25 12:51:47 -0400
committerTom Yu <tlyu@mit.edu>2015-12-09 17:30:39 -0500
commit073fbe18f102cb135ba5d3f9e6b7d84d20c125f2 (patch)
tree2b80b8d793abe3124f07a4024742c3298e16d768
parent4875478cbc2c47fdcfbabb4813dfe2b971fb9ae2 (diff)
downloadkrb5-073fbe18f102cb135ba5d3f9e6b7d84d20c125f2.zip
krb5-073fbe18f102cb135ba5d3f9e6b7d84d20c125f2.tar.gz
krb5-073fbe18f102cb135ba5d3f9e6b7d84d20c125f2.tar.bz2
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 (cherry picked from commit f0c094a1b745d91ef2f9a4eae2149aac026a5789) ticket: 8315 (new) version_fixed: 1.12.5 status: resolved
-rw-r--r--src/lib/krb5/krb/bld_princ.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/lib/krb5/krb/bld_princ.c b/src/lib/krb5/krb/bld_princ.c
index 3dbe356..442cbf5 100644
--- a/src/lib/krb5/krb/bld_princ.c
+++ b/src/lib/krb5/krb/bld_princ.c
@@ -41,10 +41,8 @@ build_principal_va(krb5_context context, krb5_principal princ,
data = malloc(size * sizeof(krb5_data));
if (!data) { retval = ENOMEM; }
- if (!retval) {
- r = strdup(realm);
- if (!r) { retval = ENOMEM; }
- }
+ if (!retval)
+ r = k5memdup0(realm, rlen, &retval);
while (!retval && (component = va_arg(ap, char *))) {
if (count == size) {