Tadle

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

In `PreMarkert::listOffer` when `offerSettleType` is in `Turbo`, the maker's `originOffer` is not upadted to show that it has a `Sublisted` offer on it.

Summary

When listing an offer in PreMarkert::listOfferin Turbo Mode, the contract updates the AbortOfferStatus to show that a sub-Offer has been listed but the variable(originOfferInfo) is in memory hence this assignment is not stored in persitent Storage to be seen by other functions.

Vulnerabilty Details

In PreMarkert::listOffer, checks are made to see if the originOffer of the maker of the stock to be listed is in turbo mode inorder to specify whether it has a subOffer or not.

if (makerInfo.offerSettleType == OfferSettleType.Turbo) {
.....code....
}

The information about this originOffer is fetched and stored in a variable calledoriginOfferInfo, but this variable is in memory but not storage;-

address originOffer = makerInfo.originOffer;
OfferInfo memory originOfferInfo = offerInfoMap[originOffer];

This makes the assignment below to be lost at the end of the function's excution, and the AbortOfferStatus of this offer won`t change to be utilised/seen by other functions.

originOfferInfo.abortOfferStatus = AbortOfferStatus.SubOfferListed;

Impact

The originOffer's offerSettleType won't be updated and will remain in initialized after the end of the function execution making other function which check this state like preMarkets::abortAskOffer unable to know the offer's collect state, hence can be aborted and collateral refunded, making the Sublisted offer to be without collateral since its in turbo mode.

Tools Used

Manual Review

Recommendation

Consider changing the memory keyword to Storage in PreMarkert::listOffer when an offer is in trubo mode to ensure all changes made to it are stored permanently.

address originOffer = makerInfo.originOffer;
- OfferInfo memory originOfferInfo = offerInfoMap[originOffer];
+ 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.