Skip to content

fix(utils): validate long-item length before loading it in RLP decoding - #162

Merged
luiz-lvj merged 1 commit into
masterfrom
fix/rlp-validate-long-length
Sep 16, 2026
Merged

luiz-lvj merged 1 commit into
masterfrom
fix/rlp-validate-long-length

Conversation

@luiz-lvj

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

Copy link
Copy Markdown
Collaborator

Summary

Ports OpenZeppelin/openzeppelin-contracts#6418 from openzeppelin-contracts 5.7.

When decoding a long string or long list, lengthLength bytes were loaded before checking itemLength > lengthLength, allowing an out-of-bounds read on malformed input. Validate the length first, and compute the payload bound with subtraction (itemLength - lengthLength > len) to avoid overflow.

@luiz-lvj
luiz-lvj force-pushed the fix/rlp-validate-long-length branch from ab5c42d to 7e248e4 Compare September 15, 2026 12:21

@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

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

When decoding a long string or long list, `lengthLength` bytes were loaded before checking `itemLength > lengthLength`, allowing an out-of-bounds read on malformed input. Validate the length first, and compute the payload bound with subtraction (`itemLength - lengthLength > len`) to avoid overflow.

Upstream changed only the contract. Compiles clean under solc 0.8.26 (the tron-solc frontend); the TVM RLP suite runs in CI.
@luiz-lvj
luiz-lvj force-pushed the fix/rlp-validate-long-length branch from 7e248e4 to a088dad Compare September 16, 2026 14:21
@luiz-lvj
luiz-lvj merged commit 7b00062 into master Sep 16, 2026
18 checks passed
@luiz-lvj
luiz-lvj deleted the fix/rlp-validate-long-length branch September 16, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants