Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect check can cause reverts for redemptions #549

Closed
code423n4 opened this issue Mar 6, 2023 · 4 comments
Closed

Incorrect check can cause reverts for redemptions #549

code423n4 opened this issue Mar 6, 2023 · 4 comments
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")

Comments

@code423n4
Copy link
Contributor

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 in RedemptionHelper 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

       totals.totalLUSDSupplyAtStart = getEntireSystemDebt(_collateral);
        // Confirm redeemer's balance is less than total LUSD supply
        assert(lusdToken.balanceOf(_redeemer) <= totals.totalLUSDSupplyAtStart);

However, because the system is multi-collateral, it is possible for:

lusdToken.balanceOf(_redeemer) to be greater than getEntireSystemDebt(_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

@code423n4 code423n4 added 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 labels Mar 6, 2023
code423n4 added a commit that referenced this issue Mar 6, 2023
@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Mar 9, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Mar 9, 2023

trust1995 marked the issue as satisfactory

@c4-judge c4-judge added the primary issue Highest quality submission among a set of duplicates label Mar 9, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Mar 9, 2023

trust1995 marked the issue as primary issue

@c4-sponsor c4-sponsor added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Mar 15, 2023
@c4-sponsor
Copy link

tess3rac7 marked the issue as sponsor confirmed

@c4-judge c4-judge added duplicate-381 and removed primary issue Highest quality submission among a set of duplicates labels Mar 20, 2023
@c4-judge
Copy link
Contributor

trust1995 marked issue #381 as primary and marked this issue as a duplicate of 381

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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")
Projects
None yet
Development

No branches or pull requests

3 participants