The listOffer() function in the PreMarkets.sol contract incorrectly attempts to update the abortOfferStatus of an originOfferInfo using a memory variable. Since memory variables do not persist changes to the contract’s state, this results in the inability to properly update the abortOfferStatus. A sub-offer maker can exploit this vulnerability to abort the main offer and subsequently steal funds from the sub-offer takers.
The function attempts to modify the abortOfferStatus of originOfferInfo.
However, originOfferInfo is a memory variable, meaning that any changes made to it do not persist to the contract’s storage. This means the actual abortOfferStatus in storage remains unchanged.
This vulnerability is critical because it allows sub-offer makers to exploit the system:
Theft of Funds: Sub-offer makers can abort the main offer despite having active sub-offers. This action can enable them to access and potentially steal the funds deposited by sub-offer takers, leading to significant financial losses for those users.
Market Disruption: The ability to abort offers with active sub-offers undermines the integrity of the market and can lead to severe disruptions in the settlement process, eroding trust in the system.
A sub-offer maker can use this flaw to abort the main offer, allowing them to access the funds associated with the sub-offers. Since the system doesn’t properly register the presence of sub-offers due to the unupdated abortOfferStatus, it fails to enforce the necessary restrictions.
This is the test code.
The result of test is like this.
As you can see, aborting of the sub-offer taker (user3) is failed, and the sub-offer maker (user2) stole the funds deposited by the sub-offer taker (user3).
Manual code review
Replace the memory keyword with storage for originOfferInfo to ensure that changes to abortOfferStatus are correctly persisted in the contract's storage.
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.