Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

ZstdDecompressor.decompress: excessive allocation (crash) on 13-byte malformed frame (decompressor.c:335); should raise ZstdError

Open
#332 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
c, python
Domain
security

Research direction

Start at c-ext/decompressor.c:335 and reproduce the issue with the supplied 13-byte malformed frame. Trace how the frame content size reaches allocation and how decompression errors become ZstdError; done means malformed input is rejected without an oversized allocation and regression coverage verifies the failure.

Written by the indexing model from the issue text.

Description

Repo

indygreg/python-zstandard

Summary

ZstdDecompressor().decompress() pre-allocates the full Frame_Content_Size (FCS) from the frame header WITHOUT capping; a 13-byte malformed frame declaring a corrupt FCS makes it call PyBytes_FromStringAndSize for a ~1.1 TB buffer at c-ext/decompressor.c:335, causing an ASan allocation-size-too-big ABORT (in production: a huge MemoryError) — i.e. a crash/DoS on a tiny untrusted decompression input, rather than the documented ZstdError.

Trigger (13 bytes)

hex: 28b52ffde06c06060663636363

Evidence

ASan (binding C-ext built with -fsanitize=address):

ERROR: AddressSanitizer: requested allocation size 0x66c6c6c00000121 exceeds maximum supported size
    #3 PyBytes_FromStringAndSize
    #4 Decompressor_decompress c-ext/decompressor.c:335
SUMMARY: AddressSanitizer: allocation-size-too-big
ABORTING

Expected

The Frame_Content_Size field of a malformed/short frame must not cause an over-allocation; the decompressor should reject such input (raise ZstdError / cap the buffer & grow dynamically), as single-shot malloc of an attacker-controlled FCS is unsafe (CWE-789).

Note

This binding C-ext path is NOT covered by OSS-Fuzz (only upstream zstd core is) and has no advisory.

Dominant language
C
Stars
642
Forks
116
Avg merge
1d 14h
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from indygreg/python-zstandard

All issues in indygreg/python-zstandard

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.