Repository Public
1{2 "schema": "qyvora-review/1",3 "title": "Multi-chain upgrade — entry points brought by the merge of main (4ac4e69): fee quotes, hidden tokens, sweep of exposed coins and persisted synchronization of Litecoin / Dogecoin / Bitcoin Cash, cold-review tokens, acceptUnverifiedAmounts, Shield entries",4 "reviewed_revision_base": "08b6c46",5 "reviewed_diff": "git diff 0a55e0e 4ac4e69 -- Sources (20 files, +1207 −105)",6 "reviewer": "area agent new-entry-points (internal audit, not an independent review)",7 "date": "2026-12-05",8 "method": "Line-by-line reading of every line changed by the merge in Sources/ (WalletService+FeeQuote, +HiddenTokens, +UTXOCoins, +Cold, +Send, +Solana, +Tron, +Shield, +Chains, WalletService, ChainPersistence, ChainRegistry+Keys, Chains, QyvoraQuantumShield/ShieldReport, QyvoraMigration, QyvoraCrypto self-test, QyvoraTron/TronClient, QyvoraCore/Networks, QyvoraRecovery/RecoverySheet, QyvoraUI/Chains), with the functions they call where a rule depends on them (signPSBT, validateCoinPlan, signAndBroadcastCoin, assembleUTXOCoin, evmToken, the align functions). Each rule verified by a regression test on scripted backends (mainnet tests in the serialized MainnetPolicy suite), property campaigns on the real loader, and two fuzz targets. No live network, no real funds.",9 "limits": "App/Sources was not reviewed (being rebuilt): interface duties are recorded in QYV-APP-100. QyvoraUI/Chains.swift (display names) was read, not tested. Bitcoin's own 1.0 sweep and the protocol modules were reviewed by other areas. The Ed25519 self-test vector was compared with RFC 8032 by transcription; the behaviour of the application on a failing self-test was not exercised.",10 "entries": [11 {12 "construct": "feeQuote(chain:asset:) — gate and activity",13 "location": "Sources/QyvoraWallet/WalletService+FeeQuote.swift:121",14 "verdict": "safe",15 "note": "Goes through activeKind → requireAllowed(kind): a main network without the opt-in answers mainnetDisabled before any request; an inactive chain answers chainNotActive; a UTXO chain is refused (its fee depends on the coins). Each family then goes through verifiedRPC / verifiedSolana / verifiedTron (gate again, offline refusal in cold mode, chain-identity check before any figure is used). No secret, no vault access: works locked, on public profile data. Test: feeQuoteIsBehindTheMainnetGateAndSilentInColdMode."16 },17 {18 "construct": "evmFeeQuote — gas estimate bounds",19 "location": "Sources/QyvoraWallet/WalletService+FeeQuote.swift:143",20 "verdict": "safe",21 "note": "The node's estimate is bounded to 21 000…30 000 000 before `estimate * 13 / 10 + 5_000` (no overflow possible), then by ethereumGasLimitCeiling."22 },23 {24 "construct": "evmFeeQuote — fee arithmetic",25 "location": "Sources/QyvoraWallet/WalletService+FeeQuote.swift:194",26 "verdict": "safe",27 "note": "Every product and sum on endpoint figures uses the overflow-reporting forms on UInt256; EVMFeeRules.gasFees (same rule as prepareSend) refuses out-of-range fees. A quote is not bounded by the fee ceilings of an unaudited build: it is an estimate (isEstimate), and prepareSend applies the ceilings to the payment actually built. Test: feeQuoteSurvivesHostileFigures (base fee / tip up to 2^256-1, raw hostile answers of six RPC methods)."28 },29 {30 "construct": "evmFeeQuote — token",31 "location": "Sources/QyvoraWallet/WalletService+FeeQuote.swift:159",32 "verdict": "safe",33 "note": "The token is resolved through the wallet's list (evmToken, QYV-SVC-084 rule): a detected token of a restored snapshot is refused; the estimate is an eth_estimateGas of a zero transfer to the account itself: nothing is signed, nothing is broadcast."34 },35 {36 "construct": "solanaFeeQuote — tiers",37 "location": "Sources/QyvoraWallet/WalletService+FeeQuote.swift:224",38 "verdict": "safe",39 "note": "Same rule as prepareSolanaSend; the doubling is overflow-checked, the price is capped by SolanaFees.maximumUnitPrice, the priority fee by SolanaComputeBudget.priorityFee (nil on overflow). A failing getRecentPrioritizationFees gives the floor price (try?). Test: feeQuoteSurvivesHostileFigures (fees up to 2^64-1: the quote stays under the wallet's own bound)."40 },41 {42 "construct": "solanaFeeQuote — token symbol in the basis sentence",43 "location": "Sources/QyvoraWallet/WalletService+FeeQuote.swift:212",44 "verdict": "note",45 "note": "The sentence names the token with the caller's symbol (the payment path resolves it since QYV-SVC-103). Display of an estimate only.",46 "finding_id": "QYV-SVC-103"47 },48 {49 "construct": "tronFeeQuote — arithmetic on chain parameters",50 "location": "Sources/QyvoraWallet/WalletService+FeeQuote.swift:260",51 "verdict": "safe",52 "note": "Bandwidth price × size and the sum of the two activation fees are overflow-checked (untrustedResponse otherwise); the timestamp conversion clamps at zero; the draft is a transfer of 1 TRX to a fixed placeholder address built only to measure its size — it is never signed, exported or broadcast. Test: feeQuoteSurvivesHostileFigures (parameters and resources at 2^63-1, 2^64-1, 2^64, negative, non-numeric)."53 },54 {55 "construct": "feeQuote vs prepareSend",56 "location": "Sources/QyvoraWallet/WalletService+FeeQuote.swift:53",57 "verdict": "safe",58 "note": "A quote can differ from the review (fees move; a token transfer to a new holder costs more gas; a TRON recipient may need activation). Nothing is enforced from a quote: prepareSend reads everything again and applies limits and ceilings. Existing tests (SendPreviewTests) check equality on a quiet model."59 },60 {61 "construct": "hiddenTokens(chain:)",62 "location": "Sources/QyvoraWallet/WalletService+HiddenTokens.swift:82",63 "verdict": "safe",64 "note": "Reads the profile only; no network, no secret. Entries are matched by the chain's prefix with its colon, so an entry belongs to one chain; a known token is described from the wallet's own list, an unknown one as a bare address. `hidden.contains(key)` is a linear scan per known token (tens of tokens): bounded by the profile file size. Duplicated entries of a hostile profile give duplicated bare addresses (same Identifiable id) — display only. Property: aHostileHiddenListIsListedWithinBoundsAndShowingATokenChangesNoList; fuzz target hidden-tokens."65 },66 {67 "construct": "showHiddenToken(_:)",68 "location": "Sources/QyvoraWallet/WalletService+HiddenTokens.swift:110",69 "verdict": "safe",70 "note": "Uses the chain and the address of the value only; `hidden.token` (public initializer: any symbol, decimals, standard) is ignored. It removes that one key from the hidden list and aligns the snapshot: a listed token returns with the list's description; a token hidden from the detected list does not enter any list — it reappears as detected only when a synchronization of this session finds it (the align functions only filter the detected list). It cannot lift the quarantine of QYV-SVC-084. Test: showingAHiddenTokenAgainChangesNoPaymentMetadata."71 },72 {73 "construct": "acceptDetectedToken (EVM 1.0 call; Solana and TRON uniform call)",74 "location": "Sources/QyvoraWallet/WalletService+Ethereum.swift:455",75 "verdict": "fixed",76 "note": "Was the way around QYV-SVC-084: a detected token of a restored file entered the list with the file's symbol and decimals. Now refused until a synchronization of this session.",77 "finding_id": "QYV-SVC-102"78 },79 {80 "construct": "prepareTronSend / prepareSolanaSend — token description",81 "location": "Sources/QyvoraWallet/WalletService+Send.swift:402",82 "verdict": "fixed",83 "note": "The review showed the caller's symbol and decimals (TRON) or symbol (Solana). The token is now resolved to the wallet's own description, as on EVM.",84 "finding_id": "QYV-SVC-103"85 },86 {87 "construct": "prepareSweepOfExposed(chain:) — routing and gate",88 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:840",89 "verdict": "safe",90 "note": "Bitcoin: only the active primary network, then the 1.0 sweep. Other coins: the chain must be active (activeKinds never returns a main network without the opt-in), the rotation capability enabled, and the snapshot fresh (freshCoinSnapshot refuses a restored one). No network except the price behind the limit."91 },92 {93 "construct": "prepareSweepOfExposed — destination",94 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:862",95 "verdict": "safe",96 "note": "The destination is computed by the service: one past the highest used index of the internal chain, derived from the account key of the profile; the caller passes a chain and a fee rate only. The used indices come from the profile file: a hostile value made the index arithmetic trap (QYV-SVC-104, fixed: bounded at decode, checked in the account); whatever the index, the address is the account's own. The plan type has no public initializer."97 },98 {99 "construct": "prepareSweepOfExposed — coins",100 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:864",101 "verdict": "safe",102 "note": "Only the exposed, unfrozen, not locally spent outputs of the fresh snapshot; send-max, so no change output exists: the whole amount is `paidAmount` for the ceilings."103 },104 {105 "construct": "prepareCoinSend — limits at prepare (sweep included)",106 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:778",107 "verdict": "safe",108 "note": "A sweep goes through the same call as a payment: value ceiling (150 USD at a fresh, floor-checked price: QYV-SVC-082), absolute fee and fee-rate ceilings; the fee-rate bound of the build is checked before the plan is built. Test: aSweepObeysTheCeilingsAndPaysOnlyTheWalletOnEveryCoin (prepare refused above the ceiling on Litecoin, Dogecoin, Bitcoin Cash)."109 },110 {111 "construct": "prepareCoinSend — warnings of a sweep",112 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:797",113 "verdict": "safe",114 "note": "A sweep drops the destination, exposed-inputs and fee-share warnings (they describe a payment to someone); unauditedMainnet, high absolute fee, unconfirmed inputs and merged addresses stay. The Bitcoin Cash fork-replay warning (QYV-APP-062) is added by prepareSend only, not for a sweep: replayed on eCash / Bitcoin SV a sweep pays the same key of the same wallet (no loss of coins, the fee is spent on both chains) — recorded in QYV-APP-100."115 },116 {117 "construct": "validateCoinPlan — limits at sign, send-max path",118 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:918",119 "verdict": "safe",120 "note": "Applied to what the transaction pays, not to plan.amount: a send-max plan has no change index, so its whole output counts; inputs must be the fresh snapshot's coins with the same value and script, amounts must add up to the stated fee; the change output must be a script of the account's change chain (QYV-SVC-063). `&+` cannot wrap: outputValue(maximumMoney:) bounded the sum just above. Test: a sweep above the ceiling with a small declared amount, and one with a fee above the ceiling, are refused at sign on the three coins."121 },122 {123 "construct": "validateCoinPlan — a sweep pays the wallet",124 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:909",125 "verdict": "fixed",126 "note": "Nothing checked that a plan presented as a sweep returns to the wallet (defence in depth: no public interface builds such a plan).",127 "finding_id": "QYV-SVC-101"128 },129 {130 "construct": "signAndBroadcastCoin — previous transactions (Dogecoin)",131 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:966",132 "verdict": "safe",133 "note": "A sweep is signed by the same function as a payment: the coins of a Dogecoin plan are authenticated against raw previous transactions that must hash to their identifier (QYV-SVC-064); the vault's account must be the profile's; signatures are verified; the signed transaction must equal the reviewed one. Test: aDogecoinSweepChecksItsCoinsAgainstTheirPreviousTransactions."134 },135 {136 "construct": "UTXOCoinSyncRecord — persisted synchronization of a coin",137 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:83",138 "verdict": "safe",139 "note": "Public chain data only (addresses, transactions, coins; no key). Holds what the indexer said, not the snapshot: at restore the snapshot is rebuilt through assembleUTXOCoin, the validation of a synchronization. Written through SyncStore with a 24 MiB cap."140 },141 {142 "construct": "utxoCoinIdentity — what a record belongs to",143 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:153",144 "verdict": "safe",145 "note": "Network, account key and the three indexer lists of the network. Not a secret and not a MAC: whoever can write the file can compute it (the record is then validated like an indexer answer and never spent from). Changing endpoints or account removes the record (updateProfile), as does a wallet removal."146 },147 {148 "construct": "restoredUTXOCoin — loader of the hostile file",149 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:196",150 "verdict": "safe",151 "note": "Size-capped read; version, identity, network, tip < 10^8, notes ≤ 50; at most 2 × maximumScanIndex entries, each position < maximumScanIndex and each address derived again from the account and compared; then the full validation of a synchronization (transactions bounded and consistent, coins cross-checked with the history, sums within the monetary range). Not restored on a main network without the opt-in. Anything else is removed from disk. No force-unwrap, no unchecked index, no unchecked arithmetic on record figures found. Tests: hostileCoinRecordsAreRefusedOrBoundedAndNeverTrap; property forgedCoinRecordsAreRefusedOrFlaggedAndBounded; fuzz target utxo-coin-snapshot."152 },153 {154 "construct": "restoredUTXOCoin — paid scripts",155 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:213",156 "verdict": "fixed",157 "note": "The record's paid scripts stayed in the session after a synchronization and silenced the first-payment warning.",158 "finding_id": "QYV-SVC-100"159 },160 {161 "construct": "freshCoinSnapshot — a restored snapshot is never spent from",162 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:738",163 "verdict": "safe",164 "note": "The single gate of prepareCoinSend, prepareSweepOfExposed, validateCoinPlan (sign) and trackCoin: a snapshot flagged as the previous session's answers notSynchronized. The flag is set by the loader, not read from the file. Same rule as Bitcoin's requireFresh. Tests: aForgedCoinRecordNeverReachesASignature (prepare, sweep, a plan of the previous session and a plan built over the forged coins: nothing signed, nothing broadcast); property aRestoredCoinRecordIsNeverSpentFrom."165 },166 {167 "construct": "synchronization — record written, state replaced",168 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:382",169 "verdict": "safe",170 "note": "A synchronization reads everything again (no incremental reuse of the record) and replaces the snapshot; the record is rewritten from the scans. usedReceiveIndices / usedChangeIndices of the profile are updated from the fresh scan only, never from a restored record."171 },172 {173 "construct": "ChainPersistence — removal and restore of coin records",174 "location": "Sources/QyvoraWallet/ChainPersistence.swift:309",175 "verdict": "safe",176 "note": "Records of every coin network are removed with the wallet; a chain that becomes active is restored through the same loader (alignWithActiveChains)."177 },178 {179 "construct": "setEnabledChains — watch-only skip rule",180 "location": "Sources/QyvoraWallet/WalletService+Chains.swift:191",181 "verdict": "safe",182 "note": "On a watch-only wallet the chains without an account are left out and returned; the call fails when none of the wanted chains has an account. It only narrows the list: applyEnabledChains (unchanged) still decides; nothing is enabled without an account, and a main network still needs the gate (activeKinds). A full wallet is not concerned."183 },184 {185 "construct": "ChainSyncResult public initializer",186 "location": "Sources/QyvoraWallet/WalletService+Chains.swift:76",187 "verdict": "safe",188 "note": "A value type for the interface; the service never reads one back."189 },190 {191 "construct": "limitSentences / ChainRegistry.previewLimits",192 "location": "Sources/QyvoraWallet/ChainRegistry+Keys.swift:118",193 "verdict": "safe",194 "note": "Sentences built from MainnetPolicy.limits for display before the opt-in; `limits(_:)` keeps its condition (main network, unaudited build). No figure is enforced from these sentences."195 },196 {197 "construct": "ChainRegistry+Keys — descriptor helpers",198 "location": "Sources/QyvoraWallet/ChainRegistry+Keys.swift:78",199 "verdict": "safe",200 "note": "Pure lookups between a descriptor and the module's network value; an unknown identifier of a recovery sheet gives nil (chainDescriptor)."201 },202 {203 "construct": "Chains.swift — signatureScheme wording, shortName",204 "location": "Sources/QyvoraWallet/Chains.swift:397",205 "verdict": "safe",206 "note": "Display strings only; BitcoinNetwork.shortName (QyvoraCore/Networks.swift) drops the coin's name by prefix, without indexing."207 },208 {209 "construct": "ColdTransactionReview.knownTokens (Solana)",210 "location": "Sources/QyvoraWallet/WalletService+Cold.swift:145",211 "verdict": "safe",212 "note": "Tokens come from the wallet's own list (built-in or custom), matched by mint; a list entry whose decimals disagree with the instruction (which the token program enforces) is not used. Never from the transaction or the network; an unknown token stays in base units."213 },214 {215 "construct": "ColdTransactionReview.knownTokens (TRON)",216 "location": "Sources/QyvoraWallet/WalletService+Cold.swift:193",217 "verdict": "safe",218 "note": "From the wallet's list by contract address. A TRC-20 transfer states no decimals: the summary uses the list's (custom tokens: read on chain when added, QYV-SVC-014 class). Display only; the bytes signed are the decoded transaction's."219 },220 {221 "construct": "signColdTransaction(acceptUnverifiedAmounts:)",222 "location": "Sources/QyvoraWallet/WalletService+Cold.swift:272",223 "verdict": "safe",224 "note": "The flag is passed to signPSBT and to nothing else (EVM, Solana, TRON branches ignore it). In signPSBT it lifts exactly one refusal — signing when amounts are stated by the PSBT alone (SegWit inputs without previous transaction, two inputs or more) — and only off an unaudited mainnet build, where the refusal is unconditional. The value ceiling, the fee ceilings of the build and the wallet's absolute fee bounds are applied after it, whatever its value; an unknown fee is always refused; signPSBT serves the primary Bitcoin network only (BIP-143: each signature commits to the amount of its own input), so the amount authentication of QYV-SVC-064 for Dogecoin / Bitcoin Cash / BIP-44 is not reachable through it (those coins have no cold signing). Who sets it: the caller (the interface) — it must come from a separate confirmation (QYV-APP-100). Tests: acceptUnverifiedAmountsLiftsNoLimit, acceptUnverifiedAmountsKeepsTheFeeBoundOnATestNetwork."225 },226 {227 "construct": "SendReview.expiresAt on Solana",228 "location": "Sources/QyvoraWallet/WalletService+Solana.swift:486",229 "verdict": "safe",230 "note": "An estimate from the device clock (60 s) for the interface; validity is decided by the chain (lastValidBlockHeight), and signing checks the blockhash again (QYV-SVC-022 path unchanged). Nothing is enforced from this date."231 },232 {233 "construct": "TRON outgoing probe (only_from)",234 "location": "Sources/QyvoraWallet/WalletService+Tron.swift:258",235 "verdict": "safe",236 "note": "One bounded request (5 entries) when the history page shows nothing sent and the index has more. The index is not trusted to have filtered: an entry counts only when its `from` is the account and its raw bytes hash to its identifier (TronClient.transactions). A lying index can at most claim \"nothing sent\" with an empty page, turning an unknown exposure into \"not exposed\" in the Shield (display; one endpoint: same class as QYV-APP-061)."237 },238 {239 "construct": "TronClient.query(onlyFrom:)",240 "location": "Sources/QyvoraTron/TronClient.swift:780",241 "verdict": "safe",242 "note": "A constant query item; the fingerprint stays validated; nothing of the caller's text enters the URL."243 },244 {245 "construct": "shieldReport — per-network entries and EVM approvals",246 "location": "Sources/QyvoraWallet/WalletService+Shield.swift:226",247 "verdict": "safe",248 "note": "Display data built from snapshots already validated at restore or synchronization; a restored coin snapshot marks the report as resting on the previous session. No index arithmetic on snapshot content; `networks[0]` is read right after an insert at 0. Nothing here signs or builds a transaction."249 },250 {251 "construct": "ShieldReport — NetworkApprovals, Chain.kind, CoinFigures",252 "location": "Sources/QyvoraQuantumShield/ShieldReport.swift:431",253 "verdict": "safe",254 "note": "Pure value transformations; counts are sums of array sizes; finding identifiers by kind are unchanged. No trap found on empty or large inputs."255 },256 {257 "construct": "MigrationPlan.CoinExposure and sweep steps",258 "location": "Sources/QyvoraMigration/Migration.swift:295",259 "verdict": "safe",260 "note": "Adds one actionable step per coin with exposed outputs; the three rotation capabilities are now `available`, which is what prepareSweepOfExposed requires (isMigrationEnabled)."261 },262 {263 "construct": "QyvoraEngine.selfTest — Ed25519",264 "location": "Sources/QyvoraCrypto/QyvoraCrypto.swift:154",265 "verdict": "safe",266 "note": "Seed, public key and signature are TEST 1 of RFC 8032 section 7.1 (empty message), transcribed and compared by the reviewer; the self-test also verifies the signature and refuses it for another message. A wrong result returns false like every other primitive of the same function: the application's start-up check (AppModel, selfTestRun) is the single consumer — App/Sources not reviewed here."267 },268 {269 "construct": "QyvoraEngine.algorithms — Ed25519 and X25519 entries",270 "location": "Sources/QyvoraCrypto/QyvoraCrypto.swift:88",271 "verdict": "safe",272 "note": "Catalogue text. X25519 is named as the system's implementation and excluded from `engineAlgorithms`; Ed25519 is stated as not quantum-resistant: consistent with the positioning rule."273 },274 {275 "construct": "RecoverySheet.ChainAccount.chainID",276 "location": "Sources/QyvoraRecovery/RecoverySheet.swift:118",277 "verdict": "safe",278 "note": "An optional registry identifier next to the display name; absent in older sheets (decodes as nil)."279 },280 {281 "construct": "Used address indices of the profile (destination of a sweep, change, receive address, PSBT search window)",282 "location": "Sources/QyvoraBitcoin/Account.swift:244",283 "verdict": "fixed",284 "note": "Unchecked UInt32 additions on indices read from the unauthenticated profile file: a trap, or an unbounded key search in the PSBT review. Bounded at decode and checked in the account.",285 "finding_id": "QYV-SVC-104"286 },287 {288 "construct": "WalletProfile decoding — used indices",289 "location": "Sources/QyvoraWallet/WalletTypes.swift:325",290 "verdict": "fixed",291 "note": "Indices above the bound are dropped when the profile is read.",292 "finding_id": "QYV-SVC-104"293 },294 {295 "construct": "BitcoinNetwork.shortName",296 "location": "Sources/QyvoraCore/Networks.swift:115",297 "verdict": "safe",298 "note": "String prefix removal guarded by hasPrefix."299 }300 ],301 "endpoint_impact": [302 {303 "capability": "Answer hostile fee figures to feeQuote (base fee, tip, gas estimate, L1 fee, prioritization fees, TRON parameters and resources)",304 "what_the_wallet_does": "Bounds the gas estimate, overflow-checks every product and sum, caps Solana's unit price, and answers an error otherwise.",305 "impact": "A misleading estimate on the form, or no estimate. Nothing is signed from a quote; the review of prepareSend reads everything again and applies the ceilings.",306 "mitigation": "Sources/QyvoraWallet/WalletService+FeeQuote.swift:194",307 "residual_risk": "The estimate rests on one endpoint per family (first answering); it is labelled as an estimate."308 },309 {310 "capability": "The coin indexer misstates an exposed coin so that a sweep burns the difference as fee (Dogecoin)",311 "what_the_wallet_does": "Reads the raw previous transactions, requires them to hash to the coin's identifier, and refuses to sign when the amount differs.",312 "impact": "None: nothing is signed. On Litecoin and Bitcoin Cash the signature commits to the amount: the transaction is invalid.",313 "mitigation": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:966",314 "residual_risk": "Which coins exist and which are exposed rests on one indexer (QYV-APP-061): it can hide exposed coins from a sweep or show coins that do not exist (then nothing valid is signed)."315 },316 {317 "capability": "The price source answers a price far from the truth while a sweep is prepared on a main network",318 "what_the_wallet_does": "Converts the 150 USD ceiling with a fresh price that must be above the plausibility floor of the coin (QYV-SVC-082), at prepare and at sign.",319 "impact": "A sweep refused (price too high) or a ceiling loosened up to the floor's ratio; the sweep pays the wallet's own address in any case.",320 "mitigation": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:714",321 "residual_risk": "One price source (QYV-SVC-082 residual)."322 },323 {324 "capability": "The TRON history index ignores or abuses the only_from filter",325 "what_the_wallet_does": "Counts an entry only when its raw bytes hash to its identifier and its sender is the account; an empty complete answer is taken as \"nothing sent\".",326 "impact": "The Shield can show a TRON account as not exposed when it is (display).",327 "mitigation": "Sources/QyvoraWallet/WalletService+Tron.swift:259",328 "residual_risk": "One index decides that display (same class as QYV-APP-061)."329 },330 {331 "capability": "(Not an endpoint: local write access to the application container) Forge utxo-sync-<network>.json",332 "what_the_wallet_does": "Validates it like an indexer answer against the account's own addresses, shows it flagged as the previous session's, never prepares or signs from it, and replaces it at the first synchronization.",333 "impact": "A false balance and history displayed until the next synchronization, labelled as the previous session's.",334 "mitigation": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:738",335 "residual_risk": "The file is not authenticated (as the other persisted snapshots: QYV-SVC-011 class)."336 }337 ],338 "replay_protection": {339 "statement": "The entry points reviewed here add no signing path of their own. A sweep of Litecoin, Dogecoin or Bitcoin Cash is signed by signAndBroadcastCoin like a payment: Litecoin under BIP-143 with Litecoin's address encodings, Dogecoin under the original digest with previous-transaction authentication, Bitcoin Cash with SIGHASH_FORKID (fork id 0). Replay between the coins is excluded as for payments (reviewed in multichain-utxo.json).",340 "residual_risks": [341 "A Bitcoin Cash sweep whose coins all predate the eCash or Bitcoin SV split is valid on those chains too (QYV-APP-062). For a sweep the replay pays the same key of the same wallet: no coin is lost, the fee is spent on both chains. The review of a sweep does not carry the fork-replay warning (QYV-APP-100).",342 "signColdTransaction(acceptUnverifiedAmounts:) concerns Bitcoin PSBTs only; replay protection of a PSBT is Bitcoin's (reviewed in the UTXO and Bitcoin registers)."343 ]344 },345 "mainnet_gate": {346 "rule": "Unchanged: a main network needs MainnetPolicy.mainnetEnabled. Every new public entry point reaches requireAllowed or activeKinds before any request or plan.",347 "entry_points": [348 {349 "entry": "feeQuote(chain:asset:)",350 "check": "activeKind → requireAllowed(kind); then verifiedRPC / verifiedSolana / verifiedTron",351 "evidence": {352 "ref": "Sources/QyvoraWallet/WalletService+FeeQuote.swift:121",353 "contains": "let kind = try activeKind(id)"354 }355 },356 {357 "entry": "prepareSweepOfExposed(chain:feeRate:)",358 "check": "activeKinds(profile) contains the kind (never a main network without the opt-in); limits at prepare and at sign",359 "evidence": {360 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:300",361 "contains": "guard Self.activeKinds(profile).contains(kind) else { throw WalletError.chainNotActive(network.displayName) }"362 }363 },364 {365 "entry": "restoredUTXOCoin (launch)",366 "check": "a record of a main network is not restored without the opt-in",367 "evidence": {368 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:199",369 "contains": "guard let identity = utxoCoinIdentity(profile, network: network), MainnetPolicy.mainnetEnabled || network.isTest,"370 }371 },372 {373 "entry": "signColdTransaction(acceptUnverifiedAmounts:)",374 "check": "signPSBT: unverified amounts always refused on an unaudited mainnet build; value and fee ceilings applied after the flag",375 "evidence": {376 "ref": "Sources/QyvoraWallet/WalletService+Bitcoin.swift:1031",377 "contains": "if account.network == .mainnet, MainnetPolicy.unauditedMainnet {"378 }379 },380 {381 "entry": "hiddenTokens(chain:), showHiddenToken(_:)",382 "check": "no network and no signature: profile only (no gate needed)",383 "evidence": {384 "ref": "Sources/QyvoraWallet/WalletService+HiddenTokens.swift:111",385 "contains": "guard profile.hiddenTokens.contains(key) else { return }"386 }387 }388 ]389 },390 "wallet_audit_items": [391 {392 "id": "WA-NEW-01",393 "title": "Sweep of exposed coins (Litecoin, Dogecoin, Bitcoin Cash): ceilings of an unaudited build at prepare and at sign",394 "group": "transaction-limits",395 "verdict": "pass",396 "scope": "service",397 "rationale": "A sweep is a send-max plan built and signed by the payment functions: the 150 USD value ceiling, the fee and fee-rate ceilings apply when it is prepared and again on the transaction about to be signed, whatever the plan object states; a sweep above the ceiling is not signed on any of the three coins.",398 "evidence": [399 {400 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:919",401 "contains": "try await enforceUnauditedCoinLimits(network: network, amount: recipients, fee: plan.fee, vsize: plan.plan.estimatedVSize)"402 },403 {404 "ref": "Tests/QyvoraWalletTests/NewEntryPointsAuditRegressionTests.swift:59",405 "contains": "@Test func aSweepObeysTheCeilingsAndPaysOnlyTheWalletOnEveryCoin() async throws {"406 }407 ]408 },409 {410 "id": "WA-NEW-02",411 "title": "Sweep of exposed coins: the destination is the wallet's own fresh address and cannot be redirected",412 "group": "transaction-integrity",413 "verdict": "pass",414 "scope": "service",415 "rationale": "The service derives the destination from the account (internal chain, never-used index); the caller passes no address; before signing, every output of a plan presented as a sweep must be a script of the account's change chain (QYV-SVC-101).",416 "finding": "QYV-SVC-101",417 "evidence": [418 {419 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:862",420 "contains": "let fresh = try account.nextUnusedAddress(chain: .change, used: usedChange)"421 },422 {423 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:914",424 "contains": "throw WalletError.stalePlan(\"The sweep does not pay an address of this wallet. Prepare it again.\")"425 }426 ]427 },428 {429 "id": "WA-NEW-03",430 "title": "Sweep on Dogecoin: coins authenticated against their previous transactions",431 "group": "transaction-integrity",432 "verdict": "pass",433 "scope": "service",434 "rationale": "The sweep is signed by signAndBroadcastCoin: an indexer that misstates an exposed coin obtains no signature (QYV-SVC-064 rule).",435 "evidence": [436 {437 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:966",438 "contains": "let previous = account.requiresPreviousTransactions ? try await previousTransactions(for: plan.plan, network: network) : [:]"439 },440 {441 "ref": "Tests/QyvoraWalletTests/NewEntryPointsAuditRegressionTests.swift:151",442 "contains": "@Test func aDogecoinSweepChecksItsCoinsAgainstTheirPreviousTransactions() async throws {"443 }444 ]445 },446 {447 "id": "WA-NEW-04",448 "title": "Persisted synchronization of a UTXO coin: hostile file refused or bounded, tied to account, network and endpoints",449 "group": "local-storage",450 "verdict": "pass",451 "scope": "service",452 "rationale": "The record is size-capped, bound to an identity (network, account key, endpoint lists), each address is derived again from the account, and the content passes the validation of a synchronization; anything else is removed. Structural mutations and fuzzing never trap and never restore a coin outside the account or the monetary range.",453 "residual_risk": "The file is not authenticated: a forged, self-consistent record is displayed (flagged as the previous session's) until the next synchronization.",454 "evidence": [455 {456 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:201",457 "contains": "record.version >= 1, record.version <= UTXOCoinSyncRecord.currentVersion, record.identity == identity, record.network == network,"458 },459 {460 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:180",461 "contains": "guard address.string == e.address else { throw WalletError.untrustedResponse(\"persisted address\") }"462 },463 {464 "ref": "security/tests/Tests/PropertyAuditTests/NewEntryPointsProperties.swift:161",465 "contains": "@Test func forgedCoinRecordsAreRefusedOrFlaggedAndBounded() async throws {"466 },467 {468 "ref": "security/tests/Sources/FuzzTargets/Targets+MultichainWallet.swift:596",469 "contains": "\"utxo-coin-snapshot\", \"Persisted synchronization of a UTXO coin (Litecoin, Dogecoin, Bitcoin Cash) written by a hostile hand and read back through the service's own loader\","470 }471 ]472 },473 {474 "id": "WA-NEW-05",475 "title": "A persisted coin snapshot never feeds a signed transaction",476 "group": "transaction-integrity",477 "verdict": "pass",478 "scope": "service",479 "rationale": "prepare, sweep, the check before signing and tracking all go through freshCoinSnapshot, which refuses a snapshot of the previous session; the flag is set by the loader. Nothing else of the session state comes from the file (QYV-SVC-100).",480 "finding": "QYV-SVC-100",481 "evidence": [482 {483 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:738",484 "contains": "guard !snapshot.isFromPreviousSession else {"485 },486 {487 "ref": "Tests/QyvoraWalletTests/NewEntryPointsAuditRegressionTests.swift:279",488 "contains": "@Test func aForgedCoinRecordNeverReachesASignature() async throws {"489 },490 {491 "ref": "security/tests/Tests/PropertyAuditTests/NewEntryPointsProperties.swift:210",492 "contains": "@Test func aRestoredCoinRecordIsNeverSpentFrom() async throws {"493 }494 ]495 },496 {497 "id": "WA-NEW-06",498 "title": "Fee quotes: behind the mainnet gate, chain-identity checked, no trap on hostile figures, nothing signed",499 "group": "network",500 "verdict": "pass",501 "scope": "service",502 "rationale": "feeQuote resolves the chain through activeKind (gate), uses the verified clients (identity check, offline refusal), bounds and overflow-checks every figure, and returns an estimate that no later step trusts.",503 "residual_risk": "An estimate rests on the first answering endpoint of the family.",504 "evidence": [505 {506 "ref": "Sources/QyvoraWallet/WalletService+FeeQuote.swift:121",507 "contains": "let kind = try activeKind(id)"508 },509 {510 "ref": "Tests/QyvoraWalletTests/NewEntryPointsAuditRegressionTests.swift:177",511 "contains": "@Test func feeQuoteIsBehindTheMainnetGateAndSilentInColdMode() async throws {"512 },513 {514 "ref": "Tests/QyvoraWalletTests/NewEntryPointsAuditRegressionTests.swift:497",515 "contains": "@Test func feeQuoteSurvivesHostileFigures() async throws {"516 }517 ]518 },519 {520 "id": "WA-NEW-07",521 "title": "acceptUnverifiedAmounts lifts no ceiling and nothing on an unaudited mainnet build",522 "group": "transaction-limits",523 "verdict": "pass",524 "scope": "service",525 "rationale": "The flag of the unified cold signing reaches signPSBT only; unverified amounts stay refused on an unaudited mainnet build whatever is passed; value and fee ceilings and the wallet's fee bounds are applied after it.",526 "gap": "The interface must obtain the flag from a separate, explicit confirmation (QYV-APP-100).",527 "finding": "QYV-APP-100",528 "evidence": [529 {530 "ref": "Sources/QyvoraWallet/WalletService+Bitcoin.swift:1034",531 "contains": "guard acceptUnverifiedAmounts else {"532 },533 {534 "ref": "Sources/QyvoraWallet/WalletService+Bitcoin.swift:1038",535 "contains": "try enforceUnauditedBitcoinLimit(network: account.network, amount: before.sentToOthers)"536 },537 {538 "ref": "Tests/QyvoraWalletTests/NewEntryPointsAuditRegressionTests.swift:203",539 "contains": "@Test func acceptUnverifiedAmountsLiftsNoLimit() async throws {"540 }541 ]542 },543 {544 "id": "WA-NEW-08",545 "title": "Token description of a payment comes from the wallet, on every family; hidden and detected tokens cannot change it",546 "group": "transaction-integrity",547 "verdict": "pass",548 "scope": "service",549 "rationale": "Showing a hidden token again uses its chain and address only; a detected token of a restored file cannot enter the list (QYV-SVC-102); TRON and Solana payments resolve the token to the wallet's own description like EVM (QYV-SVC-103).",550 "residual_risk": "Custom tokens keep the description read on chain when they were added (one endpoint); the profile is not authenticated (QYV-SVC-011, QYV-SVC-014).",551 "evidence": [552 {553 "ref": "Sources/QyvoraWallet/WalletService+HiddenTokens.swift:110",554 "contains": "let key = prefix + hidden.address"555 },556 {557 "ref": "Sources/QyvoraWallet/WalletService+Send.swift:402",558 "contains": "func tronToken(_ token: ChainToken, network: TronNetwork) throws -> ChainToken {"559 },560 {561 "ref": "Sources/QyvoraWallet/WalletService+Ethereum.swift:455",562 "contains": "guard !snapshot.isFromPreviousSession else { throw WalletError.notSynchronized(Self.detectedFromPreviousSessionText) }"563 },564 {565 "ref": "Tests/QyvoraWalletTests/NewEntryPointsAuditRegressionTests.swift:576",566 "contains": "@Test func showingAHiddenTokenAgainChangesNoPaymentMetadata() async throws {"567 },568 {569 "ref": "Tests/QyvoraWalletTests/NewEntryPointsAuditRegressionTests.swift:632",570 "contains": "@Test func aDetectedTokenOfARestoredSnapshotCannotEnterTheList() async throws {"571 }572 ]573 },574 {575 "id": "WA-NEW-10",576 "title": "Address indices of the profile file cannot trap the wallet or widen a key search",577 "group": "local-storage",578 "verdict": "pass",579 "scope": "service",580 "rationale": "Used indices are bounded when the profile is read and the account's index arithmetic is saturating or checked (QYV-SVC-104).",581 "finding": "QYV-SVC-104",582 "residual_risk": "The profile is not authenticated (QYV-SVC-011).",583 "evidence": [584 {585 "ref": "Sources/QyvoraWallet/WalletTypes.swift:341",586 "contains": "usedChangeIndices = try get(.usedChangeIndices, usedChangeIndices).mapValues { $0.filter { $0 <= Self.maximumUsedIndex } }"587 },588 {589 "ref": "Sources/QyvoraBitcoin/Account.swift:251",590 "contains": "guard !overflow else { throw BitcoinAccountError.indexOutOfRange }"591 },592 {593 "ref": "Tests/QyvoraWalletTests/NewEntryPointsAuditRegressionTests.swift:471",594 "contains": "@Test func hostileAddressIndicesOfAProfileNeitherTrapNorGrowTheSearch() async throws {"595 }596 ]597 },598 {599 "id": "WA-NEW-09",600 "title": "Ed25519 in the start-up self-test with a real RFC 8032 vector",601 "group": "cryptography",602 "verdict": "pass",603 "scope": "service",604 "rationale": "The self-test derives the public key and signs TEST 1 of RFC 8032 section 7.1, verifies the signature and refuses it for another message; a mismatch fails the self-test like any other primitive.",605 "gap": "What the application does when the self-test fails is in App/Sources (not reviewed here).",606 "evidence": [607 {608 "ref": "Sources/QyvoraCrypto/QyvoraCrypto.swift:156",609 "contains": "edSignature.hex == \"e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e065224901555fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b\","610 }611 ]612 }613 ],614 "findings": [615 "QYV-SVC-100",616 "QYV-SVC-101",617 "QYV-SVC-102",618 "QYV-SVC-103",619 "QYV-SVC-104",620 "QYV-APP-100"621 ]622}623