Uniform decompression-budget and corrupt-input handling across all permessage-* extensions
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #1987 来自 @oberstet —— 已合并
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- python
- 领域
- backend, networking
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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:
- Budget: no backend produces more than
max_output_len + 1octets in one call. "Over budget" and "budget already 0" both raisePayloadExceededError, 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 thecompressextra tobrotli>=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
PayloadExceededErroronce the budget is used up, instead of capping the call at 1 octet.
- brotli: use
- 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. - 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
- 主要语言
- Python
- 星标
- 2.5k
- 派生
- 767
- 平均合并
- 1 天 1 小时
- 30 天内合并 PR
- 23
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
crossbario/autobahn-python 的其他 Issue
-
CI-CD enhancement
难度 2/5 1-3 小时 新手友好度 78/100
crossbario/autobahn-python#1945 · 1 条评论 ·
维护者通常 1 天内回复
-
bug CI-CD
难度 2/5 1-3 小时 新手友好度 76/100
crossbario/autobahn-python#1932 ·
维护者通常 1 天内回复
-
CI-CD enhancement
难度 2/5 1-3 小时 新手友好度 72/100
crossbario/autobahn-python#1829 · 1 条评论 ·
维护者通常 1 天内回复
-
[BUG] extract_peer_certificate() raises AttributeError with pyOpenSSL >= 26.2.0 when the peer certificate has extensions可能已有人在做 @oberstet 今天认领。 未关闭bug wamp websocket
难度 4/5 3-5 天 新手友好度 35/100
crossbario/autobahn-python#2014 ·
维护者通常 1 天内回复
-
bug CI-CD
难度 4/5 3-5 天 新手友好度 52/100
crossbario/autobahn-python#2013 ·
维护者通常 1 天内回复
查看 crossbario/autobahn-python 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
anchore/grype-db#1149 · 1 条评论 ·
维护者通常 1 天内回复
-
[Bug]: `hermes plugins update` clones an entire monorepo twice - `subdir` is resolved but dropped at both catalog-update call sites可能已有人在做 @HootRock 今天认领。 未关闭comp/cli P2 type/perf
难度 2/5 1-3 小时 新手友好度 72/100
NousResearch/hermes-agent#142417 · 2 条评论 ·
维护者通常 1 天内回复
-
SMC SPEC
难度 2/5 1-3 小时 新手友好度 70/100
tenstorrent/tt-oca-harness#3287 ·
维护者通常 1 天内回复
-
bug enhancement python
难度 2/5 1-3 小时 新手友好度 85/100
DewaldOosthuizen/tech-cheat-sheets-and-notes#392 ·
维护者通常 1 天内回复
-
security
难度 2/5 1-3 小时 新手友好度 72/100
fabriziosalmi/wildbox#801 ·
维护者通常 1 天内回复