When an Ask/Sell offer is aborted via preMarket::abortAskOffer
the seller withdraws all remaining collateral deposited minus the amount recieved by any BidTaker on that offer, the bidtaker can then withdraw their initial deposited amount via PreMarkets::abortBidTaker
. However , a malicious bidtaker can instead use DeliveryPlace::closeBidTaker
- which only assumes the offer was settled(i.e. doesn't account for settling via Aborting) and refunds the bidtaker their deposit * offer's collateralRate
From PreMarkets::abortAskOffer
we can confirm/verify that the amount returned to maker (makerRefundAmount
) does include all deposited collateral
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L584-L632
Assuming offerInfo.offerStatus == OfferStatus.Virgin
for simplicity (issue still exists even if it's not) and remainingAmount = offerInfo.amount
.
transferAmount
calculated here equals remainingAmount * collateralRate as _isMaker
== true and offerType
is Ask
totalDepositAmount
is always equal to totalUsedAmount
as _isMaker
== false & offerType
is Ask. makerRefundAmount
= totalDepositAmount
- totalUsedAmount
.
So Maker is redunded all their deposited collateral minus the amount they recieved by any BidTaker on that offer.
PreMarkets::abortBidTaker
only refunds the BidTaker deposit amount
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L671-L683
depositAmount
== transferAmount
as _isMaker
== false & offerType
is Ask
However , from DeliveryPlace::closeBidTaker
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L151-L176
The amound refunded collateralFee
is equal to usedAmount
* collateralRate
as _isMaker
== true and offerType
is Ask. collateralFee
>= usedAmount
because of the invariant collateralRate
>= 1 .
The bid taker withdraws more funds than their supposed to.
HIGH - If offer maker is in cahoots with BidTaker or perhaps same person ,with sufficient capital to cover initial collateral deposit on the offer , this exploit can be repeated over and over to completely drain contract funds
Manual Review
Check the abortOfferStatus
of the offer, if aborted then _isMaker
== false so collateralFee
== usedAmount
.
Valid high, for unsettled ask offers by the original maker, the initial remaining maker collateral is already refunded as seen [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L624-L629)
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.