Skip to content

Prevent 256-bytes compression windows, unsupported by zlib. - #1768

Merged
aaugustin merged 1 commit into
mainfrom
fix-wbits-8
Sep 19, 2026
Merged

aaugustin merged 1 commit into
mainfrom
fix-wbits-8

Conversation

@aaugustin

Copy link
Copy Markdown
Member
  • When initializing the extension, reject window bits = 8
    for the local compressor.
  • When negotiating the extension, reject if the other side
    sets a limit to window bits = 8

This avoids zlib.compressobj(wbits=-8), which raises ValueError
due to madler/zlib#171.

Fix #1757.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Tests must verify that valid 8-bit decompressor negotiation remains accepted.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Prevents unsupported 8-bit zlib compression windows while retaining 8-bit decompression support.

Changes:

  • Validates local compression windows as 9–15.
  • Rejects negotiated 8-bit local compressor windows.
  • Adds regression tests and a changelog entry.
File Description
src/​websockets/​extensions/​permessage_deflate.py Adds validation and negotiation guards.
tests/​extensions/​test_permessage_deflate.py Tests 8-bit rejection paths.
docs/​project/​changelog.rst Documents the improvement.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/extensions/test_permessage_deflate.py
Comment thread tests/extensions/test_permessage_deflate.py
* When initializing the extension, reject window bits = 8
  for the local compressor.
* When negotiating the extension, reject if the other side
  attempts to limit the local compressor to window bits = 8.
* Confirm that a remote compressor limited to window bits = 8
  is still supported.

This avoids zlib.compressobj(wbits=-8), which raises ValueError
due to madler/zlib#171.

Fix #1757.
@aaugustin
aaugustin merged commit 3f5a5d1 into main Sep 19, 2026
8 checks passed
@aaugustin
aaugustin deleted the fix-wbits-8 branch September 19, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants