TempleGold

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

check bytes data length before abi.decode

Summary

The data length is not checked before abi.decode, which could result in wrong address being decoded, and lose some amount, or fail the transaction.

Vulnerability Details

lzReceive() does not check payload length before decoding, if bytes data is provided, the recipient address could be wrong and lose the recipient amount. Or get wrong recipient.

function _lzReceive(
Origin calldata /*_origin*/,
bytes32 /*_guid*/,
bytes calldata _payload,
address /*_executor,*/, // Executor address as specified by the OApp.
bytes calldata /*_extraData */ // Any extra data or options to trigger on receipt.
) internal override {
// Decode the payload to get the message
(address _recipient, uint256 _amount) = abi.decode(_payload, (address, uint256));
temple.mint(_recipient, _amount);
}

https://github.com/Cyfrin/2024-07-templegold/blob/57a3e597e9199f9e9e0c26aab2123332eb19cc28/protocol/contracts/templegold/TempleTeleporter.sol#L99C5-L109C6

Impact

  • Some amount could be lost if decoded the wrong address, such as the recipient.

  • Some function call might fail if adapter is wrongly decoded.

Tools Used

Manual Review

Recommendations

  • Add check for the bytes data length before abi.decode.

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.