rpc: Report -rpcwhitelist denials as JSON-RPC errors

bitcoin/bitcoin: PR #36753

4 suggestions

Earlier concerns neither republished nor resolved: 1 minor finding. See the Run archive for their assessments.

Optional improvements

Link

[suggestion] · Release note omits execution and notification compatibility changes

The note omits that permitted calls can now run beside certain malformed batch elements, default-denied users receive different malformed-request replies, and refused JSON-RPC 2.0 notifications lose their HTTP refusal signal.

Location: doc/release-notes-36753.md:4 (head).

Details and suggested fix

Please add these cases to the release note and compatibility section:

  • For users with a whitelist, a non-object batch element or a missing/non-string method previously stopped the whole batch before execution. The authorization pass now skips these elements. If no method is denied, permitted calls run and malformed elements receive individual errors. Parsing still prevents the malformed elements from executing.
  • With -rpcwhitelistdefault=1, users without a whitelist previously received an empty 403 before RPC parsing. Syntactically valid JSON with an invalid RPC shape now receives the usual RPC parsing errors, and [] receives HTTP 200 with []. Invalid JSON text already received a parse error before this change.
  • Refused JSON-RPC 2.0 notifications now receive HTTP 204 with no body instead of 403. This follows the documented notification rule, but senders can no longer distinguish refusal from execution, and there is no error code for them to inspect.

Link

[suggestion] · Refused-batch tests omit notifications

The tests do not check that a denied notification blocks the whole batch, that refused replies omit notifications, or that an all-notification refused batch returns 204.

Location: test/functional/rpc_whitelist.py:205 (head).

Details and suggested fix

Every refused-batch case supplies ids or uses legacy requests, which are not notifications. Extend the existing no-effect test with a JSON-RPC 2.0 batch containing permitted setnetworkactive(false) with id 0 and a denied getbestblockhash notification. Expect only the -39 reply for id 0 and assert that networkactive remains true. Then omit both ids and expect HTTP 204, an empty body, and unchanged state. These cases would catch preauthorization incorrectly skipping notifications or refused-path reply handling diverging from notification rules. interface_rpc.py already covers the shared 204 branch without a whitelist; the missing coverage is the refused path.


Link

[suggestion] · The series introduces a batch reply format only to replace it

2badf99 introduces and tests a single-object refused-batch reply that 711222b immediately replaces; retaining the empty 403 until the batch commit would avoid temporary behavior and repeated test edits without changing head.

Location: src/httprpc.cpp:222 at 2badf997447a (commit) (commit).

Details and suggested fix

In 2badf997447a7cac8ba007941545008b1867c82f, the batch denial throws -38 through JSONErrorReply with an unparsed jreq, producing HTTP 403 and one error object with id: null. Its tests assert that format, while -getinfo still expects a transport error. 711222b96fddcf0f5d86e7f4ee3a45942666bbf2 then replaces it with HTTP 200 and per-request -38/-39 entries and rewrites those assertions. This makes reviewers assess an intermediate format absent from the final tree.

Keep WhitelistDenial and the || g_rpc_whitelist_default condition in the first commit, but retain status = HTTP_FORBIDDEN; return {}; for batch denials and leave their expectations at (403, None). The second commit would then show the complete batch-format change with its tests and release note. This preserves the separate singleton fix and authorization checks; no intermediate caller depends on the single-object format, and head would remain unchanged.


Link

[suggestion] · Release note omits the broader -generate error-reporting fix

The note omits that -generate now reports any generatetoaddress error reply and exits nonzero rather than printing null blocks and succeeding; practical non-whitelist occurrences remain unconfirmed.

Location: doc/release-notes-36753.md:12 (head).

Details and suggested fix

After getnewaddress succeeds, GenerateToAddressRequestHandler::ProcessReply now forwards any error from the second RPC instead of constructing a success reply with "blocks": null. CommandLineRPC consequently prints the error and returns abs(code), which changes what scripts checking -generate's exit status observe. Add a short CLI release-note line describing that general correction, rather than only permission-error reporting. No common non-whitelist case where generatetoaddress fails after getnewaddress succeeds was identified.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.