quote function uses incorrect message encoding, different from the actual teleport function. This results in a smaller message size (52 bytes vs 64 bytes), leading to underestimation of a required fee. Consequently, users relying on these quotes will likely experience transaction failures due to insufficient fees when attempting token transfers through Teleporter.
The problem is in this part of the quote function:
See: TempleTeleporter.sol#L78-L94
It calculates a require fee to pay to LayerZero cross-chain messaging, in this case, cross-chain tokens transfer. However, it uses an a different message encoding from the actual message encoding in teleport function.
See: TempleTeleporter.sol#L34-L58
quote uses abi.encodePacked(_to, _amount) which creates a 52-byte messages (20 bytes address + 32 bytes for uint)
teleport uses abi.encodePacked(to.addressToBytes32(), amount) which creates a 64-byte message
Because the quote function uses a shorter message than the actual transfer, it always calculates an underestimated fee.
Users who use quote to calculate fee for teleport function will always have their transaction revert from insufficient fee
When considering the typical user flow for cross-chain transfers, users are expected to first call the quote function to estimate the required fee, and then use this estimate when calling the teleport function.
However, because the quote function consistently return an underestimated fee, users following this path will always have their transaction revert due to insufficient fee. Thus, breaking the protocol's functionality.
Besides, it's worth nothing that in constast to this, if quote function were to overestimate the fee, the calculation is still incorrect but the execution is not interrupted and the overpaid fee will be refunded.
Hence, incorrect calculation of fee that always result in an underestimated fee in this case should have Medium severity.
The following test shows that:
fee calculation using an incorrect message encoding results in underestimated fee.
Calling teleport function with underestimated fee results in revert with insufficient fee.
Steps
Apply below git diff to the repo.
Run forge t --match-contract TempleTeleporterTest --match-test test_quote_incorrect_fee -vv
Observe that the test fail due to LZ_InsufficientFee
Correct payload (message) encoding to match with the one use in teleport function
See: https://docs.layerzero.network/v2/developers/evm/gas-settings/gas-fees
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.