]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Simplify preauth fallback disabling 1430/head
authorGreg Hudson <ghudson@mit.edu>
Mon, 12 May 2025 20:21:05 +0000 (16:21 -0400)
committerGreg Hudson <ghudson@mit.edu>
Fri, 13 Jun 2025 19:26:28 +0000 (15:26 -0400)
Remove the fallback_disabled field from krb5_init_creds_context, and
instead record the current preauth type as the only allowed preauth
type when a preauth module invokes the disable_fallback() method.

The previous method failed to prevent fallback when a KDC unexpectedly
responds with PREAUTH_REQUIRED partway through the preauth exchange.
Reported by Richard Silverman.

src/lib/krb5/krb/get_in_tkt.c
src/lib/krb5/krb/init_creds_ctx.h
src/lib/krb5/krb/preauth2.c

index 4b2be41e75d36b27ae0f13db0fa7d599c4faa5e1..00a5cceea5ac37f3e6ed060dc537ca9e537af87c 100644 (file)
@@ -1331,9 +1331,6 @@ init_creds_step_request(krb5_context context,
     /* Don't continue after a keyboard interrupt. */
     if (code == KRB5_LIBOS_PWDINTR)
         goto cleanup;
-    /* Don't continue if fallback is disabled. */
-    if (code && ctx->fallback_disabled)
-        goto cleanup;
     if (code) {
         /* See if we can try a different preauth mech before giving up. */
         k5_save_ctx_error(context, code, &save);
index 17d55dd7c4cea8a5e5b24d5c7ed370ddcedf9ee9..710b77810b28a910eaffe64b8138f72bfa979d9e 100644 (file)
@@ -63,9 +63,9 @@ struct _krb5_init_creds_context {
     krb5_enctype etype;
     krb5_boolean info_pa_permitted;
     krb5_boolean restarted;
-    krb5_boolean fallback_disabled;
     krb5_boolean encts_disabled;
     struct krb5_responder_context_st rctx;
+    krb5_preauthtype current_preauth_type;
     krb5_preauthtype selected_preauth_type;
     krb5_preauthtype allowed_preauth_type;
     k5_json_object cc_config_in;
index 32f35b76158a67fe715df6b71bcac8482cc35664..b5ef6c61650a385a97f4fb2630882832f720c579 100644 (file)
@@ -552,7 +552,9 @@ set_cc_config(krb5_context context, krb5_clpreauth_rock rock,
 static void
 disable_fallback(krb5_context context, krb5_clpreauth_rock rock)
 {
-    ((krb5_init_creds_context)rock)->fallback_disabled = TRUE;
+    krb5_init_creds_context ctx = (krb5_init_creds_context)rock;
+
+    ctx->allowed_preauth_type = ctx->current_preauth_type;
 }
 
 static struct krb5_clpreauth_callbacks_st callbacks = {
@@ -676,6 +678,7 @@ process_pa_data(krb5_context context, krb5_init_creds_context ctx,
             if (real && previously_failed(ctx, pa->pa_type))
                 continue;
             mod_pa = NULL;
+            ctx->current_preauth_type = pa->pa_type;
             ret = clpreauth_process(context, h, modreq, ctx->opt, &callbacks,
                                     (krb5_clpreauth_rock)ctx, ctx->request,
                                     ctx->inner_request_body,
@@ -908,6 +911,7 @@ k5_preauth_tryagain(krb5_context context, krb5_init_creds_context ctx,
     if (h == NULL)
         return KRB5KRB_ERR_GENERIC;
     mod_pa = NULL;
+    ctx->current_preauth_type = pa_type;
     ret = clpreauth_tryagain(context, h, modreq, ctx->opt, &callbacks,
                              (krb5_clpreauth_rock)ctx, ctx->request,
                              ctx->inner_request_body,
@@ -954,6 +958,7 @@ fill_response_items(krb5_context context, krb5_init_creds_context ctx,
         h = find_module(context, ctx, pa->pa_type, &modreq);
         if (h == NULL)
             continue;
+        ctx->current_preauth_type = pa->pa_type;
         ret = clpreauth_prep_questions(context, h, modreq, ctx->opt,
                                        &callbacks, (krb5_clpreauth_rock)ctx,
                                        ctx->request, ctx->inner_request_body,