A vulnerability has been identified in the listOffer function where the originOfferInfo struct is defined as a memory variable instead of storage. This issue leads to the incorrect handling of the abortOfferStatus attribute, potentially resulting in inconsistent contract state and unexpected behavior.
In the listOffer function, the originOfferInfo struct is intended to reference an existing offer's state in storage. However, it is incorrectly defined as a memory variable, which creates a temporary copy of the data rather than pointing to the original data in storage. As a result, any modifications made to abortOfferStatus do not persist beyond the function execution.
The relevant code snippet is:
Here, the abortOfferStatus attribute is updated in memory but not in storage, leading to the change being discarded when the function execution ends.
The improper use of memory instead of storage results in the abortOfferStatus attribute not being updated correctly. This can cause the contract to function incorrectly, with offers that should be marked as aborted still being treated as active. It could lead to potential exploits or unintended consequences where aborted offers are mistakenly processed.
Manual Code Review
To fix this vulnerability, the originOfferInfo variable should be defined as a storage type, ensuring that any changes to the abortOfferStatus attribute are correctly persisted to the blockchain's storage.
The corrected code snippet would look like this:
This change ensures that the abortOfferStatus is properly updated in the contract's storage, preventing any inconsistencies or potential vulnerabilities.
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.