GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-155649: Bound LZMA dictionary size to prevent memory DoS by DeseretSaint · Pull Request #155650 · python/cpython

Conversation

@DeseretSaint

@DeseretSaint DeseretSaint commented Aug 13, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

liblzma allocates the full LZMA dictionary up front when a decompressor is created, and the dictionary size comes from the stream header. An untrusted stream can declare a multi-gigabyte dictionary (up to 4 GiB) and force that allocation from a handful of bytes — a memory denial of service.

Both crash paths were reported by OSS-Fuzz (python3-libraries, public):

  • fuzzer-zipfile OOM: a 1088-byte zip whose LZMA member declares a ~2 GiB dictionary → https://issues.oss-fuzz.com/issues/495472861
  • fuzzer-tarfile OOM: a 13-byte input whose first byte is a valid LZMA-alone properties byte with a ~4 GiB dictionary → https://issues.oss-fuzz.com/issues/482161128

Directly reachable too: lzma.decompress() / LZMADecompressor(FORMAT_AUTO) on untrusted bytes, and LZMADecompressor(FORMAT_RAW, filters=[{"dict_size": ...}]).

Changes

  1. parse_filter_spec_lzma() rejects dict_size above liblzma's own maximum (LZMA_DICT_SIZE_MAX, 1.5 GiB) with LZMAError — covers raw LZMA1/LZMA2 filter chains, including zipfile's LZMA members (the dictionary is parsed from the 5-byte properties header before any data is decompressed).
  2. LZMADecompressor defaults memlimit to LZMA_DICT_SIZE_MAX instead of UINT64_MAX — bounds the FORMAT_AUTO/FORMAT_ALONE/FORMAT_XZ paths where the header is parsed inside liblzma (tarfile compression detection, lzma.decompress(), LZMAFile).

An explicit memlimit can still be passed to raise or lower the bound.

Compatibility: liblzma presets cap at 64 MiB dictionaries; 1.5 GiB is liblzma's own maximum supported dictionary size, so no legitimate stream is affected.

Tests: new regression tests in test_lzma.py, test_zipfile (crafted bomb zip → LZMAError), and test_tarfile (13-byte fake-LZMA input → ReadError). test_lzma test_zipfile test_tarfile all pass (1,487 tests).

Companion fuzzer-harness change: https://github.com/python/library-fuzzers/pull/… (zipfile fuzzer now tolerates lzma.LZMAError).

  • Issue: lzma: unbounded dictionary-size allocation is a memory DoS (zipfile, tarfile, lzma.decompress) #155649

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@DeseretSaint
pythongh-155649: Bound LZMA dictionary size to prevent memory DoS
c7a05bd
liblzma allocates the full LZMA dictionary up front when a decompressor
is created, and the dictionary size comes from the stream header.  An
untrusted stream could declare a multi-gigabyte dictionary (up to 4 GiB)
and force that allocation from a handful of bytes, exhausting memory.

Two gaps are closed:
- parse_filter_spec_lzma() now rejects dict_size above liblzma's own
  maximum (LZMA_DICT_SIZE_MAX, 1.5 GiB) with LZMAError.  This covers
  raw LZMA1/LZMA2 filter chains, including zipfile's LZMA members.
- LZMADecompressor now defaults memlimit to LZMA_DICT_SIZE_MAX instead
  of UINT64_MAX, bounding the FORMAT_AUTO/FORMAT_ALONE/FORMAT_XZ paths
  (e.g. tarfile's compression detection and lzma.decompress()).

An explicit memlimit can still be passed to adjust the bound.

Fixes OSS-Fuzz reports (python3-libraries):
- fuzzer-zipfile OOM: https://issues.oss-fuzz.com/issues/495472861
- fuzzer-tarfile OOM: https://issues.oss-fuzz.com/issues/482161128
@DeseretSaint
DeseretSaint requested a review from ethanfurman as a code owner August 13, 2026 04:44
@python-cla-bot

python-cla-bot Bot commented Aug 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot mentioned this pull request Aug 13, 2026
lzma: unbounded dictionary-size allocation is a memory DoS (zipfile, tarfile, lzma.decompress) #155649
Open
@bedevere-app bedevere-app Bot added the awaiting review label Aug 13, 2026
@read-the-docs-community

read-the-docs-community Bot commented Aug 13, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34043724 | 📁 Comparing c7a05bd against main (ee4fe00)

  🔍 Preview build  

2 files changed
± library/lzma.html
± whatsnew/changelog.html
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BHUVANSH855
BHUVANSH855 reviewed Aug 13, 2026
View reviewed changes

@BHUVANSH855 BHUVANSH855 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLA check is failing, kindly sign the CLA so that maintainers can start review process.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@DeseretSaint

DeseretSaint commented Aug 13, 2026

Copy link
Copy Markdown
Author

Done.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Nov 12, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ethanfurman ethanfurman Awaiting requested review from ethanfurman ethanfurman is a code owner
1 more reviewer
@BHUVANSH855 BHUVANSH855 BHUVANSH855 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@DeseretSaint @BHUVANSH855
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.