deadsimple BSD Security Advisories and Announcements

FreeBSD Errata Notice FreeBSD-EN-22:19.pam_exec

Hash: SHA512

FreeBSD-EN-22:19.pam_exec                                       Errata Notice
                                                          The FreeBSD Project

Topic:          NULL pointer dereference in pam_exec(8)

Category:       core
Module:         pam
Announced:      2022-08-09
Affects:        FreeBSD 13.0 and later
Corrected:      2022-06-24 09:09:59 UTC (stable/13, 13.1-STABLE)
                2022-08-09 20:01:22 UTC (releng/13.1, 13.1-RELEASE-p1)
                2022-08-09 20:00:25 UTC (releng/13.0, 13.0-RELEASE-p12)

For general information regarding FreeBSD Errata Notices and Security
Advisories, including descriptions of the fields above, security
branches, and the following sections, please visit

I.   Background

pam_exec(8) is a pam(3) module for delegating PAM service functions to an
external program.  When used for authentication, it can pass the user's
authentication token to the external program.

II.  Problem Description

When pam_exec(8) is used for authentication with the `expose_authtok' option
and an application calls pam_setcred(3), it attempts to expose an already
stored authentication token.  It is incorrectly assumed that there always is
such a token stored, which leads to dereferencing a NULL pointer if this
isn't the case.

III. Impact

It is impossible to reliably use pam_exec(8) for authentication with the
`expose_authtok' option, that is necessary to have the external program check
credentials.  In most scenarios, authentication will fail because of a crash
caused by the NULL pointer dereference.

IV.  Workaround

No workaround is available, however systems not using pam_exec(8) for
authentication are not affected.

V.   Solution

Upgrade your 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 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 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
# fetch
# gpg --verify pam_exec.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:>.

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/                              ea80848e1c06    stable/13-n251487
releng/13.1/                            26db194f3db1  releng/13.1-n250151
releng/13.0/                            277c0c4d2512  releng/13.0-n244802
- -------------------------------------------------------------------------

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:


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

VII. References


The latest revision of this advisory is available at