python / python/cpython

Keep next_in and avail_in in sync in bz2/lzma/zlib decompressor reset paths

未關閉
#149,105 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

extension-modules type-refactor
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Bug report

Bug description:

(This was found by Gemini, orchestrated by Dirk Mueller at SUSE)

For https://github.com/advisories/GHSA-pg25-7cx5-cvcm the "next_in" pointers were reset to NULL. However if the decompressor is reused, the "avail_in_real" counter should also be reset to "0" at this time, as if its reused again, next_in and avail_in_real might not be in sync again.

This affects

Modules/_bz2module.c
Modules/_lzmamodule.c
Modules/zlibmodule.c

For bz2, everywhere where next_in is set to NULL, avail_in_real also needs to be set to 0.

++ bzs->next_in = NULL;
should also set
bzs->avail_in_real = 0;

similar for the others.

This is largely hardening. It is not clear if these use cases exist.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

檢查 Modules/_bz2module.c、Modules/_lzmamodule.c 和 Modules/zlibmodule.c 中的重設路徑,找出每個將 next_in 設為 NULL 的指定。確認每次此類重設也會清除 avail_in_real,然後執行相關的解壓縮器測試,並驗證重複使用的解壓縮器狀態仍保持同步。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
c, python
領域
backend, security
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
冷清
描述清晰度
描述清楚
新手友好度
62/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。