SPB Git

Repository Public

multichain-tron.json 43.1 KB 635 lines json

1{2  "schema": "qyvora-review/1",3  "title": "Multi-chain audit — TRON: protobuf codec, addresses, transactions, node client, send planner, wallet service",4  "reviewed_revision_base": "08b6c46",5  "reviewed_revision_head": "88b7d9c",6  "date": "2026-12-05",7  "method": "Manual line-by-line review of Sources/QyvoraTron (TronProtobuf, TronAddress, TronTransaction, TronJSON, TronClient, TronNetwork, TronTokens, TronSendPlanner) and of the TRON paths of Sources/QyvoraWallet (WalletService+Tron, the TRON cases of +Send, +Cold, +Chains, Chains, ChainPersistence); conformance vectors (1 103 transactions of the public chain, 10 TronWeb transactions, addresses, genesis ids, signature format); differential tests against tronpy 0.8.0, Google protobuf 5.29.5 on the tron.proto descriptors, a second hand-written encoder, coincurve 21.0.0 (libsecp256k1), eth-abi 6.0.0 and bip-utils 2.14.1; property tests; seven fuzz targets. Chain constants checked against two sources (five public endpoints read on 2026-12-05, TIP-474).",8  "limits": "Internal audit by the agent that also wrote the fixes. No transaction built by the wallet was broadcast to a real node (no funds, no network call with wallet material: stub transports only), so acceptance by a real node rests on byte-identity with the references and with real chain transactions. The protobuf reference (tronpy's tron.proto) and the hand-written encoder (field numbers of the protocol repository) describe the same protocol: an error common to both definitions would not be seen by the differential tests, but 1 103 real transactions decode and re-encode. The interface (App/Sources) was not reviewed. java-tron's fee rules are modelled from its documentation, not executed. The fuzzer is mutation-based, not coverage-guided.",9  "entries": [10    {11      "construct": "ProtoReader.varint: minimal varints, ten bytes at most, 64 bits at most",12      "location": "Sources/QyvoraTron/TronProtobuf.swift:135",13      "verdict": "safe",14      "note": "The tenth byte may only carry bit 63 (`count == 10 && group > 1` refuses), a final zero group after another byte is `nonMinimalVarint`, the loop ends at ten bytes; shifts stay under 64. No arithmetic on attacker values that can trap. Property test tron-protobuf-reader-bounds; fuzz target tron-protobuf."15    },16    {17      "construct": "ProtoReader.next: tag, wire type, length-delimited field",18      "location": "Sources/QyvoraTron/TronProtobuf.swift:169",19      "verdict": "safe",20      "note": "The length (UInt64 from the input) is compared with what is left before `Int(length)` and before any slice; nothing is allocated from the length itself. Field number 0 and above 2^29 − 1 refused; wire types other than 0 and 2 refused (the messages handled use no other). Lengths 2^31, 2^63 and 2^64 − 1 are in the property tests."21    },22    {23      "construct": "ProtoFields: duplicates, wrong wire types, negative int64, addresses",24      "location": "Sources/QyvoraTron/TronProtobuf.swift:191",25      "verdict": "safe",26      "note": "Singular fields are seen once (`duplicateField`), a known field under the other wire type is `wrongWireType`, an int64 above 2^63 − 1 is `negativeValue`, an address must be 0x41 ‖ 20 bytes."27    },28    {29      "construct": "TronTransaction.decode(rawData:): strict and canonical",30      "location": "Sources/QyvoraTron/TronTransaction.swift:419",31      "verdict": "safe",32      "note": "16 KiB cap before parsing; unknown fields of Transaction.raw, Contract, Any, TransferContract and TriggerSmartContract refused (including ref_block_num, auths, scripts, provider, ContractName, which the protocol defines and the wallet never writes); exactly one contract; type URL printable ASCII, at most 200 bytes, matching the type number in both directions; the result must re-encode to the input, which refuses field-order changes and explicit defaults. Judged like Google's protobuf runtime plus the stated policy on altered encodings; 1 096 of 1 103 chain transactions decode to their own bytes, the 7 others carry `scripts`. The decoder does not compare expiration with timestamp (a received transaction may lack a timestamp); the validity window is enforced at signing (QYV-SVC-041). A prefix that ends exactly before an optional trailing field is another valid transaction with another id (stated in the property test)."33    },34    {35      "construct": "TronTransaction.init: ranges, lifetime, memo size",36      "location": "Sources/QyvoraTron/TronTransaction.swift:319",37      "verdict": "safe",38      "note": "Every integer at most 2^63 − 1, reference fields of 2 and 8 bytes, expiration after timestamp and at most 24 h later, memo at most 256 bytes. The subtraction is guarded by the comparison before it."39    },40    {41      "construct": "TronTransaction.rawData / txID: built locally, id = SHA-256(raw_data)",42      "location": "Sources/QyvoraTron/TronTransaction.swift:374",43      "verdict": "safe",44      "note": "The id is computed from the bytes the wallet encoded; no code path takes a transaction id or raw_data from a node to sign it. Random transactions byte-identical to the protobuf runtime and to a second hand-written encoder; 10 TronWeb vectors; 1 103 chain transactions hash to the id the chain gives."45    },46    {47      "construct": "TronTransaction.sign: owner check, blind-signing refusal, self-verification",48      "location": "Sources/QyvoraTron/TronTransaction.swift:476",49      "verdict": "safe",50      "note": "The key must derive to the owner of the contract; a contract call that is not a plain TRC-20 transfer or approval, and any contract type other than TransferContract and TriggerSmartContract, is refused unless `allowBlindSigning`; the signature is recovered and compared before it is returned; v = 27 + recovery id, low s. Signatures byte-identical to libsecp256k1 (coincurve), to tronpy's OpenSSL signer and to TronWeb (10 vectors)."51    },52    {53      "construct": "SignedTronTransaction.signers: recovery, accepted v values",54      "location": "Sources/QyvoraTron/TronTransaction.swift:532",55      "verdict": "reviewed",56      "note": "v may be 0, 1, 27 or 28; anything else is refused (tronpy also takes v ≥ 35: policy difference, the network does not). High-s signatures recover (requireLowS false), as on the network: the transaction id does not cover the signature, so this is not an id malleability. Agreement with libsecp256k1 recovery on the signed-envelope campaign."57    },58    {59      "construct": "SignedTronTransaction.decode: strict envelope",60      "location": "Sources/QyvoraTron/TronTransaction.swift:566",61      "verdict": "safe",62      "note": "raw_data once, zero to five signatures of exactly 65 bytes, no other field (the `ret` a node appends is refused), canonical re-encoding. Used when a cold-signed transaction comes back and when a signed transaction is re-sent."63    },64    {65      "construct": "TronTransactionReview: derived from the decoded transaction only",66      "location": "Sources/QyvoraTron/TronTransaction.swift:632",67      "verdict": "safe",68      "note": "A pure function of the transaction that is signed (`rawData`, `txID` recomputed from it). A TRC-20 call is shown as a transfer or an approval only when the call data is exactly that call and nothing (TRX, TRC-10) is attached; everything else is `blindSigning`. Fuzz target tron-raw-data checks each action against the bytes."69    },70    {71      "construct": "TronAddress text forms",72      "location": "Sources/QyvoraTron/TronAddress.swift:81",73      "verdict": "safe",74      "note": "Base58Check form: 34 characters, 'T', checksum, 21 bytes, prefix 0x41; no trimming. Hexadecimal form only through init(hex:) (42 digits, prefix 41, no 0x). The EVM form (0x + 40 digits) is refused by every initialiser. The wallet's recipient check accepts the Base58Check form only and names the hexadecimal and EVM forms in its refusal."75    },76    {77      "construct": "TronJSON: strict parser with exact integers",78      "location": "Sources/QyvoraTron/TronJSON.swift:127",79      "verdict": "safe",80      "note": "Recursion bounded at 48, numbers kept as text (64 characters at most) and converted with UInt64(text) only when they are plain digits, duplicate keys and lone surrogates refused, every index guarded. No Double on the path of an amount. Property test tron-json-parser; fuzz target tron-json."81    },82    {83      "construct": "TronClient.request: size cap, API key header, error text",84      "location": "Sources/QyvoraTron/TronClient.swift:345",85      "verdict": "safe",86      "note": "The key is set as a header only when the host is trongrid.io or a subdomain and the scheme is https; never in a URL or a body. The transport follows no redirect (Sources/QyvoraNetworking/HTTP.swift), so the header cannot travel to another host. Errors carry the path or 200 bytes of the server's body, never the request headers."87    },88    {89      "construct": "TronClient.first: first usable answer wins",90      "location": "Sources/QyvoraTron/TronClient.swift:370",91      "verdict": "reviewed",92      "note": "No quorum: balances, resources, chain parameters, account state, TRC-20 reads, status and history are one node's word (see endpoint_impact). The reference block is the exception.",93      "finding_id": "QYV-SVC-044"94    },95    {96      "construct": "TronClient.verifyChain: genesis block id of every node",97      "location": "Sources/QyvoraTron/TronClient.swift:445",98      "verdict": "reviewed",99      "note": "Catches a misconfigured endpoint. It cannot catch a node that lies: the genesis id is a public constant. The three constants were checked against five public endpoints and the TIP-474 chain ids."100    },101    {102      "construct": "TronClient.referenceBlock: agreement of the nodes on the reference block",103      "location": "Sources/QyvoraTron/TronClient.swift:483",104      "verdict": "fixed",105      "note": "New. The oldest irreversible block among the answering nodes, confirmed by block number on the others; a different id is a disagreement.",106      "finding_id": "QYV-SVC-040"107    },108    {109      "construct": "TronClient.acceptsReference: would this network accept a reference (TaPoS)",110      "location": "Sources/QyvoraTron/TronClient.swift:529",111      "verdict": "fixed",112      "note": "New. Height arithmetic on UInt64 with the underflow case handled; an answer for another block number is an error, never 'not accepted'.",113      "finding_id": "QYV-SVC-040"114    },115    {116      "construct": "TronClient.chainParameters: bounds",117      "location": "Sources/QyvoraTron/TronClient.swift:579",118      "verdict": "safe",119      "note": "Parameters above 2^63 − 1 refused, prices of zero refused, at most 1 000 entries read. Balances are bounded the same way and an account answered for another address is refused."120    },121    {122      "construct": "TronClient.broadcast: local id, node's id compared",123      "location": "Sources/QyvoraTron/TronClient.swift:698",124      "verdict": "safe",125      "note": "The id returned to the caller is the local one; a node that reports another id is an invalid answer. Texts of a refusal are cleaned (printable, 200 characters)."126    },127    {128      "construct": "TronClient.transactionStatus / transactions: bytes must hash to the id",129      "location": "Sources/QyvoraTron/TronClient.swift:741",130      "verdict": "reviewed",131      "note": "A transaction shown from a node is rebuilt from bytes that hash to its id. Inclusion, receipt result, fee and the whole TRC-20 transfer history are the node's or the index's word."132    },133    {134      "construct": "TronClient.nodeBuiltTransfer: node-built transaction for comparison only",135      "location": "Sources/QyvoraTron/TronClient.swift:674",136      "verdict": "safe",137      "note": "Returns bytes and is not called by the wallet service; nothing signs its result. The classic defect — signing the txID of `createtransaction` — is absent by construction."138    },139    {140      "construct": "TronSendPlanner: checked arithmetic, fee model, send-max",141      "location": "Sources/QyvoraTron/TronSendPlanner.swift:235",142      "verdict": "safe",143      "note": "Every product and sum goes through `mul` / `add` (overflow and 2^63 − 1 checked); the policy ranges are validated before they are multiplied; fee limit = ceil(energy × (100 + margin) / 100) × price, refused above min(policy ceiling, protocol ceiling); send-max keeps amount + fee within the balance. Property test tron-planner-arithmetic."144    },145    {146      "construct": "WalletService.prepareTronSend: local construction from chain state",147      "location": "Sources/QyvoraWallet/WalletService+Tron.swift:432",148      "verdict": "fixed",149      "note": "Reads parameters, reference block, accounts and resources, plans locally, applies the limits, checks the reference against the main network on a test network. Nothing a node built is used.",150      "finding_id": "QYV-SVC-040"151    },152    {153      "construct": "WalletService.enforceTronLimits: ceilings read from the bytes",154      "location": "Sources/QyvoraWallet/WalletService+Tron.swift:535",155      "verdict": "safe",156      "note": "On every network: fee_limit at most 100 TRX and, when the plan is known, a worst-case fee of at most 100 TRX. On an unaudited mainnet: TRX amount under the dollar ceiling at a fresh price, TRC-20 only for a token with a known price, approvals, other calls and unknown contracts refused. Called at prepare, in signAndBroadcastTron, inside signTron and before a cold-signed transaction is broadcast."157    },158    {159      "construct": "WalletService.signTron: key, account, limits, validity, verification",160      "location": "Sources/QyvoraWallet/WalletService+Tron.swift:570",161      "verdict": "fixed",162      "note": "The owner must be the profile's account and the account the vault vouches for; the derived key must give that address; limits and (new) validity window; the private key is wiped; the result is decoded back and its signer recovered.",163      "finding_id": "QYV-SVC-041"164    },165    {166      "construct": "WalletService.signAndBroadcastTron: review bound to its transaction",167      "location": "Sources/QyvoraWallet/WalletService+Tron.swift:644",168      "verdict": "fixed",169      "note": "New check; then limits, main-network reference check, signature, broadcast. A review signed once is re-sent from the stored bytes, not signed again.",170      "finding_id": "QYV-SVC-043"171    },172    {173      "construct": "WalletService cold path: decodeTron / coldTronReview",174      "location": "Sources/QyvoraWallet/WalletService+Cold.swift:151",175      "verdict": "reviewed",176      "note": "The payload must be canonical raw_data of this wallet's account; the summary names recipient, amount, token contract, fee limit, memo, expiry; blind signing must be allowed explicitly; a test-network review now says the bytes name no network. The network itself is the label of the envelope.",177      "finding_id": "QYV-APP-040"178    },179    {180      "construct": "TronGrid API key storage",181      "location": "Sources/QyvoraWallet/WalletService+Chains.swift:293",182      "verdict": "safe",183      "note": "A vault record (type setting), set with an unlocked vault and a fresh authentication; the profile keeps a boolean only; the in-memory value is a type whose description, debug description and mirror are redacted; cleared at lock."184    },185    {186      "construct": "TronNetwork.burnAddress and recipient screening",187      "location": "Sources/QyvoraWallet/WalletService+Send.swift:325",188      "verdict": "fixed",189      "note": "Zero address, burn address (mainnet), hexadecimal form, EVM form, own address, token contracts (planner) are each refused with their own sentence; a contract recipient is a critical warning.",190      "finding_id": "QYV-SVC-042"191    }192  ],193  "endpoint_impact": [194    {195      "capability": "Forged reference block (a block of another TRON network, or one that does not exist)",196      "wallet_does": "Takes the oldest irreversible block of the answering nodes and requires every other answering node to give the same id for that number; on a test network asks the main-network nodes whether they would accept the reference, at prepare and before signing.",197      "impact": "With the fix: a single lying node among several is detected (wrongChain); a lying test node alone can still build on a non-existent block (the network refuses it, TAPOS_ERROR: nothing lost) but not on a main-network block (refused before signing).",198      "mitigation": "Sources/QyvoraTron/TronClient.swift:483",199      "residual_risk": "One node configured or reachable: no cross-check (the review says so). A main-network endpoint lying in concert with the test endpoint. Cold device: no check possible (QYV-APP-040)."200    },201    {202      "capability": "Wrong TRX balance, resources or account state (activated or not, contract or not)",203      "wallet_does": "Shows the first answer; bounds it (≤ 2^63 − 1, address echoed); plans with it.",204      "impact": "Wrong display. A payment planned on a forged balance or on forged free bandwidth is refused by the network or burns at most the real bandwidth price; a recipient falsely reported as activated hides the activation fees (about 1.1 TRX) from the review; a contract reported as an ordinary account hides the 'recipient is a contract' warning.",205      "mitigation": "Sources/QyvoraTron/TronClient.swift:547",206      "residual_risk": "No quorum on reads (QYV-SVC-044). The hidden contract warning is the most relevant case."207    },208    {209      "capability": "Forged chain parameters (bandwidth and energy prices, activation fees, memo fee, maximum fee limit)",210      "wallet_does": "Refuses values of zero or above 2^63 − 1; computes fees with checked arithmetic; refuses a fee limit above 100 TRX and a worst-case fee above 100 TRX whatever the parameters say.",211      "impact": "A low energy price gives a fee limit that is too small: the token transfer fails on chain (OUT_OF_ENERGY) and burns at most that fee limit. A high price is refused or shows a pessimistic fee. The real cost is set by the chain; the fee limit signed is the only figure the answer influences, and it is capped.",212      "mitigation": "Sources/QyvoraWallet/WalletService+Tron.swift:535",213      "residual_risk": "A griefing loss of at most the fee limit (≤ 100 TRX, in practice the few TRX of a token transfer) per failed transfer."214    },215    {216      "capability": "Forged energy estimate or simulation result (triggerconstantcontract)",217      "wallet_does": "Refuses an estimate of zero and a simulation that reverts; adds 25 % and multiplies by the price with overflow checks; caps the fee limit.",218      "impact": "Under-estimate: the transfer runs out of energy and burns its fee limit for nothing. Over-estimate: refused above the ceiling. A simulation falsely reported as failing blocks the payment.",219      "mitigation": "Sources/QyvoraTron/TronSendPlanner.swift:377",220      "residual_risk": "Bounded loss of the fee limit; denial of service."221    },222    {223      "capability": "Forged TRC-20 metadata and balances (decimals, symbol, name, balanceOf)",224      "wallet_does": "Built-in tokens: decimals and symbol are in the code, a contract that reports other decimals is not read. Custom tokens: decimals (≤ 77, wallet cap applied), symbol and name cleaned and bounded, taken from the first answer when the token is added.",225      "impact": "Custom token: the displayed amount can differ from the signed base-unit amount by the power of ten the node lied about (QYV-SVC-044); a forged symbol can imitate a known token — the contract address identifies a token. Balances: wrong display; a payment above the real balance reverts on chain.",226      "mitigation": "Sources/QyvoraWallet/WalletService+Tron.swift:224",227      "residual_risk": "Open as QYV-SVC-044. Not reachable on an unaudited mainnet (a custom token has no price and cannot be sent)."228    },229    {230      "capability": "Censored or falsely acknowledged broadcast",231      "wallet_does": "Sends to the nodes in turn until one accepts; reports 'accepted' as not confirmed; tracks the receipt; declares the payment expired one minute after its expiration without a receipt.",232      "impact": "A node that answers 'accepted' and drops the transaction delays the payment until its expiration (2 minutes by default) and holds the signed transaction, which it may broadcast itself within that window (it is the user's own payment). No loss.",233      "mitigation": "Sources/QyvoraTron/TronClient.swift:688",234      "residual_risk": "Denial of service; the first accepting node is trusted to relay."235    },236    {237      "capability": "Forged transaction status and receipts",238      "wallet_does": "Requires the id asked for in the answer, and bytes that hash to it for the transaction itself; reads failure from the receipt, never from the value a token returns; 'finalized' only when the irreversible state has it.",239      "impact": "A node can show a payment as confirmed, failed or unknown at will. A payment falsely shown as failed or expired may be made twice by the user.",240      "mitigation": "Sources/QyvoraTron/TronClient.swift:725",241      "residual_risk": "One node's word."242    },243    {244      "capability": "Forged history (TronGrid index)",245      "wallet_does": "Native entries are rebuilt from raw bytes that hash to their id; TRC-20 entries are taken from the index (bounded, cleaned, unknown tokens marked unverified).",246      "impact": "Phantom incoming payments, hidden outgoing ones, look-alike addresses in the history (address poisoning). A forged 'sent' entry to an attacker's address removes the first-payment notice for that address.",247      "mitigation": "Sources/QyvoraTron/TronClient.swift:794",248      "residual_risk": "The index is a single party; the interface must present its entries as unverified (QYV-APP-041)."249    },250    {251      "capability": "Hostile answer sizes and shapes",252      "wallet_does": "4 MiB cap, strict JSON, bounded lists (1 000 parameters, 200 history entries), exact integers.",253      "impact": "None beyond a refused answer. Fuzz target tron-json over every parser.",254      "mitigation": "Sources/QyvoraTron/TronClient.swift:302",255      "residual_risk": "None identified."256    },257    {258      "capability": "Learning the TronGrid API key",259      "wallet_does": "Sends it to trongrid.io hosts over https only, as a header; no redirect is followed.",260      "impact": "A custom or look-alike endpoint never receives the key.",261      "mitigation": "Sources/QyvoraTron/TronClient.swift:329",262      "residual_risk": "None identified beyond TronGrid itself."263    }264  ],265  "replay_protection": {266    "mechanism": "A TRON transaction carries ref_block_bytes (two low-order bytes of a block number), ref_block_hash (bytes 8 to 15 of that block's id), an expiration and a timestamp. A node accepts it only if the latest block whose number ends with ref_block_bytes has that hash on ITS chain (TaPoS), if it is not expired and expires less than 24 h after the head block, and if its id (SHA-256 of raw_data) is not already in the chain's recent-transaction window. There is no chain identifier in the signed bytes.",267    "same_chain": "Replaying an included transaction on the same chain is refused by the chain (duplicate id, then expiry). The wallet never signs the same review twice: the signed bytes are kept and re-sent (Sources/QyvoraWallet/WalletService+Tron.swift:638).",268    "cross_network": "The same key and address control the account on mainnet, Nile and Shasta. Separation rests on the reference block existing on one chain only: 80 bits (16 of height, 64 of hash) that a third party cannot make collide, but that a node chooses when it supplies the reference. QYV-SVC-040: the reference is agreed by every answering node (Sources/QyvoraTron/TronClient.swift:483) and, for a test network, refused when the main network would accept it, at prepare and before signing (Sources/QyvoraWallet/WalletService+Tron.swift:111).",269    "expiration_window": "Planner: 30 s to 1 h, 120 s by default, 30 min for a cold device (Sources/QyvoraTron/TronSendPlanner.swift:199); device clock and reference block within 300 s. Signing: nothing expired, nothing valid for more than 65 minutes, whatever built the transaction (Sources/QyvoraWallet/WalletService+Tron.swift:71, QYV-SVC-041).",270    "chain_identity": "Genesis block id of each endpoint checked once per session and endpoint list (Sources/QyvoraTron/TronClient.swift:438); constants verified against five public endpoints and the TIP-474 chain ids. This detects misconfiguration, not a lying node.",271    "residual_risks": [272      "Cold device: offline, cannot check the reference block; a payload labelled as a test network is signed without mainnet rules (QYV-APP-040, open).",273      "A single configured or reachable node gives no cross-check of the reference block; stated on the review.",274      "The main-network check trusts the main-network endpoints (first answer): a test endpoint and a main-network endpoint lying together defeat it.",275      "Nile versus Shasta: no check between the two test networks (no value at stake).",276      "A signed transaction is valid for its whole window: a node that received it can broadcast it at any moment within it (it is the payment the user approved)."277    ]278  },279  "wallet_audit_items": [280    {281      "id": "WA-TRON-01",282      "title": "TRON key derivation and recovery sheet",283      "group": "recovery-phrase",284      "verdict": "pass",285      "scope": "service",286      "rationale": "The account key is the BIP-32 secp256k1 key at m/44'/195'/0'/0/0 of the BIP-39 seed (what TronLink, Ledger Live and TronWeb derive), on every TRON network. The recovery sheet prints the path from the same function and the address from the same code. Random seeds and indices agree with bip-utils; the account of the test phrase equals TronWeb's.",287      "evidence": [288        {289          "ref": "Sources/QyvoraTron/TronNetwork.swift:113",290          "contains": "DerivationPath([.hardened(44), .hardened(195), .hardened(0), .normal(0), .normal(index)])"291        },292        {293          "ref": "Sources/QyvoraWallet/WalletService+Shield.swift:429",294          "contains": "chain: \"TRON\", networks: \"mainnet, Nile and Shasta: the same address\", derivationPath: TronPaths.account().description,"295        },296        {297          "ref": "Sources/QyvoraWallet/WalletService+Onboarding.swift:317",298          "contains": "var tron = try master.derive(TronPaths.account())"299        },300        {301          "ref": "security/tests/Tests/DifferentialAuditTests/TronDiffTests.swift:573",302          "contains": "func accountDerivation()"303        },304        {305          "ref": "security/tests/Tests/ConformanceAuditTests/TronVectors.swift:277",306          "contains": "check(TronPaths.account().description == \"m/44'/195'/0'/0/0\""307        }308      ]309    },310    {311      "id": "WA-TRON-02",312      "title": "TRON signing key lives in memory for the duration of a signature",313      "group": "key-storage",314      "verdict": "pass",315      "scope": "service",316      "rationale": "signTron derives the key under withMasterKey, checks that it gives the account the profile and the vault vouch for, signs, and wipes the derived key and the private scalar on every path. No TRON private key is stored, logged or returned.",317      "evidence": [318        {319          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:590",320          "contains": "var key = try master.derive(TronPaths.account())"321        },322        {323          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:593",324          "contains": "defer { SecureMemory.zero(&secret) }"325        },326        {327          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:577",328          "contains": "if let trusted = await trustedPublicData(), trusted.tron != owner.base58 {"329        }330      ]331    },332    {333      "id": "WA-TRON-03",334      "title": "TRON address validation and cross-family confusion",335      "group": "fraud-protection",336      "verdict": "pass",337      "scope": "service",338      "rationale": "A recipient must be the Base58Check form (34 characters, T, checksum, prefix 0x41). The hexadecimal 41… form and the EVM 0x… form — the same twenty bytes — are refused with their own sentences, as are the zero address, the mainnet burn address, the wallet's own address and token contracts. A contract recipient is a critical warning; a never-activated recipient is announced with its fee. Random and altered texts agree with an independent strict rule; tronpy accepts the EVM and hexadecimal forms, the wallet does not.",339      "finding": "QYV-SVC-042",340      "evidence": [341        {342          "ref": "Sources/QyvoraTron/TronAddress.swift:81",343          "contains": "guard ascii.count == 34, ascii[0] == 0x54, let payload = Base58Check.decode(text), let a = TronAddress(bytes: payload) else { return nil }"344        },345        {346          "ref": "Sources/QyvoraWallet/WalletService+Send.swift:329",347          "contains": "if TronAddress(hex: t) != nil {"348        },349        {350          "ref": "Sources/QyvoraWallet/WalletService+Send.swift:325",351          "contains": "if let address = TronAddress(t), address == tronNetwork.burnAddress {"352        },353        {354          "ref": "Sources/QyvoraTron/TronSendPlanner.swift:261",355          "contains": "if TronBuiltInTokens.token(recipient.address, on: state.network) != nil { throw .recipientIsTokenContract(recipient.address) }"356        },357        {358          "ref": "security/tests/Tests/DifferentialAuditTests/TronDiffTests.swift:140",359          "contains": "func addressParsing()"360        },361        {362          "ref": "Tests/QyvoraWalletTests/TronAuditRegressionTests.swift:225",363          "contains": "func theBurnAddressOfTheMainNetworkIsRefused()"364        }365      ]366    },367    {368      "id": "WA-TRON-04",369      "title": "TRON: what is shown is what is signed; nothing a node built is signed",370      "group": "fraud-protection",371      "verdict": "pass",372      "scope": "service",373      "rationale": "raw_data is encoded on the device from the plan; the transaction id is SHA-256 of those bytes; the review is derived from the same transaction and, before signing, compared with the figures shown; a payload received by a cold device must be the canonical encoding of what it decodes to. The node's createtransaction is never used to sign. Encoding identical to Google's protobuf runtime on random transactions and on 1 096 chain transactions; decoding judged like the runtime plus the stated policy on altered encodings.",374      "finding": "QYV-SVC-043",375      "evidence": [376        {377          "ref": "Sources/QyvoraTron/TronTransaction.swift:374",378          "contains": "public var txID: Bytes { SHA256.hash(rawData) }"379        },380        {381          "ref": "Sources/QyvoraTron/TronTransaction.swift:419",382          "contains": "guard tx.rawData == rawData else { throw .nonCanonical }"383        },384        {385          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:644",386          "contains": "try Self.requireMatches(review, plan: details.plan)"387        },388        {389          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:599",390          "contains": "guard signed.transaction == transaction, (try? signed.signers()) == [owner], (try? SignedTronTransaction.decode(signed.serialized)) == signed else {"391        },392        {393          "ref": "security/tests/Tests/DifferentialAuditTests/TronDiffTests.swift:228",394          "contains": "func rawDataTransactionIDAndSignature()"395        },396        {397          "ref": "security/tests/Tests/DifferentialAuditTests/TronDiffTests.swift:418",398          "contains": "func decodingOfAlteredRawData()"399        },400        {401          "ref": "Tests/QyvoraWalletTests/TronAuditRegressionTests.swift:276",402          "contains": "func aReviewThatDoesNotMatchItsTransactionIsNotSigned()"403        }404      ]405    },406    {407      "id": "WA-TRON-05",408      "title": "TRON blind signing",409      "group": "fraud-protection",410      "verdict": "pass",411      "scope": "service",412      "rationale": "The wallet builds TransferContract and TRC-20 transfer(address,uint256) only. On a cold device a TRC-20 approval is decoded and shown (unlimited approvals flagged critical); any other contract call and any other contract type is refused unless blind signing is allowed explicitly, and refused whatever is passed on an unaudited mainnet.",413      "evidence": [414        {415          "ref": "Sources/QyvoraTron/TronTransaction.swift:482",416          "contains": "guard allowBlindSigning else { throw Error.blindSigningRefused }"417        },418        {419          "ref": "Sources/QyvoraWallet/WalletService+Cold.swift:277",420          "contains": "throw WalletError.invalidPayload(\"This contract cannot be decoded. Blind signing must be allowed explicitly.\")"421        },422        {423          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:563",424          "contains": "case .trc20Approve, .contractCall, .unknownContract:"425        },426        {427          "ref": "security/tests/Tests/PropertyAuditTests/TronProperties.swift:653",428          "contains": "func theEngineSignsOnlyWhatItDecodesForTheOwnerKey()"429        }430      ]431    },432    {433      "id": "WA-TRON-06",434      "title": "TRON replay protection and network binding",435      "group": "replay-protection",436      "verdict": "partial",437      "scope": "service",438      "rationale": "A transaction is bound to a recent block (TaPoS), an expiration (120 s by default, never more than 65 minutes at signing) and its own id; the chain refuses duplicates. No chain identifier exists in the format: the reference block is agreed by every answering node and, on a test network, checked against the main network before signing.",439      "gap": "An offline cold device cannot check which network a payload is for; the label of the envelope decides which rules apply.",440      "residual_risk": "A test-network payload valid on mainnet can be cold-signed past the gate and the limits (QYV-APP-040, open); a single reachable node gives no cross-check.",441      "finding": "QYV-SVC-040, QYV-SVC-041, QYV-APP-040",442      "evidence": [443        {444          "ref": "Sources/QyvoraTron/TronClient.swift:483",445          "contains": "public func referenceBlock() async throws -> (block: TronBlockReference, confirmations: Int)"446        },447        {448          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:646",449          "contains": "try await requireNotValidOnTronMainnet(details.plan.transaction, network: network)"450        },451        {452          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:586",453          "contains": "guard transaction.expiration - nowMilliseconds <= Self.tronMaximumSigningWindowMilliseconds else {"454        },455        {456          "ref": "Tests/QyvoraWalletTests/TronAuditRegressionTests.swift:315",457          "contains": "func aTestNetworkTransactionTheMainNetworkWouldAcceptIsNeverSigned()"458        },459        {460          "ref": "Tests/QyvoraWalletTests/TronAuditRegressionTests.swift:183",461          "contains": "func aColdDeviceDoesNotSignATransactionValidForMoreThanAnHour()"462        },463        {464          "ref": "Tests/QyvoraTronTests/TronAuditRegressionTests.swift:95",465          "contains": "func aNodeWithAnotherBlockAtTheSameHeightIsADisagreement()"466        }467      ]468    },469    {470      "id": "WA-TRON-07",471      "title": "TRON fees: fee_limit ceiling, bandwidth, energy, activation",472      "group": "fees-nonces-utxos",473      "verdict": "pass",474      "scope": "service",475      "rationale": "Fees are computed with checked arithmetic from chain parameters that are bounded when read. fee_limit is the simulated energy plus 25 % at the chain price, refused above 100 TRX (and above the protocol's ceiling) when planning and again when signing, on every network; the worst-case fee of a plan is refused above 100 TRX. Send-max never exceeds the balance; the activation fee of a new recipient is announced. Hostile chain states: no trap, every invariant held.",476      "evidence": [477        {478          "ref": "Sources/QyvoraTron/TronSendPlanner.swift:377",479          "contains": "guard feeLimit <= cap else { throw .feeLimitTooHigh(requiredSun: feeLimit, capSun: cap) }"480        },481        {482          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:535",483          "contains": "guard transaction.feeLimit <= feeCeiling else {"484        },485        {486          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:538",487          "contains": "if let maximumFeeSun, maximumFeeSun > feeCeiling {"488        },489        {490          "ref": "security/tests/Tests/PropertyAuditTests/TronProperties.swift:512",491          "contains": "func plannerArithmeticHoldsForAnyChainState()"492        },493        {494          "ref": "security/tests/Tests/PropertyAuditTests/TronProperties.swift:622",495          "contains": "func sendMaxNeverExceedsTheBalance()"496        },497        {498          "ref": "Tests/QyvoraWalletTests/TronAuditRegressionTests.swift:243",499          "contains": "func aFeeLimitAboveTheCeilingIsNotSignedOnAnyNetwork()"500        }501      ]502    },503    {504      "id": "WA-TRON-08",505      "title": "TRON mainnet gate: both conditions",506      "group": "mainnet-gate",507      "verdict": "pass",508      "scope": "service",509      "rationale": "Every TRON entry point resolves the account through tronAccount / verifiedTron, which call requireAllowed: the main network needs the build's declaration and the user's switch. The cold path goes through the same function.",510      "residual_risk": "The gate looks at the network the wallet believes it is on: see WA-TRON-06 for a test-network payload that is valid on mainnet.",511      "evidence": [512        {513          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:78",514          "contains": "try requireAllowed(.tron(network))"515        },516        {517          "ref": "Sources/QyvoraWallet/WalletService.swift:341",518          "contains": "if !kind.isTest, !MainnetPolicy.mainnetEnabled { throw WalletError.mainnetDisabled(WalletError.mainnetText) }"519        },520        {521          "ref": "Sources/QyvoraCore/Networks.swift:558",522          "contains": "return auditCompleted || (internalBuild && userOptIn)"523        }524      ]525    },526    {527      "id": "WA-TRON-09",528      "title": "TRON per-transaction limits at prepare and at sign",529      "group": "mainnet-gate",530      "verdict": "pass",531      "scope": "service",532      "rationale": "On an unaudited mainnet: TRX amount under the dollar ceiling at a fresh price (no price, no transaction), TRC-20 only for tokens with a known price under their ceiling, nothing else. Applied when the review is prepared, before signing in signAndBroadcastTron, inside signTron (so a cold signature too) and before a cold-signed transaction is broadcast. The figures are read from the bytes: a plan or a review forged inside the module does not lift them, and neither type can be built through the public interface.",533      "evidence": [534        {535          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:475",536          "contains": "try await enforceTronLimits(plan.transaction, network: network, maximumFeeSun: plan.maximumFeeSun)"537        },538        {539          "ref": "Sources/QyvoraWallet/WalletService+Tron.swift:580",540          "contains": "try await enforceTronLimits(transaction, network: network, maximumFeeSun: nil)"541        },542        {543          "ref": "Sources/QyvoraWallet/WalletService+Cold.swift:340",544          "contains": "try await enforceTronLimits(signedTx.transaction, network: network, maximumFeeSun: nil)"545        },546        {547          "ref": "Sources/QyvoraCore/Networks.swift:949",548          "contains": "public static let tronLimits = AccountChainLimits(nativeUSDPerTransaction: limits.nativeUSDPerTransaction, feePerTransaction: 100_000_000)"549        },550        {551          "ref": "Tests/QyvoraWalletTests/TronAuditRegressionTests.swift:426",552          "contains": "func aForgedTronPlanAboveTheCeilingIsNotSigned()"553        }554      ]555    },556    {557      "id": "WA-TRON-10",558      "title": "TRON endpoint policy",559      "group": "network",560      "verdict": "partial",561      "scope": "service",562      "rationale": "Endpoints are https (http for a local host), user-editable, genesis-checked once per session. Reads follow the first usable answer; the reference block alone is agreed between nodes. Answers are size-bounded, strictly parsed and range-checked; no redirect is followed.",563      "gap": "No quorum on balances, resources, chain parameters, TRC-20 metadata, status and history: one lying node decides what is displayed (endpoint impact table of the review register).",564      "residual_risk": "Wrong display, bounded fee griefing (≤ fee limit), custom-token decimals (QYV-SVC-044), index-only history.",565      "finding": "QYV-SVC-044",566      "evidence": [567        {568          "ref": "Sources/QyvoraTron/TronClient.swift:370",569          "contains": "func first<T: Sendable>(_ bases: [URL], _ path: String, _ body: TronJSON?, _ map: @Sendable (TronJSON) throws -> T) async throws -> T"570        },571        {572          "ref": "Sources/QyvoraTron/TronClient.swift:445",573          "contains": "guard genesis.number == 0, genesis.idHex == network.genesisBlockID else {"574        },575        {576          "ref": "Sources/QyvoraTron/TronNetwork.swift:148",577          "contains": "guard EndpointConfiguration.isAcceptable(text), var c = URLComponents(string: text), c.query == nil, c.fragment == nil else { return nil }"578        },579        {580          "ref": "security/tests/Sources/FuzzTargets/Targets+Tron.swift:323",581          "contains": "\"tron-json\""582        }583      ]584    },585    {586      "id": "WA-TRON-11",587      "title": "TronGrid API key handling",588      "group": "data-protection",589      "verdict": "pass",590      "scope": "service",591      "rationale": "The key is a vault record, set behind a fresh authentication; the profile stores a boolean; the type redacts itself in every textual form and accepts only letters, digits, '-' and '_' (8 to 128); it is sent as a header to trongrid.io hosts over https only, never in a URL, never to a custom endpoint, and the transport follows no redirect. Test: all requests of a synchronisation, a payment and a failing request are inspected and every file under the application directory is searched.",592      "evidence": [593        {594          "ref": "Sources/QyvoraTron/TronClient.swift:345",595          "contains": "if let apiKey, grid, url.scheme == \"https\" { r.setValue(apiKey.value, forHTTPHeaderField: \"TRON-PRO-API-KEY\") }"596        },597        {598          "ref": "Sources/QyvoraTron/TronClient.swift:63",599          "contains": "public var description: String { \"TronAPIKey(redacted)\" }"600        },601        {602          "ref": "Sources/QyvoraWallet/WalletService+Chains.swift:311",603          "contains": "try await vault.addRecord(type: .setting, payload: payload)"604        },605        {606          "ref": "Tests/QyvoraWalletTests/TronAuditRegressionTests.swift:362",607          "contains": "func theTronGridKeyGoesToTronGridHostsOnlyAndNowhereElse()"608        },609        {610          "ref": "Tests/QyvoraTronTests/TronAuditRegressionTests.swift:222",611          "contains": "func theAPIKeyIsNotSentToLookAlikeHosts()"612        },613        {614          "ref": "security/tests/Tests/PropertyAuditTests/TronProperties.swift:841",615          "contains": "func theAPIKeyTypeHoldsNothingThatBreaksAHeaderAndNeverPrintsItself()"616        }617      ]618    },619    {620      "id": "WA-TRON-12",621      "title": "TRON and post-quantum scope",622      "group": "post-quantum-scope",623      "verdict": "pass",624      "scope": "service",625      "rationale": "TRON transactions are signed with secp256k1 ECDSA, as the protocol requires: nothing post-quantum protects them. The post-quantum layer protects the vault that holds the seed and the API key, not the chain.",626      "evidence": [627        {628          "ref": "Sources/QyvoraWallet/Chains.swift:329",629          "contains": "mainCounterpart: .tron, testCounterparts: [.tronNile, .tronShasta], priceID: \"tron\", signatureScheme: \"secp256k1 ECDSA\","630        }631      ]632    }633  ]634}635
Files main
Menu

Theme