Skip to content

fix(cryptography): decode MultiSignerTRC7913 payload from calldata to avoid abi.decode reverts - #164

Merged
luiz-lvj merged 2 commits into
masterfrom
fix/multisigner-trc7913-calldata-decode
Sep 17, 2026
Merged

luiz-lvj merged 2 commits into
masterfrom
fix/multisigner-trc7913-calldata-decode

Conversation

@luiz-lvj

@luiz-lvj luiz-lvj commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Ports OpenZeppelin/openzeppelin-contracts#6642 (audit finding M-08) from openzeppelin-contracts 5.7.

_rawSignatureValidation used abi.decode(signature, (bytes[], bytes[])), which reverts on malformed encoding. Decode the payload directly from calldata via a bounds-checked helper that returns false on malformed input, so account/paymaster validation can report an invalid signature instead of bubbling up a revert.

The _validateSignatures and _validateThreshold override parameters change from bytes[] memory to bytes[] calldata (also updated in the MultiSignerTRC7913Weighted override).

@luiz-lvj
luiz-lvj requested a review from pepebndc September 15, 2026 15:42
… avoid abi.decode reverts

Port of OpenZeppelin/openzeppelin-contracts#6642 (audit finding M-08), scheduled for openzeppelin-contracts v5.7 and not included in v5.6.1 (the base of this fork).

`_rawSignatureValidation` used `abi.decode(signature, (bytes[], bytes[]))`, which reverts on malformed encoding. Decode the payload directly from calldata via a bounds-checked helper that returns `false` on malformed input, so account/paymaster validation can report an invalid signature instead of bubbling up a revert.

The `_validateSignatures` and `_validateThreshold` override parameters change from `bytes[] memory` to `bytes[] calldata` (also updated in the `MultiSignerTRC7913Weighted` override).

Compiles clean under solc 0.8.26 (the tron-solc frontend); the TVM MultiSignerTRC7913 suites run in CI.
@luiz-lvj
luiz-lvj force-pushed the fix/multisigner-trc7913-calldata-decode branch from a033883 to 108e693 Compare September 15, 2026 18:45

@pepebndc pepebndc 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.

LGTM

@pepebndc

Copy link
Copy Markdown
Collaborator

Upstream #6642 ships six tests for the malformed outer encoding paths (short buffer, offset past calldata, offset near type(uint256).max, length over the uint64 cap, length over the remaining buffer). Port them in a follow-up. The fork has no test for MultiSignerTRC7913 yet, so a minimal exposed harness is enough.

Port upstream #6642's malformed outer-encoding cases as a minimal exposed harness
(the upstream tests live in the account test file this fork omits). Verifies
_rawSignatureValidation returns false instead of reverting on a short buffer,
out-of-bounds offsets, and oversized array lengths.
@luiz-lvj

Copy link
Copy Markdown
Collaborator Author

Added test/utils/cryptography/signers/MultiSignerTRC7913.test.js covering the six malformed outer-encoding cases from #6642 (short buffer, offset past calldata, offset near type(uint256).max, and array lengths over the uint64 cap and over the remaining buffer), against a minimal exposed $MultiSignerTRC7913 harness. Each asserts _rawSignatureValidation returns false instead of reverting.

@luiz-lvj
luiz-lvj merged commit b51cd2c into master Sep 17, 2026
16 of 18 checks passed
@luiz-lvj
luiz-lvj deleted the fix/multisigner-trc7913-calldata-decode branch September 17, 2026 18:34
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.

2 participants