Home / mailingsPDF  

FreeBSD Security Advisory FreeBSD-SA-23:04.pam_krb5

Posted on 21 June 2023
FreeBSD security notificat

=============================================================================FreeBSD-SA-23:04.pam_krb5 Security Advisory
The FreeBSD Project

Topic: Network authentication attack via pam_krb5

Category: core
Module: pam_krb5
Announced: 2023-06-21
Credits: Taylor R Campbell <riastradh@NetBSD.org>
Affects: All supported versions of FreeBSD
Corrected: 2023-06-21 05:25:18 UTC (stable/13, 13.2-STABLE)
2023-06-21 05:27:12 UTC (releng/13.2, 13.2-RELEASE-p1)
2023-06-21 05:27:22 UTC (releng/13.1, 13.1-RELEASE-p8)
2023-06-21 05:27:27 UTC (stable/12, 12.4-STABLE)
2023-06-21 05:43:39 UTC (releng/12.4, 12.4-RELEASE-p3)
CVE Name: CVE-2023-3326

For general information regarding FreeBSD Security Advisories,
including descriptions of the fields above, security branches, and the
following sections, please visit <URL:https://security.FreeBSD.org/>.

I. Background

Kerberos 5 (krb5) is a computer-network authentication protocol that works on
the basis of tickets to allow nodes communicating over a non-secure network
to prove their identity to one another in a secure manner.

The PAM (Pluggable Authentication Modules) library provides a flexible
framework for user authentication and session setup / teardown.

pam_krb5 is a PAM module that allows using a Kerberos password to
authenticate the user. pam_krb5 is disabled in the default FreeBSD
installation.

pam_krb5 uses passwords for authentication, which is distinct from
Kerberos native protocols like GSSAPI, which allows for login without the
exchange of passwords. GSSAPI is not affected by this issue.

II. Problem Description

pam_krb5 authenticates the user by essentially running kinit(1) with the
password, getting a `ticket-granting ticket' (tgt) from the Kerberos KDC (Key
Distribution Center) over the network, as a way to verify the password.

Normally, the system running the pam_krb5 module will also have a keytab, a
key provisioned by the KDC. The pam_krb5 module will use the tgt to get a
service ticket and validate it against the keytab, ensuring the tgt is valid
and therefore, the password is valid.

However, if a keytab is not provisioned on the system, pam_krb5 has no way to
validate the response from the KDC, and essentially trusts the tgt provided
over the network as being valid.

III. Impact

In a non-default FreeBSD installation that leverages pam_krb5 for
authentication and does not have a keytab provisioned, an attacker that is
able to control both the password and the KDC responses can return a valid
tgt, allowing authentication to occur for any user on the system.

IV. Workaround

If you are not using Kerberos at all, ensure /etc/krb5.conf is missing from
your system. Additionally, ensure pam_krb5 is commented out of your PAM
configuration located as documented in pam.conf(5), generally /etc/pam.d.
Note, the default FreeBSD PAM configuration has pam_krb5 commented out.

If you are using Kerberos, but not using pam_krb5, ensure pam_krb5 is
commented out of your PAM configuration located as documented in pam.conf(5),
generally /etc/pam.d. Note, the default FreeBSD PAM configuration has
pam_krb5 commented out.

If you are using pam_krb5, ensure you have a keytab on your system as
provided by your Kerberos administrator.

V. Solution

Upgrade your vulnerable system to a supported FreeBSD stable or
release / security branch (releng) dated after the correction date.

Perform one of the following:

1) To update your vulnerable system via a binary patch:

Systems running a RELEASE version of FreeBSD on the amd64, i386, or
(on FreeBSD 13 and later) arm64 platforms can be updated via the
freebsd-update(8) utility:

# freebsd-update fetch
# freebsd-update install

2) To update your vulnerable system via a source code patch:

The following patches have been verified to apply to the applicable
FreeBSD release branches.

a) Download the relevant patch from the location below, and verify the
detached PGP signature using your PGP utility.

# fetch https://security.FreeBSD.org/patches/SA-23:04/pam_krb5.patch
# fetch https://security.FreeBSD.org/patches/SA-23:04/pam_krb5.patch.asc
# gpg --verify pam_krb5.patch.asc

b) Apply the patch. Execute the following commands as root:

# cd /usr/src
# patch < /path/to/patch

c) Recompile the operating system using buildworld and installworld as
described in <URL:https://www.FreeBSD.org/handbook/makeworld.html>.

Restart all daemons that use the PAM module, or reboot the system.

VI. Correction details

This issue is corrected by the corresponding Git commit hash or Subversion
revision number in the following stable and release branches:

Branch/path Hash Revision
- -------------------------------------------------------------------------
stable/13/ 6322a6c9daaa stable/13-n255613
releng/13.2/ 58d21e3e8e56 releng/13.2-n254620
releng/13.1/ 07e3f54f2ea1 releng/13.1-n250186
stable/12/ r373100
releng/12.4/ r373103
- -------------------------------------------------------------------------

For FreeBSD 13 and later:

Run the following command to see which files were modified by a
particular commit:

# git show --stat <commit hash>

Or visit the following URL, replacing NNNNNN with the hash:

<URL:https://cgit.freebsd.org/src/commit/?id=NNNNNN>

To determine the commit count in a working tree (for comparison against
nNNNNNN in the table above), run:

# git rev-list --count --first-parent HEAD

For FreeBSD 12 and earlier:

Run the following command to see which files were modified by a particular
revision, replacing NNNNNN with the revision number:

# svn diff -cNNNNNN --summarize svn://svn.freebsd.org/base

Or visit the following URL, replacing NNNNNN with the revision number:

<URL:https://svnweb.freebsd.org/base?view=revision&revision=NNNNNN>

VII. References

<URL:https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-3326>

The latest revision of this advisory is available at
<URL:https://security.FreeBSD.org/advisories/FreeBSD-SA-23:04.pam_krb5.asc>

 

TOP