cpio does not properly validate the values written in the header of a TAR file through the to_oct() function. When creating a TAR file from a list of files and one of those is another TAR file with a big size, cpio will generate the resulting file with the content extracted from the input one. This leads to unexpected results as the newly generated TAR file could have files with permissions the owner of the input TAR file did not have or in paths he did not have access to. References: https://lists.gnu.org/archive/html/bug-cpio/2019-08/msg00003.html Proposed patch: https://cement.retrofitta.se/tmp/cpio-tar.patch
Mitigation: TAR archives should be inspected before being extracted and the extraction should be performed with the `tar` command or `--no-absolute-filenames` option if done with `cpio`. Moreover, it should be performed by a low-privilege user whenever possible, to prevent extraction of files that could compromise the system.
Acknowledgments: Name: Thomas Habets
Created cpio tracking bugs for this issue: Affects: fedora-all [bug 1766234]
In function tar.c:write_out_tar_header() some fields are written in octal digits in the TAR header. Among them, the "file size" field is written but only 12 bytes are available in the buffer for the resulting octal digits. When the file size of the input file is greater than the maximum number that could be written with 11 octal digits (12 - 1 for the null byte), no checks are performed to detect this case and an unexpected TAR file is generated, containing the files extracted from the input file.
This issue has been addressed in the following products: Red Hat Enterprise Linux 7 Via RHSA-2020:3908 https://access.redhat.com/errata/RHSA-2020:3908
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s): https://access.redhat.com/security/cve/cve-2019-14866
This issue has been addressed in the following products: Red Hat Enterprise Linux 8 Via RHSA-2021:1582 https://access.redhat.com/errata/RHSA-2021:1582
This issue has been addressed in the following products: Red Hat Enterprise Linux 8.2 Extended Update Support Via RHSA-2022:0073 https://access.redhat.com/errata/RHSA-2022:0073