Blame SOURCES/0011-krb5-respect-krb5_validate-for-PAC-checks.patch

42bc15
From 72132c413a2b19fbc21120ce51698978fd926360 Mon Sep 17 00:00:00 2001
42bc15
From: Sumit Bose <sbose@redhat.com>
42bc15
Date: Tue, 20 Sep 2022 15:37:01 +0200
42bc15
Subject: [PATCH] krb5: respect krb5_validate for PAC checks
42bc15
MIME-Version: 1.0
42bc15
Content-Type: text/plain; charset=UTF-8
42bc15
Content-Transfer-Encoding: 8bit
42bc15
42bc15
The first step of checking the PAC is the same as during the Kerberos
42bc15
ticket validation, requesting a service ticket for a service principal
42bc15
from the local keytab. By default ticket validation is enable for the
42bc15
IPA and AD provider where checking the PAC might become important. If
42bc15
ticket validation is disabled manually it is most probably because there
42bc15
are issues requesting the service ticket and fixing those is currently
42bc15
not possible.
42bc15
42bc15
Currently when SSSD is configured to check the PAC it ignores the
42bc15
krb5_validate setting and tries to request a service ticket which would
42bc15
fail in the case ticket validation is disabled for a reason. To not
42bc15
cause regressions with this patch SSSD will skip the PAC checks if
42bc15
ticket validation is disabled.
42bc15
42bc15
Resolves: https://github.com/SSSD/sssd/issues/6355
42bc15
42bc15
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
42bc15
Reviewed-by: Tomáš Halman <thalman@redhat.com>
42bc15
(cherry picked from commit f4dffaeaef16f146fc03970f62761fc335a3c7cc)
42bc15
---
42bc15
 src/man/include/krb5_options.xml      | 11 ++++++++++-
42bc15
 src/man/sssd.conf.5.xml               | 13 ++++++++++---
42bc15
 src/providers/krb5/krb5_child.c       |  9 ++++-----
42bc15
 src/providers/krb5/krb5_init_shared.c | 10 ++++++++++
42bc15
 4 files changed, 34 insertions(+), 9 deletions(-)
42bc15
42bc15
diff --git a/src/man/include/krb5_options.xml b/src/man/include/krb5_options.xml
42bc15
index c3292d1bb..d82be7bfa 100644
42bc15
--- a/src/man/include/krb5_options.xml
42bc15
+++ b/src/man/include/krb5_options.xml
42bc15
@@ -26,7 +26,16 @@
42bc15
                 keytab entry as the last entry or the only entry in the keytab file.
42bc15
             </para>
42bc15
             <para>
42bc15
-                Default: false
42bc15
+                Default: false (IPA and AD provider: true)
42bc15
+            </para>
42bc15
+            <para>
42bc15
+                Please note that the ticket validation is the first step when
42bc15
+		checking the PAC (see 'pac_check' in the
42bc15
+                <citerefentry>
42bc15
+                    <refentrytitle>sssd.conf</refentrytitle>
42bc15
+                    <manvolnum>5</manvolnum>
42bc15
+                </citerefentry> manual page for details). If ticket
42bc15
+                validation is disabled the PAC checks will be skipped as well.
42bc15
             </para>
42bc15
         </listitem>
42bc15
     </varlistentry>
42bc15
diff --git a/src/man/sssd.conf.5.xml b/src/man/sssd.conf.5.xml
42bc15
index 615b41550..7a9920815 100644
42bc15
--- a/src/man/sssd.conf.5.xml
42bc15
+++ b/src/man/sssd.conf.5.xml
42bc15
@@ -2238,9 +2238,16 @@ pam_gssapi_indicators_map = sudo:pkinit, sudo-i:pkinit
42bc15
                         <para>
42bc15
                             Apply additional checks on the PAC of the Kerberos
42bc15
                             ticket which is available in Active Directory and
42bc15
-                            FreeIPA domains, if configured. The following
42bc15
-                            options can be used alone or in a comma-separated
42bc15
-                            list:
42bc15
+                            FreeIPA domains, if configured. Please note that
42bc15
+			    Kerberos ticket validation must be enabled to be
42bc15
+                            able to check the PAC, i.e. the krb5_validate option
42bc15
+                            must be set to 'True' which is the default for the
42bc15
+                            IPA and AD provider. If krb5_validate is set to
42bc15
+                            'False' the PAC checks will be skipped.
42bc15
+			</para>
42bc15
+                        <para>
42bc15
+			    The following options can be used alone or in a
42bc15
+			    comma-separated list:
42bc15
                             <variablelist>
42bc15
                             <varlistentry>
42bc15
                                 <term>no_check</term>
42bc15
diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
42bc15
index 0a592da00..8727b4202 100644
42bc15
--- a/src/providers/krb5/krb5_child.c
42bc15
+++ b/src/providers/krb5/krb5_child.c
42bc15
@@ -3866,11 +3866,10 @@ int main(int argc, const char *argv[])
42bc15
         goto done;
42bc15
     }
42bc15
 
42bc15
-    /* To be able to read the PAC we have to request a service ticket where we
42bc15
-     * have a key to decrypt it, this is the same step we use for validating
42bc15
-     * the ticket. */
42bc15
-    if (cli_opts.check_pac_flags != 0) {
42bc15
-        kr->validate = true;
42bc15
+    if (cli_opts.check_pac_flags != 0 && !kr->validate) {
42bc15
+        DEBUG(SSSDBG_IMPORTANT_INFO,
42bc15
+              "PAC check is requested but krb5_validate is set to false. "
42bc15
+              "PAC checks will be skipped.\n");
42bc15
     }
42bc15
 
42bc15
     kerr = privileged_krb5_setup(kr, offline);
42bc15
diff --git a/src/providers/krb5/krb5_init_shared.c b/src/providers/krb5/krb5_init_shared.c
42bc15
index ee48f459b..3e6ebe2ed 100644
42bc15
--- a/src/providers/krb5/krb5_init_shared.c
42bc15
+++ b/src/providers/krb5/krb5_init_shared.c
42bc15
@@ -77,6 +77,16 @@ errno_t krb5_child_init(struct krb5_ctx *krb5_auth_ctx,
42bc15
         goto done;
42bc15
     }
42bc15
 
42bc15
+    if (krb5_auth_ctx->check_pac_flags != 0
42bc15
+            && !dp_opt_get_bool(krb5_auth_ctx->opts, KRB5_VALIDATE)) {
42bc15
+        DEBUG(SSSDBG_IMPORTANT_INFO,
42bc15
+              "PAC check is requested but krb5_validate is set to false. "
42bc15
+              "PAC checks will be skipped.\n");
42bc15
+        sss_log(SSS_LOG_WARNING,
42bc15
+                "PAC check is requested but krb5_validate is set to false. "
42bc15
+                "PAC checks will be skipped.");
42bc15
+    }
42bc15
+
42bc15
     ret = parse_krb5_map_user(krb5_auth_ctx,
42bc15
                               dp_opt_get_cstring(krb5_auth_ctx->opts,
42bc15
                                                  KRB5_MAP_USER),
42bc15
-- 
42bc15
2.37.3
42bc15