TempleGold

TempleDAO
Foundry
25,000 USDC
View results
Submission Details
Severity: low
Invalid

MisAlignment can occur on _lzReceive

Summary

The teleport function send 64 bytes but only decodes 52 bytes which can lead to chopping of some data in the amount sent and cause users to mint less than they burned when bridging through the TempleTeleport contract, due to misalignment of encoding and decoding.

Vulnerability Details

In the function teleport at https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol/contracts/templegold/TempleTeleporter.sol#L43 , payload is encoded to bytes32 to force padding of 20 bytes address payload to 32 bytes as seen here https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol/contracts/templegold/TempleTeleporter.sol#L52

In the _lzReceive function at https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol/contracts/templegold/TempleTeleporter.sol#L99 , the decoding decodes with (address, uint256), mind you 64 bytes was encoded at teleport, but 52 bytes are decoded at _lzReceive.

This means that the first 20 bytes is decoded as address, in _lzReceive, and then the next 32 bytes is decoded as amount, this could result in chopping off amounts for large amount of tokens teleported through layerzero bridge.

The likelihood of this happening is low as it would require large amount of tokens to notice this,
The impact of this is high as users would lose some funds on bridging

Impact

The impact of this is high as users would lose some funds on bridging

Tools Used

Manual Review

Recommendations

(bytes32 _bytesrecipient, uint256 _amount) = abi.decode(_payload, (bytes32, uint256));
address _recipient = address(uint160(uint256(_bytesrecipient)));
Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

`abi.encodePacked` to encode it while on the recieving it uses `abi.decode()` to decode the payload and it doesn't work like that

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.