The current collateral management system allows a malicious actor to drain the collateral pool by manipulating collateral rates. The issue arises because the collateral deposit charged at the time of listing a non-original offer corresponds to the previously set collateral rate, while the refund upon closing the offer is calculated based on the collateral rate registered on the offer. This discrepancy allows an attacker to exploit the system by manipulating collateral rates.
When a user lists an offer with PreMarkets::listOffer
, they choose a collateral rate, which gets set on their offer. However, in the current implementation, the collateral deposit they are charged is based on the previous collateral rate rather than the rate they selected, according to the code snippets below:
However, the collateral rate that is set on their offer info is the rate they selected:
On PreMarkets::closeOffer
, the collateral is refunded upon the cancelation of an order based on the collateral rate that is set on the offer:
This creates an opportunity for a malicious actor to exploit the system:
The attacker takes an existing offer with a low collateral rate.
The attacker then lists the offer with a significantly higher collateral rate.
Upon canceling the listing, the attacker receives a refund based on the inflated collateral rate, effectively withdrawing more funds than they deposited.
This exploit can lead to all of the protocol's funds being drained.
The impact - user withdrawing more collateral funds than they deposited - is demonstrated in the test case below, which can be included in the PreMarkets.t.sol file:
Manual code review.
This vulnerability can be addressed by updating the PreMarkets::listOffer
function to charge the user the collateral rate they define instead of the original collateral rate, as shown below:
Valid high severity, because the collateral rate utilized when creating an offer is stale and retrieved from a previously set collateral rate, it allows possible manipilation of refund amounts using an inflated collateral rate to drain funds from the CapitalPool contract
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.