In the PreMarkets.abortBidTaker
function, msg.sender
receives tokens that he deposited in PreMarkets.createTaker
function.
But, calculation of depositAmount
is not correct and a malicious attacker can drain the protocol by leveraging this.
In the createTaker
function, depositAmount
is calculated as Ceil(_points * offerInfo.amount / offerInfo.points)
In the abortBidTaker
function, depositAmount
is calculated as Floor(_points * offerInfo.points / offerInfo.amount)
depositAmount
in createTaker
and abortBidTaker
function are different.
Let's assume the following scenario:
step1: Alice, the initial market maker, lists 1000e18 points for sale at 10 USDC(1e7 wei).
step2: Alice buys 500e18 points from origin offer of step1. She deposits 5 USDC.
depositAmount = 500e18 * 1e7 / 1000e18 = 5e6
step3: She aborts bid taker of step2. She receives 5e28 USDC.
depositAmount = Floor(500e18 * 1000e18 / 1e7) = 5e34
In step2, Alice deposits 5USDC, but she receive any 5e28 USDC(5e34 wei) in step3.
As a result, a malicious attacker can drain the protocol.
As a result, a malicious attacker can drain the protocol.
Manual Review
It is recommended to change the code as following:
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.