Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#332 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
c, python
领域
security

调研方向

从 c-ext/decompressor.c:335 开始,使用提供的 13 字节畸形帧重现该问题。跟踪帧内容大小如何传递到内存分配,以及解压缩错误如何变为 ZstdError;当畸形输入在不进行超大内存分配的情况下被拒绝,并且回归覆盖验证了该失败时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
C
星标
642
派生
116
平均合并
1 天 14 小时
30 天内合并 PR
5

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

indygreg/python-zstandard 的其他 Issue

查看 indygreg/python-zstandard 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。