Browse files

Fix LDAP key data segmentation [CVE-2014-4345]

For principal entries having keys with multiple kvnos (due to use of
-keepold), the LDAP KDB module makes an attempt to store all the keys
having the same kvno into a single krbPrincipalKey attribute value.
There is a fencepost error in the loop, causing currkvno to be set to
the just-processed value instead of the next kvno.  As a result, the
second and all following groups of multiple keys by kvno are each
stored in two krbPrincipalKey attribute values.  Fix the loop to use
the correct kvno value.


In MIT krb5, when kadmind is configured to use LDAP for the KDC
database, an authenticated remote attacker can cause it to perform an
out-of-bounds write (buffer overrun) by performing multiple cpw
-keepold operations.  An off-by-one error while copying key
information to the new database entry results in keys sharing a common
kvno being written to different array buckets, in an array whose size
is determined by the number of kvnos present.  After sufficient
iterations, the extra writes extend past the end of the
(NULL-terminated) array.  The NULL terminator is always written after
the end of the loop, so no out-of-bounds data is read, it is only

Historically, it has been possible to convert an out-of-bounds write
into remote code execution in some cases, though the necessary
exploits must be tailored to the individual application and are
usually quite complicated.  Depending on the allocated length of the
array, an out-of-bounds write may also cause a segmentation fault
and/or application crash.

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

[ clarified commit message]
[ CVE summary, CVSSv2 vector]

(cherry picked from commit 81c332e)

ticket: 7980
version_fixed: 1.12.2
status: resolved
  • Loading branch information...
1 parent df78452 commit dc7ed55c689d57de7f7408b34631bf06fec9dab1 @tkuthan tkuthan committed with tlyu Aug 1, 2014
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c
3 src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c
@@ -463,7 +463,8 @@ krb5_encode_krbsecretkey(krb5_key_data *key_data_in, int n_key_data,
last = i + 1;
- currkvno = key_data[i].key_data_kvno;
+ if (i < n_key_data - 1)
+ currkvno = key_data[i + 1].key_data_kvno;
ret[num_versions] = NULL;

0 comments on commit dc7ed55

Please sign in to comment.