Harden input validation across Bitcoin UTXO, Aptos, Sui, EOS and Icon signers#4798
Harden input validation across Bitcoin UTXO, Aptos, Sui, EOS and Icon signers#4798nikhil-gupta-tw wants to merge 13 commits into
Conversation
…ead of silently returning partial transactions
…urn value to prevent process crash on invalid input
…rain and fund theft across UTXO chains
…ly wrapping modulo 256
…prevent silent index wrap during signing
…prevent silent precision wrap
Summary by OctaneNew ContractsNo new contracts were added. Updated Contracts
🔗 Commit Hash: fc4489d |
Binary size comparison➡️ aarch64-apple-ios: - 14.31 MB
+ 14.31 MB +4 KB➡️ aarch64-apple-ios-sim: - 14.32 MB
+ 14.32 MB +3 KB➡️ aarch64-linux-android: - 18.73 MB
+ 18.73 MB +7 KB➡️ armv7-linux-androideabi: - 16.17 MB
+ 16.17 MB +5 KB➡️ wasm32-unknown-emscripten: - 13.66 MB
+ 13.66 MB +3 KB |
Overview
Detailed findings
|
BSCSecChef
left a comment
There was a problem hiding this comment.
-
Check on the value 30 here -
- probably just add in comment so callers can handle the expiration at their end. -
Check on this too -
The comment says - "Will fail to generate if given an empty ObjVec"
but the function takes Vec
-
PR says this - "and that the sum of UTXOs matches the total output" where is this one present? Don't seem to see it in TransactionSigner.cpp - Do update the description.
-
Also, I would suggest to add in ? with unwrap calls -
Although, this is not going to trigger at all but still avoiding panic on FFI boundaries
- Change is to add in throw in buildTx, but here the function uses noexcept -
wallet-core/src/EOS/Signer.cpp
Line 129 in c908296
but internally calls buildTx
same here too -
wallet-core/src/EOS/Signer.cpp
Line 124 in c908296
- Also, probably add in a comment that caller needs to validate this -
wallet-core/src/EOS/Signer.cpp
Line 115 in c908296
reference_block_id and reference_block_time
- Do check here, if validation is required for address, value, network_id etc -
wallet-core/src/Icon/Signer.cpp
Line 79 in c908296
This pull request introduces several input validation improvements and error handling enhancements across multiple blockchain transaction builders and signers. The main focus is on ensuring that invalid or out-of-range parameters are caught early, preventing the construction or signing of malformed transactions.
Input validation and error handling:
chain_idinTransactionFactory::new_from_protobuf, returning an error if the value is outside theu8range.ProgrammableTransactionBuilderto ensure the number of recipients/amounts does not exceed theu16argument index limit, returning an error if exceeded.TransactionSigner), added validation to ensureamount,change, andfeein a transaction plan are non-negative, returning an error if invalid. [1] [2]Signer::buildTx, added a check to ensure asset decimals do not exceed 18, throwing an exception if the value is out of range.signTemplatefunction to handle parsing failures gracefully by setting an appropriate error in the output.Other improvements:
noexceptqualifier from theIcon::Signer::encodemethod declaration and definition, aligning its signature and allowing exceptions to propagate if needed. [1] [2]u16in the Sui transaction builder, given the new validation.