Vulnerability details
function teleport(
uint32 dstEid,
address to,
uint256 amount,
bytes calldata options
) external payable override returns(MessagingReceipt memory receipt) {
if (amount == 0) { revert CommonEventsAndErrors.ExpectedNonZero(); }
if (to == address(0)) { revert CommonEventsAndErrors.InvalidAddress(); }
bytes memory _payload = abi.encodePacked(to.addressToBytes32(), amount);
temple.burnFrom(msg.sender, amount);
emit TempleTeleported(dstEid, msg.sender, to, amount);
receipt = _lzSend(dstEid, _payload, options, MessagingFee(msg.value, 0), payable(msg.sender));
}
The tokens refunded to msg.sender
may not be recoverable if the caller doesn' have control over it (for example, when caller is using a multisig wallet contract or the transaction is sent by other address).
Proof of Concept
receipt = _lzSend(
dstEid,
_payload,
options,
MessagingFee(msg.value, 0),
payable(msg.sender)
)
msg.sender
is set as refund address which might not be controlled by user.
Impact
The refund address is incorrectly set. The original user loses refund layerzero fees.
Recommended Mitigation Steps
Set the LayerZero refund address to a user input address:
receipt = _lzSend(
dstEid,
_payload,
options,
MessagingFee(msg.value, 0),
refundAddress
)