Incorrect check can cause reverts for redemptions #549
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-381
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2023-02-ethos/blob/73687f32b934c9d697b97745356cdf8a1f264955/Ethos-Core/contracts/RedemptionHelper.sol#L126-L128
Vulnerability details
Impact
The function
redeemCollateral
inRedemptionHelper
checks that the caller doesn't have a higher balance than the totalDebt from the chosen_collateral
https://github.com/code-423n4/2023-02-ethos/blob/73687f32b934c9d697b97745356cdf8a1f264955/Ethos-Core/contracts/RedemptionHelper.sol#L126-L128
However, because the system is multi-collateral, it is possible for:
lusdToken.balanceOf(_redeemer)
to be greater thangetEntireSystemDebt(_collateral);
This is a mistake in the logic, as the invariant should be checking for all system collaterals
Proof of Concept
Imagine a scenario with two collaterals, one with 10 debt and another with 100
A: 10 debt, you own 0
B: 100 debt, you own 100 (perhaps bought from AMM or minted yourself)
If you tried to redeem the 10 A, you'd get a revert as the check would compare
yourbalance = 100 <= 10
Which will revert.
Additional considerations
This may also create an opportunity to grief a
redeemer
, if they were holding a lot of the total debt, a marginal donation may be sent in order to trigger a revert.Recommended Mitigation Steps
Either change the check to ensure that the debt paid is less than the total
Or sum up all of the debts for all collaterals and check against that
The text was updated successfully, but these errors were encountered: