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

=============================================================================
FreeBSD-SA-23:16.cap_net                                    Security Advisory
                                                          The FreeBSD Project

Topic:          Incorrect libcap_net limitation list manipulation

Category:       core
Module:         libcap_net
Announced:      2023-11-08
Credits:        Shawn Webb, Mariusz Zaborski 
Affects:        FreeBSD 13.2 and later
Corrected:      2023-11-06 19:19:04 UTC (stable/14, 14.0-STABLE)
                2023-11-08 00:45:34 UTC (releng/14.0, 14.0-RC4-p1)
                2023-11-06 19:19:54 UTC (stable/13, 13.2-STABLE)
                2023-11-08 00:49:31 UTC (releng/13.2, 13.2-RELEASE-p5)
CVE Name:       CVE-2023-5978

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

libcasper(3) allows Capsicum-sandboxed applications to define and use system
interfaces which would otherwise be disallowed, through implementing special
services.  One of these services, libcap_net, enables networking capabilities
within the restriced environment.

II.  Problem Description

Casper services allow limiting operations that a process can perform.  Each
service maintains a specific list of permitted operations.  Certain operations
can be further restricted, such as specifying which domain names can be
resolved.  During the verification of limits, the service must ensure that the
new set of constraints is a subset of the previous one.  In the case of the
cap_net service, the currently limited set of domain names was fetched
incorrectly.

III. Impact

In certain scenarios, if only a list of resolvable domain names was specified
without setting any other limitations, the application could submit a new list
of domains including include entries not previously in the list.

IV.  Workaround

No workaround is available.  Note that no FreeBSD base system software is
vulnerable to this issue.

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
# 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-23:16/cap_net.patch
# fetch https://security.FreeBSD.org/patches/SA-23:16/cap_net.patch.asc
# gpg --verify cap_net.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 library, 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/14/                              765757c6301f    stable/14-n265696
releng/14.0/                            5f4fc91cc87c  releng/14.0-n265377
stable/13/                              114c6d9bef76    stable/13-n256672
releng/13.2/                            acd860c3622d  releng/13.2-n254640
- -------------------------------------------------------------------------

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://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-5978>

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

iQIzBAEBCgAdFiEEthUnfoEIffdcgYM7bljekB8AGu8FAmVLKaYACgkQbljekB8A
Gu8Ofg/6AxzPey7hIS6rRO5Mv5ufiKEiYDwPo3t6epUiaLid21KhkLry1CofqFHd
pC0zsYDJiWCkvieGBHhCkNYmffL9TCgLqNxSSH7plwMHwrLLQKxYRVn9V0ReGdc9
qRY5XB1W0Ocns0CbpEXuMRNde5UNwc63xN0/xlnBESfex6+fP9kPNB7VLoYY4Foj
jDzn6s8YNaUOVO7YtlZDjPRRazwVLriQ3Bf+lCNkJFq4VyyhRPFkeknOFHt5olA2
dp+DIVQGUVRGjeaZDlxLZ4j0Nw39ZK8T6mSXSskjtSfQtHd6DPgDFBzZKjhtzRFd
+5lutnrXpZemQjUcOKqVG1ZmlbDQChIWVlJ1kyORRjb8ZO+vknhFo/w3a5o4sq1A
ZtK1w2CFo0+jL+oWxJdFEiRFR0jwMtVfMCzZAoLsDXnYbmni/353BKGMlBFgdsAy
Php3E/LsxCoFaZ+r87Z6O2UefEYMCr1FDM99SQkU1Ui3kzWEskHEvPR6JS31Htu2
9ry3c4T08r1Qhp7J9Zdfnwvtd0fyEWn16ewzeiV4M6+gPErWZncar+86b87IRKof
bTJ4XiK7kcORyD5ksgcBINUd5njOvXGIYTfkqSmlyikAhnoM7MN3npUGyRq6KQTE
NPAr3gWrch7pegBVP3JuDQaYwfJarg6BmPb9sWWfkzQHRf9pfOI=
=XNt1
-----END PGP SIGNATURE-----