Skip to content

Harden input validation across Bitcoin UTXO, Aptos, Sui, EOS and Icon signers#4798

Open
nikhil-gupta-tw wants to merge 13 commits into
masterfrom
fix/sec-issues-4
Open

Harden input validation across Bitcoin UTXO, Aptos, Sui, EOS and Icon signers#4798
nikhil-gupta-tw wants to merge 13 commits into
masterfrom
fix/sec-issues-4

Conversation

@nikhil-gupta-tw

@nikhil-gupta-tw nikhil-gupta-tw commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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:

  • Added range validation for chain_id in TransactionFactory::new_from_protobuf, returning an error if the value is outside the u8 range.
  • Added a check in the Sui ProgrammableTransactionBuilder to ensure the number of recipients/amounts does not exceed the u16 argument index limit, returning an error if exceeded.
  • In Bitcoin transaction signing (TransactionSigner), added validation to ensure amount, change, and fee in a transaction plan are non-negative, returning an error if invalid. [1] [2]
  • In EOS Signer::buildTx, added a check to ensure asset decimals do not exceed 18, throwing an exception if the value is out of range.
  • Improved input parsing in the generic signTemplate function to handle parsing failures gracefully by setting an appropriate error in the output.

Other improvements:

  • Removed the noexcept qualifier from the Icon::Signer::encode method declaration and definition, aligning its signature and allowing exceptions to propagate if needed. [1] [2]
  • Added a code comment clarifying the safety of casting indices to u16 in the Sui transaction builder, given the new validation.

@nikhil-gupta-tw nikhil-gupta-tw requested review from a team and BSCSecChef as code owners June 9, 2026 13:19
@octane-security-app

Copy link
Copy Markdown

Summary by Octane

New Contracts

No new contracts were added.

Updated Contracts

  • transaction_builder.rs: The key change is improved error handling for 'chain_id' conversion with a new validation and specific error context.
  • programmable_transaction.rs: The update adds a check for a recipient/amount limit, returning an error if it exceeds u16::MAX.
  • TransactionSigner.cpp: The smart contract now includes transaction plan validation to ensure non-negative values and correct UTXO sum balance.
  • Signer.cpp: Implemented a validation to ensure EOS asset decimals do not exceed 18.
  • Signer.cpp: Removed noexcept from the encode function, possibly allowing exceptions.

🔗 Commit Hash: fc4489d

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

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

@octane-security-app

Copy link
Copy Markdown

Overview

Vulnerabilities found: 5                                                                                
Severity breakdown: 2 Medium, 2 Low, 1 Informational

Detailed findings

src/Bitcoin/TransactionSigner.cpp

  • Incorrect plan validation in Bitcoin TransactionSigner causes DoS and segwit fee-estimation degradation. See more
  • Missing revalidation of imported plan.utxos in Bitcoin signing path causes fee drain and potential DoS. See more
  • Unchecked signed integer arithmetic in Bitcoin UTXO validatePlan causes DoS/correctness degradation on imported-plan signing/preimage flows. See more

src/EOS/Signer.h

  • Exception introduced in EOS::Signer::buildTx crossing noexcept helpers causes process termination (DoS) in preimage/compile paths. See more

src/Zcash/TransactionBuilder.h

  • Unchecked variable-length branch_id copied into 4-byte buffer in Zcash TransactionBuilder causes memory corruption or invalid signatures. See more

🔗 Commit Hash: fc4489d
🛡️ Octane Dashboard: All vulnerabilities

@sergei-boiko-trustwallet sergei-boiko-trustwallet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@BSCSecChef BSCSecChef left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Check on the value 30 here -

    transaction_expiration_time: 30,
    - probably just add in comment so callers can handle the expiration at their end.

  2. Check on this too -

    /// Will fail to generate if given an empty ObjVec

The comment says - "Will fail to generate if given an empty ObjVec"

but the function takes Vec

  1. 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.

  2. Also, I would suggest to add in ? with unwrap calls -

    let rec_arg = self.pure(recipient).unwrap();

Although, this is not going to trigger at all but still avoiding panic on FFI boundaries

  1. Change is to add in throw in buildTx, but here the function uses noexcept -
    std::string Signer::buildSignedTx(const Proto::SigningInput& input, const Data& signature) noexcept {

but internally calls buildTx

same here too -

Data Signer::buildUnsignedTx(const Proto::SigningInput& input) noexcept {

  1. Also, probably add in a comment that caller needs to validate this -
    Transaction(Data(input.reference_block_id().begin(), input.reference_block_id().end()),

reference_block_id and reference_block_time

  1. Do check here, if validation is required for address, value, network_id etc -
    Proto::SigningOutput Signer::sign() const {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants