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

primitives: add minimum allocation size

Public commit record

What the developer wrote

Authored by Andrew Poelstra

78/100 · Adequate
primitives: add minimum allocation size

It's possible to construct witnesses that force our current logic to repeatedly
allocate a single byte, many thousands of times. This is inefficient, and on
some targets (notably: x86 with fuzzer instrumentation) it is slow to the point
of being a DoS vector.

I was not able to construct a unit test which meaningfully demonstrates this
behavior (or even runs slowly enough to notice), but with this patch, a fuzzer
input which previously took several seconds now takes only milliseconds.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a performance problem in how the library reads Bitcoin transaction witness data. Before the fix, specially crafted witness data could force the code to allocate memory one byte at a time, thousands of times in a row. That slowness could be abused to cause denial of service, especially when the code is run under fuzz testing or other instrumentation. The fix ensures the code always allocates at least 1,000 bytes at once, removing the repeated tiny allocations.

Recommended action

Apply the patch. It is a low-risk performance hardening change. Consider adding a regression test or benchmark that exercises large witness deserialization to prevent reintroduction of the pathological allocation pattern.

Security signals we found

01

DoS vector explicitly mentioned in commit message

02

Pathological allocation pattern in deserialization

03

Fuzzer instrumentation target noted as affected

04

No bounds or correctness change; only allocation batching

Risk score

Why this scored 57/100

Our methodology →
Potential impact 12/30
Exploitability 14/25
Stealth signal 10/15
Affected reach 11/15
Confidence 7/10
Evidence quality 3/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.