-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

=============================================================================
FreeBSD-SA-24:06.ktrace                                     Security Advisory
                                                          The FreeBSD Project

Topic:          ktrace(2) fails to detach when executing a setuid binary

Category:       core
Module:         ktrace
Announced:      2024-08-07
Affects:        All supported versions of FreeBSD
Corrected:      2024-08-07 13:41:53 UTC (stable/14, 14.1-STABLE)
                2024-08-07 13:44:29 UTC (releng/14.1, 14.1-RELEASE-p3)
                2024-08-07 13:44:47 UTC (releng/14.0, 14.0-RELEASE-p9)
                2024-08-07 13:42:10 UTC (stable/13, 13.3-STABLE)
                2024-08-07 13:44:59 UTC (releng/13.3, 13.3-RELEASE-p5)
CVE Name:       CVE-2024-6760

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

The ktrace utility enables kernel trace logging for the specified processes,
commonly used for diagnostic or debugging purposes.  The kernel operations
that are traced include system calls, namei translations, signal processing,
and I/O as well as data associated with these operations.

II.  Problem Description

A logic bug in the code which disables kernel tracing for setuid programs
meant that tracing was not disabled when it should have, allowing
unprivileged users to trace and inspect the behavior of setuid programs.

III. Impact

The bug may be used by an unprivileged user to read the contents of files to
which they would not otherwise have access, such as the local password
database.

IV.  Workaround

No workaround is available.

I/O tracing can be disabled by setting the kern.ktrace.genio_size sysctl to
0, but other information recorded by ktrace, such as system call arguments,
can still be leaked.

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 or arm64 platforms,
or the i386 platform on FreeBSD 13, can be updated via the freebsd-update(8)
utility:

# freebsd-update fetch
# freebsd-update install
# shutdown -r +10min "Rebooting for a security update"

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-24:06/ktrace.patch
# fetch https://security.FreeBSD.org/patches/SA-24:06/ktrace.patch.asc
# gpg --verify ktrace.patch.asc

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

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

c) Recompile your kernel as described in
<URL:https://www.FreeBSD.org/handbook/kernelconfig.html> and reboot the
system.

VI.  Correction details

This issue is corrected as of the corresponding Git commit hash in the
following stable and release branches:

Branch/path                             Hash                     Revision
- -------------------------------------------------------------------------
stable/14/                              8b400c8488f0    stable/14-n268423
releng/14.1/                            22d04990cee5  releng/14.1-n267693
releng/14.0/                            c39fb98e4740  releng/14.0-n265429
stable/13/                              f702110bc4bc    stable/13-n258224
releng/13.3/                            769536bcb5c3  releng/13.3-n257445
- -------------------------------------------------------------------------

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

VII. References

<URL:https://www.cve.org/CVERecord?id=CVE-2024-6760>

The latest revision of this advisory is available at
<URL:https://security.FreeBSD.org/advisories/FreeBSD-SA-24:06.ktrace.asc>
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEthUnfoEIffdcgYM7bljekB8AGu8FAmazha0ACgkQbljekB8A
Gu/6ThAAvKUJFwdRV/rSRyGEOTWJE+dv1Qig000xhD6g42yKpfGShaNFUTSvMPG+
kLtpN41SRN/LXyNyQfk3GL2SmphB2V9nlJ+FM2PEmi4hMrWoiNi6uX9MmSheFbp3
QbDAh5+2sRo66AUXjUX118cK1ruqQjRRMVSW6D8hOeDv64Wvg01L0R3ls1ZsdXYL
5wYuTRNh2ciyMEHQ0QUz8X38qebdPSV/8aVNSZYinwtYE+wGWbpmUCQoqgtLlnT9
3UqIy68KVj4+TNYoZuQkK5/Ur9YG884YlNpzsJ6peX8U0gjQhG1BfqEPAylTZn/6
vPp0LtJ0fRRZs0a6XJQ+rBxhuh22vLLFLXI9jSthCcNdJhRFFnnY9nFoB0/EOpIH
I6i94dEExCeGkWcpPB2wyrQGPcRTik9h57vsTaHcnEAPWu1fO2OckUILZVsMs7Yp
WXePdrVfTke1hIzk5DAc5PYJ1IKcN49m/+GhXjLz8aCcy9RadJPpJDe2HSltgfTn
xvxAudY+58f6518getIfvU4tAA1DVw2Y9zRoRhdlXLiVDayBkCOFRMMBY1cWOk9o
aUnbQ9PYO2h7iyzSvqgWDLIy7fIdLZnyuflSVtJ4KUnetk2hU5kxb0VZFx10+z7l
dsTyXGdb04olDMvURtgn5eQotbJzn+KLqi3vOmQ92uAGSsLeH70=
=3iOc
-----END PGP SIGNATURE-----