Repository navigation
fix(dash): reject headers messages above Core's batch limit - #1140
Conversation
The `headers` decoder reserved space for up to 16384 headers from the peer-controlled count before reading any, so a few-byte frame with a huge count triggered a ~1.3 MB allocation. `headers2` did the same, capped at `MAX_VEC_SIZE`. Core never sends more than 2000 headers in `headers` or 8000 in `headers2` (`MAX_HEADERS_UNCOMPRESSED_RESULT` and `MAX_HEADERS_COMPRESSED_RESULT`) and treats more as misbehaviour. Reject larger counts before reserving, which also bounds the allocation. Closes #1124 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 28 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1140 +/- ##
==========================================
- Coverage 77.92% 77.92% -0.01%
==========================================
Files 302 302
Lines 79108 79143 +35
==========================================
+ Hits 61644 61669 +25
- Misses 17464 17474 +10
|
|
Bots are done — your move: post |
The `headers` decoder reserved space for up to 16384 headers from the peer-controlled count before reading any, so a few-byte frame with a huge count triggered a ~1.3 MB allocation. `headers2` did the same, capped at `MAX_VEC_SIZE`. Core never sends more than 2000 headers in `headers` or 8000 in `headers2` (`MAX_HEADERS_UNCOMPRESSED_RESULT` and `MAX_HEADERS_COMPRESSED_RESULT`) and treats more as misbehaviour. Reject larger counts before reserving, which also bounds the allocation. Closes #1124 Co-authored-by: Claude Opus 5.5 <[email protected]> (cherry picked from commit 644d373)
Closes #1124.
The
headersdecoder reserved space for up to 16384 headers from the peer-controlled count before reading any, so a few-byte frame with a huge count triggered a ~1.3 MB allocation.headers2had the same pattern, capped atMAX_VEC_SIZE.Core never sends more than 2000 headers in
headersor 8000 inheaders2(MAX_HEADERS_UNCOMPRESSED_RESULT/MAX_HEADERS_COMPRESSED_RESULTinsrc/validation.h) and treats more as misbehaviour (net_processing.cpp). Both decoders now reject larger counts before reserving, which also bounds the allocation.For
headers2, Core's limit is 2000 unless the negotiated protocol version allows 8000. The decoder doesn't know the negotiated version, so it enforces the absolute maximum.Testing
test_case): exactly the limit decodes and one above is rejected, for both messages. A frame carrying only au64::MAXcount fails.cargo test -p dashcore,cargo test -p dash-spvand-p dash-spv-ffi --test dashd_syncwith dashd integration tests, clippy-D warnings.test-caseis added todash's dev-dependencies (same version asdash-spv,hashes,key-wallet).🤖 Generated with Claude Code
PR Hygiene ·
499f8d1/self-revieweddash/Cargo.toml,dash/src/network/message.rs,dash/src/network/message_headers2.rs) — QuantumExplorer or xdustinfaceWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.