When makerInfo.offerSettleType == OfferSettleType.Protected in the PreMarkets.sol#listOffer() function, severe fund loss in the protocol may occur due to lack of validation for _collateralRate.
In the PreMarkets.sol#listOffer() function, if the offer settlement type is protected, it is transferred from the collateral caller to the CapitalPool contract.
The transferAmount is calculated according to collateralRate in stockInfo.preOffer.
Next, set the entered _collateralRate to the collateralRate of the offer.
Meanwhile, the PreMarkets.sol#closeOffer() function uses the collateralRate of the offer in the OfferLibraries.sol#getRefundAmount() function to update refund token from capital pool to balance.
As a result, users can steal funds from the protocol by intentionally entering a large _collateralRate.
Alice calls listOffer with _collateralRate = 12000 (120%) and _amount = 100 ehter.
At this time, assume that collateralRate = 10000 (100%) of stockInfo.preOffer.
At this time, transferAmount is calculate as follows:
transferAmount = _amount * offerInfoMap[stockInfo.preOffer].collateralRate / COLLATERAL_RATE_DECIMAL_SCALER =
= 100 ether * 10000 / 10000 = 100 ether
As a result, Alice has paid 100 ether.
Next, the collateralRate of that offer is set to 12000.
Alice immediately calls closeOffer for the offer.
At this time, offerInfo.usedPoints = 0.
Therefore,
refundAmount = offerInfo.amount * offerInfo.collateralRate / COLLATERAL_RATE_DECIMAL_SCALER =
= 100 ether * 12000 / 10000 = 120 ether
As a result, Alice receives 20 ether more than the deposit amount.
Malicous users can steal funds from the protocol by intentionally entering a large _collateralRate.
Manual Review
In the PreMarkets.sol#listOffer() function, if makerInfo.offerSettleType == OfferSettleType.Protected, it is recommended to add the following line:
Valid high severity, because the collateral rate utilized when creating an offer is stale and retrieved from a previously set collateral rate, it allows possible manipilation of refund amounts using an inflated collateral rate to drain funds from the CapitalPool contract
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.