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

blockchain: reuse existing header node in maybeAcceptBlock

Public commit record

What the developer wrote

Authored by Calvin Kim

73/100 · Adequate
blockchain: reuse existing header node in maybeAcceptBlock

maybeAcceptBlock unconditionally created a new blockNode, overwriting the
index entry. If maybeAcceptBlockHeader had already processed the header,
the pointer held by bestHeader's chainView became orphaned, breaking
bestHeader.Contains and downstream checks like IsValidHeader.

Check for an existing node first and upgrade its status to
statusDataStored rather than replacing it.
✓ 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 bug in btcd's blockchain handling where accepting a full block could overwrite an existing header-only entry in the block index. That overwrite would leave an internal 'best header' view pointing to an orphaned record, causing later checks that rely on header membership to fail. The fix reuses the existing index entry and upgrades its status instead of replacing it.

Recommended action

Review whether any reachable code paths could have triggered incorrect behavior from the orphaned bestHeader pointer, such as stale header validation or netsync decisions. The fix should be backported if the affected release branch is in production use. No immediate emergency action is indicated because the bug is internal-state consistency rather than a direct funds-loss or remote-crash vector.

Security signals we found

01

Inconsistent internal block index state leading to incorrect header-chain membership checks

02

Potential for downstream synchronization logic to make wrong decisions based on orphaned bestHeader pointers

03

Regression test added to prevent reintroduction

Risk score

Why this scored 58/100

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