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

Change CChain::Contains() to take reference

Public commit record

What the developer wrote

Authored by optout

80/100 · Strong
Change CChain::Contains() to take reference

The `CChain::Contains()` method dereferences its input without checking,
potentially resulting in nullptr-dereference if invoked with `nullptr`.
To avoid this possibility, its input is changed to a reference instead.
Call sites are adapted accoringly, extra nullptr-check is added as
needed.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
The short version

What changed, and why it matters

This commit hardens a core Bitcoin method called CChain::Contains() so it can no longer be accidentally called with a null (missing) block pointer, which would crash the node. The change turns the method's input from a pointer into a reference, forcing every caller to prove the block exists before calling it. Several call sites were updated, and one place in startup index syncing now explicitly handles a missing block instead of silently passing a null pointer. It is a defensive fix that removes a class of potential null-dereference crashes, but the commit message does not frame it as a critical security vulnerability and no exploit is demonstrated.

Recommended action

Treat as a low-to-moderate hardening commit. Review whether any remaining callers of CChain::Next() still accept nullptr (the commit message notes the next commit will address that). Ensure fuzzing and unit tests cover null/missing block index paths for RPC, REST, and P2P handlers. No urgent patch deployment is indicated absent a demonstrated exploit, but the change is safe to include in normal release cadence.

Security signals we found

01

Null-pointer dereference hardening in consensus-adjacent code

02

Signature change from pointer to reference to enforce non-null at compile time

03

Addition of explicit null check in StartIndexBackgroundSync before Contains() call

04

Use of Assert() macro in net_processing to document assumed non-null invariant

05

Removal of commented-out crash test indicating prior awareness of null-deref behavior

Risk score

Why this scored 47/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 6/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.