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

net: fix use-after-free with v2->v1 reconnection logic

Public commit record

What the developer wrote

Authored by Eugene Siegel

73/100 · Adequate
net: fix use-after-free with v2->v1 reconnection logic

CConnman::Stop() resets semOutbound, yet m_reconnections is not
cleared in Stop. Each ReconnectionInfo contains a grant member
that points to the memory that semOutbound pointed to and ~CConnman
will attempt to access the grant field (memory that was already
freed) when destroying m_reconnections. Fix this by calling
m_reconnections.clear() in CConnman::Stop() and add appropriate
annotations.
✓ 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 memory-handling bug that occurs when Bitcoin Core shuts down its network connections. A list of pending reconnections held references to a memory resource (semaphore) that was freed during shutdown. When the program later destroyed that list, it could read already-freed memory, which can cause crashes or unpredictable behavior. The fix clears the reconnection list before freeing the underlying resource and adds code annotations to prevent the wrong lock from being held during shutdown.

Recommended action

Apply the patch to ensure m_reconnections is cleared before semOutbound is reset, and adopt the lock annotations to prevent future regressions. No immediate emergency response is indicated because the bug is in the shutdown path and not remotely triggerable.

Security signals we found

01

use-after-free in shutdown path

02

destructor accesses freed semaphore memory

03

missing cleanup of m_reconnections before semaphore destruction

04

added thread-safety annotations for shutdown locks

Risk score

Why this scored 49/100

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