krb5 commit: Prevent count overflow in LDAP key decoding

ghudson at mit.edu ghudson at mit.edu
Tue Nov 24 03:45:49 EST 2026


https://github.com/krb5/krb5/commit/534400f90221f3f5d1eb25520490aaa3a6d18eaf
commit 534400f90221f3f5d1eb25520490aaa3a6d18eaf
Author: Aysha Afrah Ziya <aysha26 at digiscrypt.com>
Date:   Sat Nov 21 18:12:39 2026 +0530

    Prevent count overflow in LDAP key decoding
    
    In decode_keys(), reject a total key count which would exceed
    INT16_MAX.  Each krbPrincipalKey value can decode to up to 32767 keys,
    so summing several values could wrap total_keys to a small positive
    number, causing krb5_decode_krbsecretkey() to allocate too small of a
    key_data array and overflow it when copying the keysets.
    
    ticket: 9296 (new)
    tags: pullup
    target_version: 1.22-next

 src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c
index cb588ed66..8217e9857 100644
--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c
+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c
@@ -1710,8 +1710,13 @@ decode_keys(struct berval **bvalues, ldap_seqof_key_data **keysets_out,
         if (err)
             goto cleanup;
 
-        if (total_keys_out)
+        if (total_keys_out) {
+            if (keysets[ki].n_key_data > INT16_MAX - total_keys) {
+                err = EOVERFLOW;
+                goto cleanup;
+            }
             total_keys += keysets[ki].n_key_data;
+        }
         ki++;
     }
 


More information about the cvs-krb5 mailing list