When a bid order is aborted, the user will receive the wrong amount of collateral as a refund (higher or lower than expected depending on the offer condition).
The calculation for getting back collateral after the order is aborted is wrong.
Currently, it's (stockInfo.points * preOfferInfo.points) / preOfferInfo.amount
, but it should be instead (stockInfo.points * preOfferInfo.amount) / preOfferInfo.points
:
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L671-L675
Alice creates an ASK offer for 1000 points and 2000 collateral
Bob creates a BID order to buy 400 points, sending 800 as payment
Bob aborts and calls abortBidTaker
, he should receive 800:
(stockInfo.points * preOfferInfo.amount) / preOfferInfo.points
-> 400 * 2000 / 1000 = 800
But he received 200 instead, so he lost 600:
(stockInfo.points * preOfferInfo.points) / preOfferInfo.amount
-> 400 * 1000 / 2000 = 200
If offer points were worth less than the collateral (e.g. 2000 points for 1000 collateral), Bob could abuse this to drain the pool instead
Impact: High (Protocol funds drained or loss of user funds)
Likelihood: High (No preconditions)
Risk: Critical
Manual review
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L671-L675
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.