bcli: return "not found" on any `getblockhash` exit status
What changed, and why it matters
This change alters how Core Lightning's bitcoin backend plugin reacts when the connected Bitcoin node cannot find a requested block by height. Previously, only one specific error code (8) was treated as 'block not found,' while any other failure caused Core Lightning to report a hard error and stop. Now, any non-zero failure from the 'getblockhash' command is treated as 'not found.' This makes the plugin more tolerant of Bitcoin node behavior differences, but could mask real backend problems such as network errors, authentication failures, or node crashes by silently treating them as missing blocks.
Review whether silently treating all getblockhash failures as 'not found' is safe for every failure mode. Consider logging the original exit status and error output for diagnostics, and ensure that transient backend errors (network, authentication, resource exhaustion) are retried or escalated rather than permanently treated as missing blocks. If this is a defensive hardening change, verify that downstream callers handle repeated 'not found' responses safely.
Security signals we found
Error-handling broadening masks non-missing-block failures
Any getblockhash non-zero exit status now treated as missing block
Potential for denial of service or synchronization stall if backend errors are silently swallowed
No explicit bounds, input, or cryptographic changes
Evidence from the diff
In plugins/bcli.c, getrawblockbyheight() previously checked whether res->exitstatus == 8 to decide whether a missing block height should return getrawblockbyheight_notfound(); any other non-zero exit status returned command_err(cmd, res, “command failed”). The patch removes the special-case check and returns getrawblockbyheight_notfound() for any non-zero exit status. This broadens the ‘not found’ handling to all getblockhash failures, which may hide transient or persistent backend errors from Core Lightning’s block synchronization logic.
Changed components
plugins/bcli.cgetrawblockbyheight()bitcoind getblockhash RPC handlingInspect captured patch +1 / −4
diff --git a/plugins/bcli.c b/plugins/bcli.c
index 4616c58b..b914714d 100644
--- a/plugins/bcli.c
+++ b/plugins/bcli.c
@@ -344,10 +344,7 @@ static struct command_result *getrawblockbyheight(struct command *cmd,
tal_fmt(tmpctx, "%u", *height), NULL);
if (res->exitstatus != 0) {
- /* Exit code 8 means block height doesn't exist (empty response) */
- if (res->exitstatus == 8)
- return getrawblockbyheight_notfound(cmd);
- return command_err(cmd, res, "command failed");
+ return getrawblockbyheight_notfound(cmd);
}
strip_trailing_whitespace(res->output, res->output_len);
Why this scored 45/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.