Audit report AR-26

Reported privately in an independent security review, 2026-08-26.

Report date
2026-08-26
Kind
API
Status on master
Present
Proposed issue state
Open

Summary

BlockTemplate::submitSolution returns false early when no coinbase is given, without touching its reason and debug output strings, so an in-process caller that reuses those strings sees text from an earlier call. IPC callers get fresh strings and are not affected. The report is accurate. Minor wrong-result fix for direct C++ callers, mergeable.

The report

submitSolution(version, timestamp, nonce, coinbase, reason, debug) fills reason and debug on the normal submission path, but the missing-coinbase check returns before assigning them. A caller that passes strings already holding text from an earlier failure gets that stale text back with the new failure.

The report requires a direct C++ caller that reuses output strings on the missing-coinbase path. It found no in-tree production caller that does, notes that IPC delivers fresh output values at that boundary, and shows no effect on node availability, funds, consensus or persistent state.

The reproduction is a Boost unit test added to src/test/miner_tests.cpp against the real node code. It calls submitSolution with a null coinbase and pre-filled strings, and checks that both are empty afterwards.

Proposed change

Clear both strings before the early return, and document it in the interface:

     bool submitSolution(uint32_t version, uint32_t timestamp, uint32_t nonce, CTransactionRef coinbase, std::string& reason, std::string& debug) override
     {
-        if (!coinbase) return false;
+        if (!coinbase) {
+            reason.clear();
+            debug.clear();
+            return false;
+        }

In src/interfaces/mining.h the @param[out] docs for reason and debug gain "cleared if coinbase is null".

Assessment

Present on Bitcoin Core master (if (!coinbase) return false; in BlockTemplateImpl::submitSolution). Over IPC the output parameters are new strings on the server side for every call, so an IPC client always sees empty strings on this path. Only in-process callers that reuse strings are affected, and none in the tree does. No stability effect; outside the survey's scope.

Status

Present on master. Next step: a small Bitcoin Core PR with the change and test. No public PR yet.

Reported privately in an independent security review on 2026-08-26.