In the abortBidTaker function, the depositAmount is incorrectly calculated. This leads to an incorrect amount being added to the users balance, which could lead to loss of funds.
In the abortBidTaker() function, the depositAmount is incorrectly calculated:
Here it is calculate as (stockInfo.points x preOfferInfo.points) / preOfferInfo.amount.
A malicious attacker could use this incorrect calculation to his advantage and get more amount than he deserves.
One such scenario is:
Assume Bob creates an ask offer of 100points for 2USDC, and giving 2USDC collateral.
Alice takes this offer (createTaker
), 50 points, and paying 1USDC. (increasing BOB's balance by 1USDC + tax + platformfee)
Bob aborts his ask offer (abortAskOffer) and is refunded 1 USDC.
Alice now aborts her stock (generated in createTaker
function), by callign the abortBidTaker() function.
Here the depositAmount is wrongly calculated as (50x100)/2 = 2500
Alice is thus refunded 2500USDC instead of the 1USDC she should have been.
Note that for the sake of simplicity small numbers have been used. But in a real world scenario, if alice and bob work together, they can make the discrepancy very large.
In the worst case scenario malicious attacker can completely drain the funds of the contract using the method shown above, and in the best case users funds are calculated incorrectly.
Manual Review
Change the calculation of depositAmount (line 671) as follows:
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.
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.