The current implementation of the abortOfferStatus
update(in listOffer
function) for originOfferInfo
contains critical issues. The status is incorrectly updated in memory instead of storage.
The abortOfferStatus
is being updated in memory
instead of storage
, leading to the update not being persisted. This results in the status not reflecting the actual state of the offer after the function execution.
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L335-L343
Add the following POC in PreMarkets.t.sol
:
Due to above issue as it is not updating the storage, the turbo
settlementType offers which will have subOffer
listed can also be aborted by calling abortAskMaker
. This will cause loss of funds for the protocol since in turbo
mode, subOffers are not collateralized and due to abort
of offer, they will get the collateral.
Consider following scenario to understand the impact:
Maker M1
listed 100 points for 100 USDC
in turbo mode
Taker T1
bought 100 points for 100 USDC
from M1
Taker T1
listed the 100 points for 200 USDC
Buyer B1
bought 100 points for 200 USDC
from T1
.
If M1
calls abortAskOffer
and aborts the offer and take the collateral back, who will settle the stock
of Buyer B1
.
Manual review
Fixed code:
Valid high severity, because the `abortOfferStatus` of the offer is not updated and persist through `storage` when listing an offer for turbo mode within the `offerInfoMap` mapping, it allows premature abortion given the `abortOfferStatus` defaults to `Initialized`, allowing the bypass of this [check](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L552-L557) here and allow complete refund of initial collateral + stealing of trade tax which can potentially be gamed for profits using multiple addresses
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.