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

wire: make decode budget tests assert what they describe

Public commit record

What the developer wrote

Authored by Olaoluwa Osuntokun

83/100 · Strong
wire: make decode budget tests assert what they describe

In this commit, we strengthen the decode budget tests so each one
actually verifies the property its comment claims.

The truncated vector test now asserts a decode reserves zero element
storage rather than comparing against an always-zero maxCap column, and
it covers MsgBlock.DeserializeTxLoc in addition to BtcDecode, closing
the one count-driven vector the table missed.

The streaming decode tests no longer silently take the preallocation
path: a bare bytes.Reader exposes its remaining length, which let the
decoders preallocate from the claimed counts. Both now wrap the reader
in readSizeRecorder, which hides the remaining length, and assert the
element vectors grew to only about twice the delivered count.

The truncated frame test now measures total bytes allocated across one
hundred truncated header reads and bounds them far below the claimed
payload, covering reservation as well as the already-checked read sizes.
The variable length prefix test gains a loop that claims the maximum
payload while delivering progressively more bytes, asserting the staged
reservation tracks what was delivered rather than the claim.

The readSizeRecorder helper moves next to the other test readers and
gains a doc comment explaining its two jobs: hiding the reader's
remaining length to force streaming, and recording the largest read
request to catch oversized speculative reads.
✓ Specific, 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 only changes test code. It strengthens existing tests that verify Bitcoin wire-protocol decoders do not reserve huge amounts of memory based on attacker-controlled length fields. No production code is modified, so it does not introduce or fix a runtime vulnerability by itself. It appears to be a follow-up that makes earlier decode-budget protections actually testable.

Recommended action

No immediate action required; this is a test-only change. Reviewers may want to confirm the corresponding production decode-budget fixes are already merged and that these new assertions pass in CI.

Security signals we found

01

Hardens memory-budget tests for wire protocol decoders

02

Prevents test readers from exposing remaining length, forcing streaming decode paths

03

Adds allocation-bound test for truncated message headers

04

Adds staged-reservation test for variable-length byte reads

05

No changes to non-test source files

Risk score

Why this scored 12/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/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.