TOFT in (m)TapiocaOft contracts can be stolen by calling removeCollateral() with a malicious removeParams.market #1695
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
H-01
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/bcf61f79464cfdc0484aa272f9f6e28d5de36a8f/contracts/tOFT/BaseTOFT.sol#L190
https://github.com/Tapioca-DAO/tapiocaz-audit/blob/bcf61f79464cfdc0484aa272f9f6e28d5de36a8f/contracts/tOFT/BaseTOFT.sol#L516
https://github.com/Tapioca-DAO/tapiocaz-audit/blob/bcf61f79464cfdc0484aa272f9f6e28d5de36a8f/contracts/tOFT/modules/BaseTOFTMarketModule.sol#L230-L231
Vulnerability details
Impact
The
TOFT
available in theTapiocaOFT
contract can be stolen when callingremoveCollateral()
with a malicious market.Proof of Concept
(m)TapiocaOFT
inheritBaseTOFT
, which has a functionremoveCollateral()
that accepts a market address as an argument. This function calls_lzSend()
internally on the source chain, which then is forwarded to the destination chain by the relayer and callslzReceive()
.lzReceive()
reaches_nonBlockingLzReceive()
inBaseTOFT
and delegate calls to theBaseTOFTMarketModule
on functionremove()
. This function approvesTOFT
to theremoveParams.market
and then calls functionremoveCollateral()
of the provided market. There is no validation whatsoever in this address, such that a malicious market can be provided that steals all funds, as can be seen below:The following POC in Foundry demonstrates this vulnerability, the attacker is able to steal all
TOFT
inmTapiocaOFT
:Tools Used
Vscode, Foundry
Recommended Mitigation Steps
Whitelist the
removeParams.market
address to prevent users from providing malicious markets.Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: