The current implementation of the refund mechanism in the PreMarkets::abortBidTaker
function allows a malicious actor to drain the collateral pool by manipulating points and aborting offers. The issue arises because the refund is incorrectly calculated as (remaining points * total points) / amount
instead of (remaining points * amount) / total points
. This allows an attacker to exploit the system by creating offers with a higher absolute value of points compared to the amount, buying a small fraction of the order with another account, and then aborting the offer to receive an inflated refund.
When an offer is aborted using PreMarkets::abortBidTaker
, the refund to buyers is calculated as (remaining points * total points) / amount
instead of (remaining points * amount) / total points
:
This discrepancy allows a malicious actor to exploit the system by:
Creating an offer where the absolute value of points is higher than the absolute value of the amount, so that it is advantageous to multiply by points and divide by amount, vs the opposite.
Using another account to buy a small fraction of the offer.
Aborting the offer with both accounts, causing the system to calculate an inflated refund using the incorrect formula.
The attacker receives a refund that is larger than the amount originally paid, draining the protocol funds.
This vulnerability can lead to the protocol's funds being completely drained. By creating offers with a high points-to-amount ratio and then aborting them after a small purchase by a secondary account, an attacker can receive refunds that exceed their initial payments, effectively stealing funds from the protocol.
The following test case, which can be included in the PreMarkets.t.sol, demonstrates the exploit:
Manual code review.
Adjust depositAmount
formula on PreMarkets::abortBidTaker
:
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.