[Hardening] Validate legacy block_headers length before slicing (F-007)
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- rust
调研方向
从受影响版本中 raw_client.rs 第1062–1068行开始,追踪协议1.4的旧版 blockchain.block.headers 响应处理。检查解码后的头部长度和 count 在切片前如何使用,然后为头部为空、被截断以及数量不匹配的情况添加回归测试。完成标准是:格式错误的响应返回协议错误且不会触发 panic,同时有效的头部响应仍能正常工作。
由索引模型根据 Issue 内容生成。
描述
Summary
In rust-electrum-client 0.25.2 (reported upstream commit 7c1d759e2789b5e46fcae1525ab06ff4012bc668), the pre-1.6 legacy response path for blockchain.block.headers trusts the server-controlled result.count and slices the decoded header bytes in fixed 80-byte chunks without validating the available length. A malicious or compromised Electrum server (or an attacker able to alter the Electrum connection) can make a release build panic, causing client/wallet availability loss.
Reproduction
- Build the client in release mode.
- Connect to a mock TCP Electrum server.
- Negotiate protocol version 1.4.
- Return this response to blockchain.block.headers:
{"jsonrpc":"2.0","id":1,"result":{"count":1,"max":8,"hex":""}}
Observed:
range end index 80 out of range for slice of length 0
A negative control containing one valid 80-byte header with count=1 returns normally. A count=3 response containing only one header panics at the second slice.
Source
Reported source location: raw_client.rs lines 1062–1068 (in the affected revision).
Suggested hardening
- Validate the decoded header byte length (and its consistency with count) before fixed-size slicing.
- Return a normal protocol error on mismatch instead of panicking.
- Add regression tests for empty/truncated headers and mismatched counts.
This is a hardening issue: the demonstrated impact is availability loss in release mode; no fund or privacy compromise was observed.
- 主要语言
- Rust
- 星标
- 89
- 派生
- 87
- 平均合并
- 1 小时 25 分钟
- 30 天内合并 PR
- 4
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
bitcoindevkit/rust-electrum-client 的其他 Issue
-
[Hardening] Reject non-object JSON notifications without panicking (F-008)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 82/100
bitcoindevkit/rust-electrum-client#221 · 1 条评论 ·
-
use-rustls-ring transitively enables rustls/default (aws-lc-rs), breaking ring-only builds可能已有人在做 @EddieHouston 于 130 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
-
discussion new feature
难度 4/5 3-5 天 新手友好度 48/100
bitcoindevkit/rust-electrum-client#211 · 2 条评论 ·
-
Rework CI to use `cargo-rbmt`可能重新可做 @luisschwab 于 205 天前认领,目前没有进行中的 PR。 未关闭
bitcoindevkit/rust-electrum-client#202 · 已指派 1 人 ·
查看 bitcoindevkit/rust-electrum-client 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
swc-project/swc-ai-issues#164 ·
-
难度 2/5 1-3 小时 新手友好度 85/100
pop-os/cosmic-player#367 ·
-
good first issue help wanted
难度 2/5 1-3 小时 新手友好度 72/100
servo/rust-smallvec#873 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
messense/dav-server-rs#82 ·
维护者通常 1 天内回复