Repository navigation
Conversation
A client whose address is not in -rpcallowip gets a 403, but a client asking for "Connection: keep-alive" must not be able to hold the connection open.
… open connections
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35772. ReviewsSee the guideline and AI policy for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Haven't reviewed this yet but is the issue already covered by #35592 ? |
ugh! yes but partially, let me re-work it. Thanks |
|
The reworked code comes down to only the change in the WriteReply() function. The change would only be used for the (now) ignored line 185 of httpserver.cpp (sends headers without a connection close). I do not think this is currently worthy to PR, or overkill for one line of code. So closing this instead. |
This PR changes the way how a ClientAllowed rejection is handled.
Currently whether to drop the connection to a refused client is the client's choice instead of the server.
A client whose address is not covered by
-rpcallowipgets a403 Forbidden, but the connection is not actively closed. This PR changes that by setting aConnectionclose header on reject and a change in theWriteReply()function makes that now the connection is closed based on a close requested by either side. The client is disconnected once the reply has been flushed.So a rejected client asking for
keep-alive(the HTTP/1.1 default) does not hold a slot until-rpcservertimeoutexpires anymore. Whether to drop a refused connection should not be that peer's choice. This fixes a DDOS vector that will increase severity if #35730 is merged (due to the limited number of connections)
How to reproduce:
Details
Start a bitcoin node with
-rpcallowip=1.1.1.1 -rpcbind=<ip> -rpcservertimeout=30 -debug=httpeg:Run a timed netcat connection:
On master:
nc output:
bitcoind log:
This PR:
nc output:
bitcoind log: