AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 60 Bitcoin

consensus_encoding: implement batched allocation for VecDecoder and `ByteVecDecoder`

Public commit record

What the developer wrote

Authored by jrakibi

73/100 · Adequate
consensus_encoding: implement batched allocation for VecDecoder and `ByteVecDecoder`

`VecDecoder` and `ByteVecDecoder` only checks that the element count/byte < 4,000,000.
This still allows an attacker to claims a large size without providing the data.

In this patch we allocates in 1 MB batches so an attacker now needs to provide
X MB of data to make us allocate X+1 MB of memory
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a denial-of-service weakness in how the library reads length-prefixed byte and element lists from untrusted data. Previously, the library would reserve up to 4 million bytes or elements immediately after seeing a length number, even if the actual data never arrived. Now it reserves memory in 1 MB chunks only as data actually comes in, so an attacker must send data to make the program use memory. The commit message and code comments explicitly describe this as a DoS-prevention change.

Recommended action

Review the batch size and element-size calculation for integer overflow or zero-size types; confirm the 4,000,000 element/byte cap is still enforced elsewhere. Consider adding tests that send a large length prefix with truncated data to verify memory usage stays bounded.

Security signals we found

01

DoS-prevention allocation batching

02

Removal of upfront large Vec::with_capacity based on attacker-controlled length prefix

03

Memory-bound incremental reservation

04

Explicit reference to Bitcoin Core DoS mitigation in comments

Risk score

Why this scored 60/100

Our methodology →
Potential impact 12/30
Exploitability 14/25
Stealth signal 10/15
Affected reach 12/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.