Skip to content

Provide AUTHID to GSS to select correct principal#871

Open
michael-dev wants to merge 1 commit intocyrusimap:masterfrom
michael-dev:bugfix/gssapi-select-principal
Open

Provide AUTHID to GSS to select correct principal#871
michael-dev wants to merge 1 commit intocyrusimap:masterfrom
michael-dev:bugfix/gssapi-select-principal

Conversation

@michael-dev
Copy link

@michael-dev michael-dev commented Mar 2, 2025

When using postfix smtp client with KRB5_CLIENT_KTNAME for relayhost authentication, the first entry in the client keytab is always used. For /etc/krb5.keytab, this might be a service principal of the host instead of the user principal, so gss_init_sec_context then fails - AS-REQ fails for service principals, only works for user principals.

Fix this by using the authid supplied by postfix to provide a desired name to gss_acquire_cred (if present).

Postfix config:
smtp_sasl_auth_enable = yes
smtp_sasl_mechanism_filter = gssapi
smtp_sasl_password_maps = static:HOSTNAME$$@EXAMPLE.ORG:irrelevant
import_environment = ... KRB5_CLIENT_KTNAME=/etc/krb5.keytab KRB5CCNAME=MEMORY:

@hyc
Copy link
Contributor

hyc commented Mar 2, 2025

Why are the client and server sharing a single keytab file? That's inherently insecure, since it allows arbitrary entities to authenticate as either of them.

When using postfix smtp client with KRB5_CLIENT_KTNAME for relayhost
authentication, the first entry in the client keytab is always used.
For /etc/krb5.keytab, this might be a service principal of the host
instead of the user principal, so gss_init_sec_context then fails -
AS-REQ fails for service principals, only works for user principals.

Fix this by using the authid supplied by postfix to provide a
desired name to gss_acquire_cred (if present).

Postfix config:
  smtp_sasl_auth_enable = yes
  smtp_sasl_mechanism_filter = gssapi
  smtp_sasl_password_maps = static:HOSTNAME$$@EXAMPLE.ORG:irrelevant
  import_environment = ... KRB5_CLIENT_KTNAME=/etc/krb5.keytab \
                           KRB5CCNAME=MEMORY:

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
@michael-dev michael-dev force-pushed the bugfix/gssapi-select-principal branch from 2515cf9 to 8ce5827 Compare March 2, 2025 14:27
@michael-dev
Copy link
Author

No, client and server do not share a keytab. On the client, I have /etc/krb5.keytab which contains the machine account. So I want to use the machine account of the client to authenticate to the server (for system mails, e.g.from CRON).
Similiarly, I want to be able to use a gMSA account to authenticate to the mail gateway (for application e-Mail). The current key of the gMSA account would automatically be provided using a keytab file.

@Neustradamus
Copy link
Contributor

@hyc, @quanah: Have you progressed on this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants