Tadle

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

Incorrect Calculation in `PreMarkets.abortBidTaker()`.

Summary

abortBidTaker() calcualtes depositAmount incorrectly.

Vulnerability Details

While calculating depositAmount in abortBidTaker() using mulDiv, it uses an incorrect order.

File: PreMarkets.sol
671: uint256 depositAmount = stockInfo.points.mulDiv(
672: preOfferInfo.points,
673: preOfferInfo.amount,
674: Math.Rounding.Floor
675: );

Currently, depositAmount will be stockInfo.points * preOfferInfo.points / preOfferInfo.amount which is incorrect.

Impact

Possible loss of funds in abortBidTaker() due to the incorrect calculation.

Tools Used

Manual Review

Recommendations

It should be fixed like this.

uint256 depositAmount = stockInfo.points.mulDiv(
- preOfferInfo.points,
- preOfferInfo.amount,
+ preOfferInfo.amount,
+ preOfferInfo.points,
Math.Rounding.Floor
);
Updates

Lead Judging Commences

0xnevi Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-PreMarkets-abortBidTaker-amount-wrong-StockInfo-points

Valid high severity, due to incorrect computation of `depositAmount` within `abortBidTaker`, when aborting bid offers created by takers, the collateral refund will be completely wrong for the taker, and depending on the difference between the value of `points` and `amount`, it can possibly even round down to zero, causing definite loss of funds. If not, if points were worth less than the collateral, this could instead be used to drain the CapitalPool contract instead.

Support

FAQs

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