Tadle

Tadle
DeFiFoundry
27,750 USDC
View results
Submission Details
Severity: high
Valid

Incorrect Storage Handling in `listOffer` Function Allows Turbo Offers to be Aborted

Summary

The listOffer function incorrectly handles the storage update of the abortOfferStatus field for offers with the Turbo settlement type. Due to this mistake, offers that should not be abortable under the Turbo settlement type can still be canceled, leading to potential disruptions and exploitation in the system.

Vulnerability Details

In the listOffer function, when an offer's settlement type is Turbo, the function attempts to change the abortOfferStatus of the previous offer linked to the stock to AbortOfferStatus.SubOfferListed to prevent the offer from being aborted. However, this change is made to a memory copy of the offer information rather than updating the storage directly. The relevant code snippet is as follows:

if (makerInfo.offerSettleType == OfferSettleType.Turbo) {
address originOffer = makerInfo.originOffer;
OfferInfo memory originOfferInfo = offerInfoMap[originOffer];
if (_collateralRate != originOfferInfo.collateralRate) {
revert InvalidCollateralRate();
}
originOfferInfo.abortOfferStatus = AbortOfferStatus.SubOfferListed;
}

Here, originOfferInfo is a memory variable, meaning any changes to abortOfferStatus are not persisted in storage. As a result, the original abortOfferStatus remains unchanged in storage, allowing offers that should be locked under the Turbo settlement type to be aborted.

Impact

This vulnerability allows offers with the Turbo settlement type to be canceled even after they have been listed. This contradicts the intended functionality, which should prevent such offers from being aborted. The issue could be exploited by malicious users to bypass the system's restrictions, leading to financial loss.

Tools Used

Manual Code Review

Recommendations

Use Storage Instead of Memory

OfferInfo storage originOfferInfo = offerInfoMap[originOffer];
Updates

Lead Judging Commences

0xnevi Lead Judge 12 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-PreMarkets-listOffer-originIOfferInfo-storage-memory

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

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.