Repository Public
1{2 "id": "QYV-SVC-008",3 "title": "Cold PSBT signing trusts the input amounts written in the PSBT when the device has no synchronized snapshot (BIP-143 fee attack)",4 "severity": "medium",5 "cvss_vector": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:N",6 "cvss_score": 5.3,7 "cwe": "CWE-345",8 "masvs": "MASVS-CRYPTO-1",9 "area": "wallet",10 "location": "Sources/QyvoraWallet/WalletService+Bitcoin.swift:782",11 "tool": "manual-review",12 "rule": "",13 "status": "fixed",14 "fix_commit": "8311bd8",15 "regression_test": "QyvoraWalletTests.PSBTAmountVerificationTests (amountsStatedOnlyByThePSBTAreReportedAndNeedAnExplicitConfirmation, theTwoRoundFeeAttackYieldsNoSignatureWithoutConfirmationAndIsCaughtWithPreviousTransactions, previousTransactionsOrASingleInputMakeTheAmountsVerified, coinsTheWalletReadItselfAreVerifiedAgainstItsSnapshot, exportAttachesPreviousTransactionsThatHashToTheOutpoint); MainnetPolicyTests.unverifiedAmountsAreNeverSignedOnUnauditedMainnet; BitcoinWalletTests.coldSigningRoundTripWithPSBT",16 "description": "Root cause: `signPSBT` fills `PSBT.SigningOptions.expectedUTXOs` only from `bitcoinSnapshot`. A cold device never synchronizes (cold mode refuses every request), so it has no snapshot, `requireNonWitnessUTXO` stays false, and the amounts of the wallet's own inputs are whatever PSBT_IN_WITNESS_UTXO says; `exportPSBT` only writes witness UTXOs. The fee shown by `reviewPSBT` and the fee ceilings (`bitcoinMaximumFee`, `bitcoinMaximumFeeRate`) are computed from these unverified amounts. A SegWit v0 signature commits to the amount of the input it signs, not to the other inputs: a compromised online companion can present the same transaction twice with a different input under-declared each time, collect one valid signature per round, and assemble a transaction whose real fee is the hidden difference. Impact: funds burned as miner fee without the user having seen the amount (theft requires a colluding miner); it needs the user to approve two signing requests for what looks like the same payment. This is the 2020 \"BIP-143 fee attack\" documented for hardware wallets. Bitcoin transaction security is unrelated to the post-quantum protection of local storage.",17 "recommendation": "Export side: attach PSBT_IN_NON_WITNESS_UTXO (the full previous transaction, fetched with `EsploraClient.transactionHex` and checked by `PSBT.setNonWitnessUTXO`) for every input in `exportPSBT`. Signing side: in `signPSBT`, for every input of this wallet require either a matching `expectedUTXOs` entry or a non-witness UTXO, and refuse otherwise (`options.requireNonWitnessUTXO = true` when no snapshot covers the input); state in the review that the amounts were verified. Add tests for the two-round attack. Until then, state the limit in the cold-signing screen.",18 "evidence": "",19 "fingerprint": "66a68172ffa1",20 "reported": "2026-12-04",21 "owner": "integrator",22 "fixed": "2026-12-04",23 "resolution_note": "Fixed: `reviewPSBT` reports `inputAmountsVerified`: true only when the transaction has a single input (its SegWit signature commits to its amount) or when every input carries its previous transaction (PSBT_IN_NON_WITNESS_UTXO, hashed to the outpoint by the parser and the signer) or is an output the wallet read itself (its snapshot). Otherwise the review carries a warning and the fee line is marked NOT VERIFIED, `signPSBT` refuses unless `acceptUnverifiedAmounts` is true (a separate toggle of the cold-signing screen), and on mainnet with an unaudited engine it refuses in every case: a hidden fee cannot be bounded by a ceiling on the fee the PSBT states. Export side: `exportPSBT` now attaches the previous transaction of every input, read from the Esplora endpoint and accepted only when it hashes to the outpoint and agrees with the witness UTXO (best effort: an input whose previous transaction cannot be read keeps its witness UTXO, and the cold device then says the amounts are unverified). Verification: package tests on M4M64c (Swift 6.3.3, release) and on the laptop (Swift 6.4, release); application target compiled for iphoneos on M3U96a (cold PSBT screen). Residual risk: A PSBT prepared by other software without previous transactions needs the explicit confirmation on a test network and is refused on unaudited mainnet. Previous transactions above 50 000 bytes are not attached by the export. All inputs are required to be verified, not only the wallet's own: an input presented as foreign could otherwise be one of the wallet's.",24 "verification": "package tests on M4M64c (Swift 6.3.3, release) and on the laptop (Swift 6.4, release); application target compiled for iphoneos on M3U96a (cold PSBT screen).",25 "residual_risk": "A PSBT prepared by other software without previous transactions needs the explicit confirmation on a test network and is refused on unaudited mainnet. Previous transactions above 50 000 bytes are not attached by the export. All inputs are required to be verified, not only the wallet's own: an input presented as foreign could otherwise be one of the wallet's."26}27