The DeliveryPlace
contract does not handle changes in the collateral rate after the creation of offers or stocks, leading to potential miscalculations in refund amounts and collateral fees. This vulnerability can result in significant financial discrepancies and exploitation.
The contract uses collateralRate
in several functions to calculate refund amounts and collateral fees. If the collateral rate changes after an offer or stock is created, these calculations will be incorrect.
closeBidOffer
FunctionThe closeBidOffer
function calculates the refund amount using the collateral rate stored in the offerInfo
structure. If the collateral rate changes after the offer is created, the refund calculation will be incorrect.
closeBidTaker
FunctionThe closeBidTaker
function calculates the collateral fee using the collateral rate stored in the offerInfo
structure. Similar to the closeBidOffer
function, if the collateral rate changes after the offer is created, the collateral fee calculation will be incorrect.
detailed step-by-step exploit scenario
Collateral Rate: Initially set to 10%.
Offer: An offer is created with an amount of 1000 tokens and 100 points.
Collateral: Calculated as 100 tokens (10% of 1000 tokens)
Action: An attacker creates an offer with the following parameters:
Amount: 1000 tokens
Points: 100 points
Collateral Rate: 10%
Calculation:
Collateral: 100 tokens (10% of 1000 tokens)
The offer is created and stored with these values.
Action: The collateral rate is changed to 20% due to an external event or administrative action.
Impact: The new collateral rate is now 20%, but the offer still holds the old collateral rate of 10%.
Action: The attacker closes the offer using the closeBidOffer
function.
Calculation:
The function calculates the refund amount based on the initial collateral rate of 10%.
Refund Amount: OfferLibraries.getRefundAmount
is called with the old collateral rate of 10%.
Calculation:
Initial Collateral: 100 tokens (10% of 1000 tokens)
New Collateral Rate: 20%
Refund Amount Calculation:
Since the collateral rate used for the refund calculation is still 10%, the refund amount will be based on 100 tokens instead of the updated 200 tokens.
Result: The attacker receives a refund based on the outdated collateral rate of 10%, resulting in an incorrect refund amount.
Refund Amount: 100 tokens (instead of the correct amount based on the new 20% rate, which would be 200 tokens)).
The protocol will refund incorrect amounts, leading to financial discrepancies/.
Users may receive more or less than they are entitled to, causing potential financial loss.
leading to potential operational disruptions and loss of user trust.
The protocol will refund incorrect amounts, leading to financial discrepancies.
Users may receive more or less than they are entitled to, causing potential financial loss and trust issues.
manual code review, vscode, solidity, foundry, solodit
Ensure that the collateral rate is dynamically fetched and used in calculations at the time of function execution, rather than relying on stored values.
Implement mechanisms to update the collateral rate in existing offers and stocks whenever the global collateral rate changes.
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.