TOFT triggerSendFrom
can be used to steal all the balance
#1290
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
edited-by-warden
H-13
primary issue
Highest quality submission among a set of duplicates
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/Tapioca-DAO/tapiocaz-audit/blob/master/contracts/tOFT/modules/BaseTOFTOptionsModule.sol#L142
Vulnerability details
Impact
triggerSendFrom
->sendFromDestination
message pathway can be used to steal all the balance of theTapiocaOFT
andmTapiocaOFT
` tokens in case when their underlying tokens is native gas token.TOFTs that hold native tokens are deployed with erc20 address set to address zero, so while minting you need to transfer value.
Proof of Concept
The attack flow is the following:
triggerSendFrom
withairdropAdapterParams
of type airdropAdapterParamsV1 which don't airdrop any value on the remote chain but just deliver the message.adapterParamsV2
which are used to airdrop the balance from the destination chain to another chain to the attacker.sendFromData.adapterParams
would be encoded in the following way:sendFromDestination
ISendFrom(address(this)).sendFrom{value: address(this).balance}
is instructed by the malicious
ISendFrom.LzCallParams memory callParams
to actually airdrop the max amount allowed by LayerZero to the attacker on thelzDstChainId
.The core issue at play here is that
BaseTOFT
delegatecalls into theBaseTOFTOptionsModule
and thus the BaseTOFT is themsg.sender
forsendFrom
function.There is also another simpler attack flow possible:
sendFromDestination
passes as value whole balance of the TapiocaOFT it is enough to specify the refundAddress in callParams as the address of the attacker._refundAddress
.Tools Used
Recommended Mitigation Steps
One of the ways of tackling this issue is during the
triggerSendFrom
to:airdropAdapterParams
andsendFromData.adapterParams
params to be passed as bytes but rather asgasLimit
andairdroppedAmount
, from which you would encode eitheradapterParamsV1
oradapterParamsV2
.Assessed type
ETH-Transfer
The text was updated successfully, but these errors were encountered: