]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Improve safety of KDC AS-REQ processing cleanup 1472/head
authorGreg Hudson <ghudson@mit.edu>
Thu, 11 Dec 2025 07:43:59 +0000 (02:43 -0500)
committerGreg Hudson <ghudson@mit.edu>
Tue, 20 Jan 2026 21:47:07 +0000 (16:47 -0500)
In finish_process_as_req(), don't clean up
state->reply.enc_part.ciphertext until the end of the function.
Otherwise a dangling pointer appears in the structure while it is used
several times, including potentially by audit plugin modules.

Omit the memset() to 0 for this and
state->ticket_reply.enc_part.ciphertext, as ciphertexts are not
secrets.

src/kdc/do_as_req.c

index 5d588e5be710a2e3b568fff1f021c94492572151..4dbb6ae67b4d0dedc407eb06c3a1cdfcc4e46955 100644 (file)
@@ -331,12 +331,6 @@ finish_process_as_req(struct as_req_state *state, krb5_error_code errcode)
     if (errcode)
         goto egress;
 
-    /* these parts are left on as a courtesy from krb5_encode_kdc_rep so we
-       can use them in raw form if needed.  But, we don't... */
-    memset(state->reply.enc_part.ciphertext.data, 0,
-           state->reply.enc_part.ciphertext.length);
-    free(state->reply.enc_part.ciphertext.data);
-
     log_as_req(context, state->local_addr, state->remote_addr,
                state->request, &state->reply, state->client, state->cname,
                state->server, state->sname, state->kdc_time, 0, 0, 0);
@@ -405,12 +399,8 @@ egress:
     krb5_db_free_principal(context, state->local_tgt_storage);
     if (state->session_key.contents != NULL)
         krb5_free_keyblock_contents(context, &state->session_key);
-    if (state->ticket_reply.enc_part.ciphertext.data != NULL) {
-        memset(state->ticket_reply.enc_part.ciphertext.data , 0,
-               state->ticket_reply.enc_part.ciphertext.length);
-        free(state->ticket_reply.enc_part.ciphertext.data);
-    }
-
+    free(state->ticket_reply.enc_part.ciphertext.data);
+    free(state->reply.enc_part.ciphertext.data);
     krb5_free_pa_data(context, state->e_data);
     krb5_free_data(context, state->inner_body);
     kdc_free_rstate(state->rstate);