deadsimple BSD Security Advisories and Announcements

FreeBSD Security Advisory FreeBSD-SA-23:13.capsicum

Hash: SHA512

FreeBSD-SA-23:13.capsicum                                   Security Advisory
                                                          The FreeBSD Project

Topic:          copy_file_range insufficient capability rights check

Category:       core
Module:         capsicum
Announced:      2023-10-03
Credits:	David Chisnall
Affects:        FreeBSD 13.2
Corrected:      2023-10-02 16:00:27 UTC (stable/13, 13.2-STABLE)
                2023-10-03 21:24:41 UTC (releng/13.2, 13.2-RELEASE-p4)
CVE Name:       CVE-2023-5369

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

I.   Background

Capsicum is a lightweight OS capability and sandbox framework.  It provides
two kernel primatives, capability mode and capabilities.  Capabilities limit
operations that can be performed on file descriptors.

copy_file_range is a system call that performs a kernel copy of a byte range
from one file to another or within one file.  copy_file_range accepts
optional pointers to offsets for the input and output file descriptors.

II.  Problem Description

The syscall checked only for the CAP_READ and CAP_WRITE capabilities on the
input and output file descriptors, respectively.  Using an offset is
logically equivalent to seeking, and the syscall must additionally require
the CAP_SEEK capability.

III. Impact

A sandboxed process with only read or write but no seek capability on a file
descriptor may be able to read data from or write data to an arbitrary
location within the file corresponding to that file descriptor.

IV.  Workaround

No workaround is available.

V.   Solution

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

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
# fetch
# gpg --verify capsicum.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:> and reboot the

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/                              3f0ce63828dc    stable/13-n256458
releng/13.2/                            2d23f6c33431  releng/13.2-n254636
- -------------------------------------------------------------------------

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