Skip to content

Commit

Permalink
Ensure array count consistency in kadm5 RPC
Browse files Browse the repository at this point in the history
In _xdr_kadm5_principal_ent_rec(), ensure that n_key_data matches the
key_data array count when decoding.  Otherwise when the structure is
later freed, xdr_array() could iterate over the wrong number of
elements, either leaking some memory or freeing uninitialized
pointers.  Reported by Robert Morris.

CVE-2023-36054:

An authenticated attacker can cause a kadmind process to crash by
freeing uninitialized pointers.  Remote code execution is unlikely.
An attacker with control of a kadmin server can cause a kadmin client
to crash by freeing uninitialized pointers.

(cherry picked from commit ef08b09)

ticket: 9099
version_fixed: 1.20.2
  • Loading branch information
greghudson committed Jul 6, 2023
1 parent 5c2f26a commit c81ffb6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/lib/kadm5/kadm_rpc_xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ _xdr_kadm5_principal_ent_rec(XDR *xdrs, kadm5_principal_ent_rec *objp,
int v)
{
unsigned int n;
bool_t r;

if (!xdr_krb5_principal(xdrs, &objp->principal)) {
return (FALSE);
Expand Down Expand Up @@ -443,6 +444,9 @@ _xdr_kadm5_principal_ent_rec(XDR *xdrs, kadm5_principal_ent_rec *objp,
if (!xdr_krb5_int16(xdrs, &objp->n_key_data)) {
return (FALSE);
}
if (xdrs->x_op == XDR_DECODE && objp->n_key_data < 0) {
return (FALSE);
}
if (!xdr_krb5_int16(xdrs, &objp->n_tl_data)) {
return (FALSE);
}
Expand All @@ -451,9 +455,10 @@ _xdr_kadm5_principal_ent_rec(XDR *xdrs, kadm5_principal_ent_rec *objp,
return FALSE;
}
n = objp->n_key_data;
if (!xdr_array(xdrs, (caddr_t *) &objp->key_data,
&n, ~0, sizeof(krb5_key_data),
xdr_krb5_key_data_nocontents)) {
r = xdr_array(xdrs, (caddr_t *) &objp->key_data, &n, objp->n_key_data,
sizeof(krb5_key_data), xdr_krb5_key_data_nocontents);
objp->n_key_data = n;
if (!r) {
return (FALSE);
}

Expand Down

0 comments on commit c81ffb6

Please sign in to comment.