Tadle

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

Vulnerability in abortBidTaker Function: Incorrect Calculation of depositAmount

Summary

A vulnerability has been identified in the abortBidTaker function of the smart contract. The error involves the incorrect calculation of the depositAmount variable, which affects how funds are managed during the abort process. The current implementation of the calculation is inaccurate, leading to potential financial discrepancies.

Vulnerability Details

The abortBidTaker function incorrectly calculates the depositAmount variable. The current implementation is:

https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L671

Impact

The incorrect calculation of depositAmount can result in financial discrepancies during the abort process, potentially causing participants to receive incorrect amounts of funds. This issue can undermine the integrity of the contract and lead to unintended financial consequences.

Tools Used

Manual Code Review

Recommendations

To resolve this vulnerability, update the abortBidTaker function to use the corrected calculation for depositAmount. Implement the following change:

uint256 depositAmount = stockInfo.points.mulDiv(
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.