Home / mailingsPDF  

FreeBSD Security Advisory FreeBSD-SA-23:15.stdio

Posted on 08 November 2023
FreeBSD security notificat

=============================================================================FreeBSD-SA-23:15.libc Security Advisory
The FreeBSD Project

Topic: libc stdio buffer overflow

Category: core
Module: libc
Announced: 2023-11-07
Credits: inooo
All supported versions of FreeBSD.
Corrected: 2023-11-07 17:29:20 UTC (stable/14, 14.0-STABLE)
2023-11-08 00:45:25 UTC (releng/14.0, 14.0-RC4-p1)
2023-11-07 18:41:49 UTC (stable/13, 13.2-STABLE)
2023-11-08 00:48:03 UTC (releng/13.2, 13.2-RELEASE-p5)
2023-11-08 14:30:51 UTC (stable/12, 12.4-STABLE)
2023-11-08 01:09:31 UTC (releng/12.4, 12.4-RELEASE-p7)
CVE Name: CVE-2023-5941

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 FreeBSD C library (libc) Standard I/O (stdio) component provides
essential functionality for input and output operations including file
handling and buffering. It includes functions like "fopen", "printf", and
"fflush". Streams may be unbuffered, line buffered, or fully buffered.
The library writes buffered data when the buffer is full or when the
application explicitly requests so by calling the fflush(3) function.

II. Problem Description

For line-buffered streams the __sflush() function did not correctly update
the FILE object's write space member when the write(2) system call returns
an error.

III. Impact

Depending on the nature of an application that calls libc's stdio functions
and the presence of errors returned from the write(2) system call (or an
overridden stdio write routine) a heap buffer overfly may occur. Such
overflows may lead to data corruption or the execution of arbitrary code at
the privilege level of the calling program.

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.

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.

[FreeBSD 14.0]
# fetch https://security.FreeBSD.org/patches/SA-23:15/stdio.14.patch
# fetch https://security.FreeBSD.org/patches/SA-23:15/stdio.14.patch.asc
# gpg --verify stdio.14.patch.asc

[FreeBSD 13.2]
# fetch https://security.FreeBSD.org/patches/SA-23:15/stdio.13.patch
# fetch https://security.FreeBSD.org/patches/SA-23:15/stdio.13.patch.asc
# gpg --verify stdio.13.patch.asc

[FreeBSD 12.4]
# fetch https://security.FreeBSD.org/patches/SA-23:15/stdio.12.patch
# fetch https://security.FreeBSD.org/patches/SA-23:15/stdio.12.patch.asc
# gpg --verify stdio.12.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/ abe12d2f4ce3 stable/14-n265706
releng/14.0/ 1f9c4610dde5 releng/14.0-n265376
stable/13/ 59ec3ffdd7ce stable/13-n256680
releng/13.2/ d51a39b13ee4 releng/13.2-n254639
stable/12/ r373263
releng/12.4/ r373265
- -------------------------------------------------------------------------

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-5941>

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

 

TOP