Repository navigation
Conversation
The external signer mock previously replayed a PSBT that the test prepared in advance. This makes it difficult to test more complicated scenarios like a misbehaving wallet and (MuSig2) multisig. Instead, give the mock its own descriptor wallet. The test provides a dedicated node for this wallet and keeps it offline, so the mock can't cheat by e.g. inspecting the UTXO set. The mock creates the wallet on first use and signs with walletprocesspsbt. wallet_signer.py now funds all four descriptor types and spends them in a single transaction, exercising every signing code path.
Co-authored-by: brunoerg <brunoely.gc@gmail.com>
Reject a signer response with a different PSBT version and report the expected and returned versions. Document the requirement and test a v0 response to a v2 request.
A signature with SIGHASH_NONE or SIGHASH_SINGLE doesn't commit to all outputs, letting anyone alter them after signing. Reject a PSBT from an external signer that declares such a sighash type or contains signatures made with one. SIGHASH_ANYONECANPAY is still accepted: it only permits adding inputs, which does not affect us. The mock signer produces real signatures for these scenarios by letting its wallet sign with the requested sighash type, optionally hiding the declared sighash type field so that only the signatures themselves reveal it. Co-authored-by: brunoerg <brunoely.gc@gmail.com>
Previously the PSBT returned by the external signer replaced the original wholesale, trusting the signer not to modify the transaction. Merge it instead. This rejects a response that describes a different transaction. Merging also supports signers that strip fields they don't need from their response. New tests cover both scenarios. Also test a signer that changes a PSBT v2 input sequence before signing. The transaction identifier used for merging ignores sequences, but the merge preserves the original sequence, leaving the signatures invalid for the wallet's transaction. This and a corrupted signature must leave the original transaction unchanged and return an incomplete PSBT. Test ECDSA and Schnorr signatures independently. Suggested in: bitcoin#36114 (comment) Co-authored-by: brunoerg <brunoely.gc@gmail.com>
Require signer responses to keep signatures in non-final fields and leave finalization to Bitcoin Core. Document the requirement in the signer API. Test final scriptSig and witness fields independently, including responses that finalize only one input.
This was referenced Oct 25, 2026
Add opt-in -signerantiexfil protection with Core-generated randomness, two signtx calls and provisional BIP-EXFIL PSBT fields. Validate immutable requests and raw transcripts before merging, and accept only independently verified key-path signatures. Never retry a failed exchange automatically with fresh entropy. Cover DEFAULT and ALL in PSBT v0/v2, two inputs, transcript removal, transaction preservation and fourteen malformed or dishonest signer cases.
Sjors
force-pushed
the
2026/10/taproot-anti-exfil
branch
from
October 25, 2026 07:26
7e79760 to
557eede
Compare
This was referenced Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add opt-in
-signerantiexfilprotection to external-signer wallets. Core generates an independent random scalar for each target input, sends its commitment to the signer, records the returned full nonce point, and reveals the scalar in a secondsigntxcall. It accepts a signature only after independently verifying BIP340 validity and the prescribed nonce relation.A valid transaction signature can still encode a secret through a maliciously selected nonce. Transaction integrity checks and mempool admission do not address that channel. This implements the single-signer additive protocol from the companion BIP draft, without changing transaction consensus rules or the on-chain format.
Stack and dependencies
This is stacked on the external-signer hardening work associated with bitcoin/bitcoin PR 36114, through iwyu: Fix warnings in
src/external_signer.cppand treat them as errors. When restacking, preserve the hardening dependency and replay only these five increments:aefields in global, input, and output maps regardless of the protection setting.Behavior and review details
Only unsigned single-signer Taproot key-path targets with DEFAULT or ALL are supported. Each target has its own entropy and nonce. Core freezes the complete unsigned transaction, including sequences, and the UTXOs and transcript. A PSBTv2 unique identifier alone is insufficient because it excludes sequences.
Raw responses are checked before PSBT merging can preserve Core's conflicting values or fill omissions. Early signatures, missing or changed fields, unexpected fields, finalized inputs, untargeted signatures, changed transactions or UTXOs, and invalid proofs fail. Core copies only verified signatures back into the caller's PSBT; nonce transcripts and other device-supplied metadata are discarded.
A fully signed but unfinalized PSBT succeeds on later wallet passes without starting a new session. Caller-provided
aefields are rejected because Core manages its own sessions and must not downgrade an explicit request through ordinary signing. Managed-session subprocess, JSON, and PSBT-parser errors cannot expose raw transcripts through RPC errors or routine debug logs.There is no automatic retry with fresh entropy. Failures after a commitment explain the selective-abort concern, including subprocess/JSON failures. Interrupted transcripts are not persisted across RPC calls or restart; automatic resumption would require retaining and reusing the exact tuple. A new user-initiated signing attempt is not a transparent protocol retry.
The experimental
aefields work with PSBTv0 and PSBTv2.BIP-EXFIL/hostandBIP-EXFIL/nonceremain placeholders; BIP assignment requires coordinated domain changes and regenerated vectors. MuSig2/FROST, script-path signing, ECDSA, and general sign-to-contract are outside this PR.Validation
key_testsandpsbt_tests: all 17 relevant cases passed.wallet_signer_anti_exfil.py: DEFAULT/ALL, PSBTv0/v2, two inputs, transaction preservation, transcript removal, fourteen dishonest/malformed/process-failure cases, eight transcript-error channels, twelve caller-field downgrade cases, unfinalized/repeated signing, and final broadcast/confirmation passed.wallet_signer.pyandrpc_signer.pypassed.fix_includes.py --nosafe_headers --dry_run; no edits remained. The corrected stack passed the preset rebuild, unit suites, include lint, and all three external-signer functional tests.These are local validation results. GitHub CI for the corrected pushed branch is still in progress; earlier Docker-layer download failures occurred before compilation.