TOFT exerciseOption
can be used to steal all underlying erc20 tokens
#1307
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
edited-by-warden
H-11
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#L255
Vulnerability details
Impact
Unvalidated input data for the
exerciseOption
function can be used to steal all the erc20 tokens from the contract.Proof of Concept
Each BaseTOFT is a wrapper around an
erc20
token and extends theOFTV2
contract to enable smooth cross-chain transfers through LayerZero.Depending on the erc20 token which is used usually the erc20 tokens will be held on one chain and then only the shares of
OFTV2
get transferred around (burnt on one chain, minted on another chain).Subject to this attack is
TapiocaOFTs
ormTapiocaOFTs
which store as an underlying token an erc20 token(not native). In order to mintTOFT
shares you need to deposit the underlying erc20 tokens into the contract, and you getTOFT
shares.The attack flow is the following:
exerciseOption
. Nothing is validated here and the only cost of the attack is theoptionsData.paymentTokenAmount
which is burned from the attacker. This can be some small amount.exercise
function it is important that nothing reverts for the attacker.The underlying
ERC20
token for eachTOFT
can be queried througherc20()
function, and thetapAmount
to pass isERC20
balance of theTOFT
.This attack is possible because the
msg.sender
inside theexerciseInternal
is the address of theTOFT
which is the owner of all the ERC20 tokens that get stolen.Tools Used
Recommended Mitigation Steps
Validate that
tapSendData.tapOftAddress
is the address ofTapOFT
token either while sending the message or during the reception of the message on the remote chain.Assessed type
Token-Transfer
The text was updated successfully, but these errors were encountered: