Fix critical memory offset bug in FiatTokenUtil#658
Open
Kewe63 wants to merge 1 commit into
Open
Conversation
mikwespinoza-ux
approved these changes
Jul 10, 2026
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
Fix incorrect assembly memory offsets in
_unpackAddressesthat causedtransferWithMultipleAuthorizationsto decode wrong addresses, leading to failed or misdirected batch transfers.Detail
In
FiatTokenUtil.sol, the_unpackAddressesfunction uses inline assembly to extract two 20-byte addresses from a packedbytes memoryparameter. The original code used offsets 20 and 40:addr1 := mload(add(packed, 20))addr2 := mload(add(packed, 40))This is incorrect because Solidity stores
bytes memoryvariables with a 32-byte length prefix in memory. Using offset 20 reads 12 bytes of the length field mixed with 20 bytes of the first address, producing a completely wrong value.Correct offsets:
addr1at offset 32 (skip the 32-byte length prefix)addr2at offset 52 (32 + 20 bytes of the first address)This bug affected
transferWithMultipleAuthorizations, the only external function that calls_unpackAddresses. Every batch transfer attempt would either revert or send tokens to incorrect addresses.Testing
transferWithMultipleAuthorizationscorrectly decodesfromandtoaddresses for a single transfertransferWithMultipleAuthorizationscorrectly decodes addresses for multiple transfers in a single batchDocumentation
No documentation changes required. This is an internal assembly-level fix with no changes to function signatures or external behavior.
Requested Reviewers: @Kewe63