Review report

core: PR #10102

1 major finding · 7 minor findings · 1 suggestion

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

Findings

Link

[major] · CoinControl maximum depth is replaced by the minimum depth over IPC

A default CCoinControl arrives with a maximum depth of zero, preventing multiprocess GUI sends from using confirmed coins.

Location: src/ipc/capnp/wallet.cpp:196 (head).

Details and suggested fix

The builder writes m_min_depth to maxDepth, and the reader also fills m_max_depth from getMinDepth(). A default CCoinControl has a minimum depth of zero and a maximum depth of DEFAULT_MAX_DEPTH, so the wallet process receives m_max_depth == 0.

AvailableCoins skips outputs with nDepth > max_depth, making confirmed UTXOs ineligible. In multiprocess bitcoin-gui, prepareTransaction can pass its cached-balance check before createTransaction fails for insufficient funds or uses only unconfirmed trusted change. Other wallet calls that pass a CCoinControl, such as getAvailableBalance with selected coins, use the same incorrect bound. Funds are not affected.

Write m_max_depth when building the message and read getMaxDepth() on the other side. Add a round-trip test with unequal bounds.


Link

[minor] · Reading a WitnessUnknown destination throws

A payment containing a valid witness v2-or-higher output can make multiprocess GUI wallet-history reads fail for as long as the transaction remains in the wallet.

Location: src/ipc/capnp/wallet.cpp:137 (head).

Details and suggested fix

When the reader sees witnessUnknown, it calls std::get<WitnessUnknown>(dest) before decoding. The destination is freshly constructed, so std::get throws std::bad_variant_access. List elements are created with emplace_back(), and CRecipient::dest and CCoinControl::destChange default to CNoDestination.

This can happen when a GUI recipient or custom change address is a valid witness v2-or-higher address accepted by DecodeDestination. It can also happen when MakeWalletTx extracts destinations from every transaction output, including outputs the wallet does not own. A third party can pay the user in a transaction with such an output; afterward, getWalletTxs, getWalletTx, and getWalletTxDetails fail when reading that transaction. How bitcoin-gui surfaces the IPC exception was not traced.

Read into a temporary WitnessUnknown and assign it to dest, or emplace the variant alternative first. Add a round-trip test covering every CTxDestination alternative.


Link

[minor] · PayToAnchor destinations are not serialized

A P2A output in a wallet transaction can make transaction-history IPC calls fail, and P2A recipients cannot be serialized.

Location: src/ipc/capnp/wallet.cpp:113 (head).

Details and suggested fix

PayToAnchor is its own CTxDestination alternative, so std::get_if<WitnessUnknown> does not match it and the builder throws std::logic_error.

ExtractDestination returns PayToAnchor for anchor outputs, and MakeWalletTx extracts the destination of every output. A wallet transaction containing a P2A output, including one sent by a third party, can therefore no longer be serialized by getWalletTxs, getWalletTx, or getWalletTxDetails. A user-entered P2A address also fails in createTransaction because DecodeDestination returns PayToAnchor.

Add a representation for PayToAnchor. Alternatively, encode it as witnessUnknown and reconstruct PayToAnchor on read when the version and program match, preserving destination comparisons.


Link

[minor] · Restoring without loading aborts the reply-reading process

The GUI's “Restore and Migrate Wallet File” action can abort the process reading the reply instead of continuing to migration.

Location: src/ipc/capnp/common-types.h:371 (head).

Details and suggested fix

MigrateWalletActivity::restore_and_migrate calls restoreWallet with load_after_restore=false. RestoreWallet only loads the wallet when that flag is true, so it returns null with an empty error. WalletLoaderImpl::restoreWallet then returns a successful util::Result containing a null unique_ptr<Wallet>.

The util::Result builder passes the null pointer to the interface builder, which sets no value. The reader then reaches assert(result.hasValue()) and aborts; assertions are always enabled. bitcoin-node proxies the GUI's WalletLoader calls to bitcoin-wallet, so bitcoin-node is the most likely process to abort.

Have the reader construct an empty value when the field is unset and the value type is nullable.


Link

[minor] · An omitted address-book purpose is read as RECEIVE

Relabeling an existing sending contact during a GUI send silently reclassifies it as a receiving address in the wallet database.

Location: src/ipc/capnp/wallet.capnp:34 (head).

Details and suggested fix

The schema declares purpose :Int32 without a hasPurpose field, so mpgen does not mark it optional and StructField::has() returns true.

When WalletModel::sendCoins calls setAddressBook(dest, strLabel, {}) to change an existing contact's label without changing its purpose, the client leaves the field at zero. The server reads zero as AddressPurpose::RECEIVE and passes an engaged optional to SetAddressBookWithDB, which overwrites the record's purpose and writes it to the database. The contact then appears in the Receiving address list instead of the Sending list.

Add hasPurpose :Bool so the existing optional handling preserves std::nullopt.


Link

[minor] · IPC trace logging can record wallet passphrases

When IPC trace logging is enabled, passphrases sent through wallet RPCs or GUI wallet calls can appear in debug.log, unlike in regular RPC logs.

Location: src/ipc/capnp/chain.capnp:135 (head).

Details and suggested fix

Wallet RPCs served by the spawned wallet process are invoked through ActorCallback.call, which carries the full JSONRPCRequest, including params as JSON text.

libmultiprocess logs request.toString() on the client side and params.toString() on the server side at Log::Trace. Bitcoin Core enables that level when IPC trace logging is requested with -debug=ipc and -loglevel=ipc:trace. LogEscape escapes and truncates the text to 200 characters. A walletpassphrase, encryptwallet, or walletpassphrasechange call can therefore put a passphrase in debug.log; the regular RPC server logs only the method name. The GUI's Wallet.unlock and encryptWallet passphrase fields use the same logging path. Whether a particular secret appears depends on field order and the 200-character cutoff.

Skip or redact payload logging for secret-bearing methods, and add a check that passphrases never appear in IPC trace output.


Link

[minor] · SecureString passphrase copies in IPC buffers are not cleansed

Passphrases sent over IPC remain in ordinary, unlocked heap buffers because the IPC code does not perform the cleansing that its comments assign to callers.

Location: src/ipc/capnp/common-types.h:198 (head).

Details and suggested fix

The SecureString builder copies the passphrase into Cap'n Proto message storage, and the reader copies it back out. Both comments make memory_cleanse the caller's responsibility, but no IPC code calls it. The message buffers for encryptWallet, unlock, and changeWalletPassphrase are therefore released without being cleansed. In the wallet process, this bypasses SecureString's locked, cleanse-on-free allocator and leaves the passphrase exposed to swap, core dumps, or later memory disclosure. The GUI already copies passphrases through a plain std::string in AskPassphraseDialog, so the additional exposure is mainly in the IPC message buffers.

Whether residual passphrase copies in the wallet-process heap fall within the threat model for this mode remains an open question; exploiting them already requires access to process memory, swap, or core dumps. Cleanse request and response segments for secret-bearing methods after consumption, including on error paths.


Link

[minor] · CoinControl lock time, version, and weight limit are lost over IPC

The builder does not set the presence flags the reader checks, so these values revert to defaults; no current caller passing them over IPC was identified, leaving production impact unconfirmed.

Location: src/ipc/capnp/wallet.cpp:198 (head).

Details and suggested fix

The builder writes lockTime, version, and maxTxWeight but does not call setHasLockTime, setHasVersion, or setHasMaxTxWeight. The reader applies each value only when its has* field is nonzero, so the wallet process always sees m_locktime unset, m_version at DEFAULT_WALLET_TX_VERSION, and no weight cap. A caller requesting a TRUC (version 3) transaction, a specific lock time, or a weight limit therefore gets a transaction built without that option.

No current caller sending these values over IPC was identified: the GUI sets none of them, and wallet RPCs run inside the wallet process. The behavior change is established, but its production impact is unconfirmed.

Set each presence field when writing its value, and include these fields in a CCoinControl round-trip test.


Optional improvements

Link

[suggestion] · Spawn-only Init methods are also served to running-node socket clients

An -ipcbind client can call ReadGlobalArgs on a running bitcoin-node, replacing global chain parameters and rerunning logging setup; this affects robustness, not a privilege boundary.

Location: src/ipc/capnp/init.capnp:33 (head).

Details and suggested fix

-ipcbind serves the same Init object, which now exposes makeChain, makeNode, and makeWalletLoader. makeWalletLoader takes GlobalArgs, and CustomPassField runs ReadGlobalArgs before the method body, even though BitcoinNodeInit does not implement makeWalletLoader. On a running node, this overwrites gArgs, calls SelectParams to reassign globalChainParams and invalidate references previously taken from Params(), and reruns init_process (InitLogging and InitParameterInteraction).

The socket already grants unauthenticated RPC access, so this is not privilege escalation. A buggy or misconfigured client can nevertheless corrupt or crash a running node in ways RPC cannot. The -ipcconnect follow-ups may need makeNode on this socket, so which Init methods a running node should serve to socket clients remains an open question. At minimum, ReadGlobalArgs and init_process could refuse to run on a non-parent connection or after initialization.


Coverage details

Earlier concerns

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