FreeBSD Security Advisory FreeBSD-SA-21:15.libfetch

—–BEGIN PGP SIGNED MESSAGE—– Hash: SHA512
============================================================================= FreeBSD-SA-21:15.libfetch Security Advisory The FreeBSD Project
Topic: libfetch out of bounds read
Category: core Module: libfetch Announced: 2021-08-24 Credits: Samanta Navarro Affects: All supported versions of FreeBSD. Corrected: 2021-08-24 17:59:43 UTC (stable/13, 13.0-STABLE) 2021-08-24 18:00:47 UTC (releng/13.0, 13.0-RELEASE-p4) 2021-08-24 18:30:16 UTC (stable/12, 12.2-STABLE) 2021-08-24 18:32:17 UTC (releng/12.2, 12.2-RELEASE-p10) 2021-08-24 18:29:40 UTC (stable/11, 11.4-STABLE) 2021-08-24 18:31:31 UTC (releng/11.4, 11.4-RELEASE-p13) CVE Name: CVE-2021-36159
For general information regarding FreeBSD Security Advisories, including descriptions of the fields above, security branches, and the following sections, please visit .
I. Background
libfetch(3) is a multi-protocol file transfer library included with FreeBSD and used by the fetch(1) command-line tool, pkg(8) package manager, and others.
II. Problem Description
The passive mode in FTP communication allows an out of boundary read while libfetch uses strtol to parse the relevant numbers into address bytes. It does not check if the line ends prematurely. If it does, the for-loop condition checks for *p == ‘\0’ one byte too late because p++ was already performed.
III. Impact
The connection buffer size can be controlled by a malicious FTP server because the size is increased until a newline is encountered (or no more characters are read). This also allows to move the buffer into more interesting areas within the address space, potentially parsing relevant numbers for the attacker. Since these bytes become available to the server in form of a new TCP connection to a constructed port number or even part of the IPv6 address this is a potential information leak.
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
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 security.FreeBSD.org/patches/SA-21:15/libfetch.patch # fetch security.FreeBSD.org/patches/SA-21:15/libfetch.patch.asc # gpg –verify libfetch.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 .
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/ a75324d674f5 stable/13-n246939 releng/13.0/ 060510ba8bfb releng/13.0-n244758 stable/12/ r370384 releng/12.2/ r370395 stable/11/ r370382 releng/11.4/ r370388 – ————————————————————————-
For FreeBSD 13 and later:
Run the following command to see which files were modified by a particular commit:
# git show –stat
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
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:

VII. References



The latest revision of this advisory is available at —–BEGIN PGP SIGNATURE—–
iQIzBAEBCgAdFiEE/A6HiuWv54gCjWNV05eS9J6n5cIFAmElV14ACgkQ05eS9J6n 5cJpVBAApBRBKwxTpmLfH+JJP8JwDwpop407/A54uPFRXzl7ri6D0wlvlHgMb70T OPnD2pco3gI56GOvRLipnbtrkGZJT0ijsXHMqMK+3O44yoMP8BMNOZauPUVia6FW 6P0aLXqjiJDYZ8N2k+MnnsXQFJKvFt/Vv0D7aHOUettfgyx5YIQX2urjB/hGZIfM 93VMRCsLruixIRgsL6Jt2PvS004HxqJOsaNMg6unp0JWa/vrcCcr4AMzJmu+k0lg /XtUpNBWdClKSYvDFikNrCz9x8ae6V9wosz5gfeKL+1tctBMxhrMLwBEaWtB7YIc 4Vu9+ZsGRLBpapEE8aLRyApY1xFP0xcDutf1G/tuuz5zK8gObaTrxTcRm6fbyf8C ejspPabgM3lgKrWjGiI0T3WzYPWJKTZqtGEAtyMAutjpv9+N/p0YEDsCWkvG/zlt BZ+TbT33oL2N1odzLBNOlJkiR2LQnTcjBgci+jqCVx7CdnYmV2laGF1kIttBCcRN TOJoOJ1pbK1UXqek77+cCSeTKrlocU6oH3+1W68oLeWtemvzCTxlxLsT/pU/TetC 2fibVyN9P1PMI0VbaktjSN8HX8QWtr1u5kp2AIZPmq5RqL+S7+o90GVFr5f41D7M QjHGddO+DG77lGyd+KC7zMuG6p8OcDBkdy9Tc0aTVW4JPhnIeyA= =QN3R —–END PGP SIGNATURE—– _______________________________________________ freebsd-security-notifications@freebsd.org mailing list lists.freebsd.org/mailman/listinfo/freebsd-security-notifications To unsubscribe, send any mail to “freebsd-security-notifications-unsubscribe@freebsd.org