Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Uniform decompression-budget and corrupt-input handling across all permessage-* extensions

Đã đóng
#1,986 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Một pull request liên quan đã được merge.

  • #1987 của @oberstet — đã merge

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend, networking

Hướng nghiên cứu

Start with websocket/protocol.py and onFrameData(), then inspect the four decompress_message_data() implementations and their compression dependency versions. Add unit coverage for the listed budget and corrupt-input cases, plus protocol tests on Twisted and asyncio; run them on CPython and PyPy. Done means all backends enforce the output budget and map decode errors to PayloadCorruptError, with clean connection failures.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

Autobahn supports four WebSocket per-message compression extensions: permessage-deflate (RFC 7692), and the non-standard permessage-bzip2, permessage-brotli and permessage-snappy. All four implement the same internal method:

def decompress_message_data(self, data, max_output_len=None): ...

The receive path (websocket/protocol.py, onFrameData()) passes in the remaining maxMessagePayloadSize budget as max_output_len. The four backends do not handle that budget, or a decode error, the same way. This issue makes their behaviour uniform.

Current behaviour

Extension Budget passed to the library? Over budget Budget already 0 Corrupt input
deflate yes (max_length) PayloadExceededError returns 1 octet, no exception (the protocol's post-inflation check then rejects it) zlib.error
bzip2 yes (max_length) PayloadExceededError PayloadExceededError OSError
brotli no: decompresses the whole frame, then checks PayloadExceededError, after decompression PayloadExceededError brotli.error / brotlicffi.error
snappy no: decompresses the whole frame, then checks PayloadExceededError, after decompression PayloadExceededError no exception: the input is buffered and an empty message is returned

Decode errors are not caught in onFrameData(), so how a connection fails on a corrupt compressed frame depends on the backend and on the networking framework (Twisted or asyncio).

Target behaviour

For every extension, on CPython and PyPy, and on Twisted and asyncio:

  1. Budget: no backend produces more than max_output_len + 1 octets in one call. "Over budget" and "budget already 0" both raise PayloadExceededError, which is raised before the backend decompresses past the budget, not after.
    • brotli: use Decompressor.process(data, output_buffer_limit=...), and raise the floor of the compress extra to brotli>=1.2.0 (CPython) / brotlicffi>=1.2.0 (PyPy), the first versions that have this argument.
    • snappy: python-snappy's StreamDecompressor.decompress() has no output limit, so feed the input one framing chunk at a time (at most 64 KiB of output each) and stop at the budget.
    • deflate: raise PayloadExceededError once the budget is used up, instead of capping the call at 1 octet.
  2. Corrupt input: each library's decode error becomes a new autobahn.exception.PayloadCorruptError. The protocol fails the connection the same way for every backend, on Twisted and asyncio. The snappy backend rejects malformed input instead of buffering it.
  3. Remove or correct the code comments claiming that per-frame decompression is "bounded on the wire by maxFramePayloadSize".

Tests

  • Unit tests for every cell of the table above, on all four backends: over budget in one frame, over budget across two frames, exactly at budget, one octet over, budget already 0, and corrupt input. They must check both the exception type and that the output never exceeds the budget plus one octet.
  • Protocol-level tests on Twisted and asyncio: a corrupt compressed frame, and an over-budget compressed message, each fail the connection cleanly with the expected close code.
  • Run on CPython and PyPy.

Target

autobahn-python 26.10.1

Ngôn ngữ chính
Python
Star
2.5k
Fork
767
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
23

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của crossbario/autobahn-python

Tất cả issue của crossbario/autobahn-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.