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

rpcclient: avoid double-resolving POST requests on shutdown

Public commit record

What the developer wrote

Authored by Boris Nagaev

83/100 · Strong
rpcclient: avoid double-resolving POST requests on shutdown

When shutdown races with sendPostRequest, a request could be marked
as ErrClientShutdown and still be enqueued. The sendPostHandler cleanup
loop would then try to send a second terminal response and could block
forever on a full response channel.

Fix this by prioritizing the shutdown path. First check shutdown with a
non-blocking select and return immediately when it is already closed.
Then use a second select to choose between enqueue and shutdown for the
remaining race window.

A regression test verifies a shutdown request is failed immediately and
never enqueued.
✓ 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 fixes a race condition in btcd's RPC client that could cause the client to hang forever during shutdown. When the client was shutting down at the same moment a request was being sent, the old code could both mark the request as failed due to shutdown and still place it in the outgoing queue. A cleanup loop would later try to send a second response on a channel that was already full, blocking indefinitely. The fix prioritizes the shutdown path so requests are failed immediately and never queued once shutdown has started. A regression test was added to confirm the behavior.

Recommended action

Treat this as a reliability and availability fix rather than an active exploit. Upgrade btcd nodes that rely on the RPC client to a version containing this commit to prevent shutdown hangs. If running an affected version, avoid issuing RPC calls immediately before or during client shutdown, and monitor for stuck goroutines in rpcclient.

Security signals we found

01

Race condition between shutdown and request enqueueing

02

Potential indefinite goroutine block on full response channel

03

Double-response / double-resolution of a single RPC request

04

Denial-of-service-like client hang during shutdown

05

Regression test added for shutdown prioritization

Risk score

Why this scored 42/100

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