This repository has been archived by the owner on Sep 15, 2024. It is now read-only.
GiuseppeDeLaZara - TOFTMarketReceiverModule::marketBorrowReceiver
flow is broken
#137
Labels
Medium
A valid Medium severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
GiuseppeDeLaZara
high
TOFTMarketReceiverModule::marketBorrowReceiver
flow is brokenSummary
The
TOFTMarketReceiverModule::marketBorrowReceiver
flow is broken and will revert when the Magnetar contract tries to transfer the ERC1155 tokens to the Market contract.Vulnerability Detail
TOFTMarketReceiverModule::marketBorrowReceiver
flow is broken.Let's examine it more closely:
marketHelper
,magnetar
and themarket
contracts an approval is made to the Magnetar contract.MagnetarCollateralModule::depositAddCollateralAndBorrowFromMarket
get called with the passed parameters.data.deposit
is true, the Magnetar contract will call_extractTokens
with the following params:from = msg_.user
,token = collateralAddress
andamount = msg_.collateralAmount
.msg._user
has given sufficient allowance to the Magnetar contract through the Pearlmit contract._setApprovalForYieldBox(data.market, yieldBox_);
is called that sets the allowance of the Magnetar contract to the Market contract.addCollateral
is called on the Market contract. I've inlined the internal function to make it easier to follow:userCollateralShare
mapping is updatedpearlmit.transferFromERC1155(from, address(this), address(yieldBox), collateralId, share);
gets called._setApprovalForYieldBox(data.market, yieldBox_);
, nothing else.transferFromERC1155
function when the allowance is being checked.Other occurrences
TOFT::mintLendXChainSGLXChainLockAndParticipateReceiver
has a similar issue as:BBCollateral::addCollateral
the_addTokens
again expects an allowance through the Pearlmit contract.TOFT::lockAndParticipateReceiver
calls theMagnetar:lockAndParticipate
where:Impact
The
TOFTMarketReceiverModule::marketBorrowReceiver
flow is broken and will revert when the Magnetar contract tries to transfer the ERC1155 tokens to the Market contract. There are also other instances of similar issues.Code Snippet
Tool used
Manual Review
Recommendation
Review all the allowance mechanisms and ensure that they are correct.
The text was updated successfully, but these errors were encountered: