using abi.encodePacked
and then decoded using abi.decode
can lead to incorrect decoding, potentially causing the contract to misinterpret the data. As a result, tokens might be minted to unintended addresses, leading to potential loss of funds or tokens being locked up.
Using abi.encodePacked
for encoding and then attempting to decode using abi.decode
can lead to incorrect decoding. This discrepancy can cause issues, such as minting tokens to incorrect addresses or interpreting the wrong amounts, which can result in loss of funds or locked tokens.
, abi.encodePacked
combines the address and amount into a byte array without any delimiters or type information, causing abi.decode
to fail or produce incorrect values.
https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol%2Fcontracts%2Ftemplegold%2FTempleTeleporter.sol#L43-L58
Encoding with abi.encodePacked
:
This concatenates the address and amount into a single byte array without retaining the type information
https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol%2Fcontracts%2Ftemplegold%2FTempleTeleporter.sol#L52
Decoding with abi.decode
:
Here, abi.decode
expects the data to be encoded with abi.encode
, which retains type and size information. Since abi.encodePacked
does not do this, abi.decode
cannot correctly interpret the concatenated data.
https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol%2Fcontracts%2Ftemplegold%2FTempleTeleporter.sol#L107
The use of abi.encodePacked
to encode the payload and abi.decode
to decode it can result in incorrect data retrieval, potentially leading to incorrect addresses or amounts being used.
leading to incorrect values for decodedAddress
and decodedAmount
.
If the decoding fails or results in wrong values, tokens might be sent to incorrect addresses or not minted at all, leading to a loss of funds. This could lock up tokens, making them irretrievable.
Manual Review
use abi.encode
instead of abi.encodePacked
for encoding the payload:
This ensures that the encoded data retains the type and size information necessary for correct decoding.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.