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

witness: Allocate in reserve_batch if capacity < MIN_VECTOR_ALLOCATE

Public commit record

What the developer wrote

Authored by Mitchell Bagot

81/100 · Strong
witness: Allocate in reserve_batch if capacity < MIN_VECTOR_ALLOCATE

Following #6198, the reserve_batch call now allocates a minimum size of
1000 bytes. Since the allocation only updates beyond capacity when
capacity - len == 0, reserve_batch may not always allocate up to the
given required_len.
In WitnessDecoder::push_bytes, reserve_batch is used in such a way that
assumes self.content will have the required_len. This causes a panic
when writing a compact size to the witness content if it does not.

Replace capacity == 0 check with capacity < MIN_VECTOR_ALLOCATE,
ensuring reserve_batch always allocates at least MIN_VECTOR_ALLOCATE
empty content space.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a bug in how the Bitcoin witness data decoder grows its internal buffer. Previously, when decoding witness data, the code could fail to reserve enough space before writing a size value, causing the program to panic and crash. The fix ensures the buffer is always expanded by at least a minimum amount when free space is low.

Recommended action

Treat as a security-relevant bug fix and include in release notes. Backport to maintained release branches. Review other uses of reserve_batch for similar assumptions about guaranteed allocation size. No immediate CVE is required unless a reproducible crash from untrusted network input is confirmed, but the project should assess whether this is reachable from serialized transaction parsing.

Security signals we found

01

Denial-of-service vector: malformed or crafted witness input can trigger a panic during decoding

02

Memory allocation boundary condition in serialization/deserialization code

03

Fix follows a prior related change (#6198), indicating an incomplete patch

04

Crash occurs in witness parsing, a consensus-critical data structure

Risk score

Why this scored 59/100

Our methodology →
Potential impact 18/30
Exploitability 12/25
Stealth signal 8/15
Affected reach 10/15
Confidence 7/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.