fix(utils): validate long-item length before loading it in RLP decoding - #162
Merged
Merged
Conversation
luiz-lvj
force-pushed
the
fix/rlp-validate-long-length
branch
from
September 15, 2026 12:21
ab5c42d to
7e248e4
Compare
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
force-pushed
the
fix/rlp-validate-long-length
branch
from
September 16, 2026 14:21
7e248e4 to
a088dad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports OpenZeppelin/openzeppelin-contracts#6418 from openzeppelin-contracts 5.7.
When decoding a long string or long list,
lengthLengthbytes were loaded before checkingitemLength > 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.