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

Merge bitcoin/bitcoin#36299: cli: Improve empty-response and fix -rpcclienttimeout regression

Public commit record

What the developer wrote

Authored by Ava Chow

100/100 · Strong
Merge bitcoin/bitcoin#36299: cli: Improve empty-response and fix -rpcclienttimeout regression

1805716354b49ecb96e49b949a61e2c72ad2c1a3 cli: Apply -rpcclienttimeout per socket wait instead of per phase (Fabian Jahr)
b841ab694215699cba53c4de8a7cc08b9fce259a cli: Treat a response with Content-Length: 0 as complete (Fabian Jahr)

Pull request description:

Two follow-ups to #34342

First commit: An empty body was not treated as a complete response. We currently check if `Content-Length` is greater than zero instead of whether the header was sent, so a response with a `Content-Length` of 0 falls into the branch for responses that carry no length and confinues to read until the peer disconnects. Our server sends an empty body with several types of errors such as a wrong RPC password but it does close the connection as well, which mitigates this from causing any serious issue. However, it would still be good to handle this correctly on the client side that we don't have to rely on the server to save us from hanging.

b-l-u-e found this in post-merge review in https://github.com/bitcoin/bitcoin/pull/34342#discussion_r3358700705 but I didn't manage to look into it until now.

Second commit: `-rpcclienttimeout` no longer measures real idle time. Before the libevent removal, it used to mean give up if really nothing arrives for this long, and any newly incoming data did reset the counter. With the new code the countdown ignores progress, so a large/slow response could be cut off while data still arrives. Revert this to the old behavior.

The second commit does not have a test because I didn't manage to construct one that didn't turn out to be flaky. It may be possible but I couldn't come up with something within a scope of complexity that seems reasonable for this.

ACKs for top commit:
achow101:
ACK 1805716354b49ecb96e49b949a61e2c72ad2c1a3
0tuedon:
tACK 1805716354b49ecb96e49b949a61e2c72ad2c1a3
winterrdog:
tACK 1805716354b49ecb96e49b949a61e2c72ad2c1a3
hodlinator:
ACK 1805716354b49ecb96e49b949a61e2c72ad2c1a3

Tree-SHA512: 6139328c84480af7c7ccd5beec3361a28bbd639459e36b3f033ffc5946840ac0e589d987d4ce2414e58110b73ce48e34b449f9dd5ca577d07e334589a280a136
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This update fixes two bugs in bitcoin-cli, the command-line tool used to talk to a Bitcoin node. First, when a server replied with an empty body but said it was intentionally empty (Content-Length: 0), the client would keep waiting instead of accepting the reply. Second, the client timeout stopped measuring actual idle time, so a slow but ongoing download could be cut off. The patch makes the timeout reset whenever new data arrives and treats a declared empty body as complete. The hang-on-empty-body case is the more security-relevant one, because a malicious or misbehaving server that keeps the connection open could make bitcoin-cli hang until the user kills it.

Recommended action

No urgent action beyond applying the patch. Users and downstream packagers should include this fix to avoid bitcoin-cli hanging against servers that return Content-Length: 0 while keeping the connection open. Operators relying on -rpcclienttimeout for large RPC calls should verify slow responses are no longer prematurely aborted.

Security signals we found

01

Client-side hang on empty HTTP body (denial-of-service against bitcoin-cli user)

02

Timeout regression could abort legitimate slow RPC responses

03

Fix distinguishes Content-Length: 0 from absent Content-Length

04

Timeout behavior reverted to reset on each received data chunk

Risk score

Why this scored 38/100

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