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

Protocol doesn't handle vault loss. #541

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

Protocol doesn't handle vault loss. #541

code423n4 opened this issue Mar 6, 2023 · 3 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 downgraded by judge Judge downgraded the risk level of this issue duplicate-632 edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

code423n4 commented Mar 6, 2023

Lines of code

https://github.com/code-423n4/2023-02-ethos/blob/73687f32b934c9d697b97745356cdf8a1f264955/Ethos-Core/contracts/ActivePool.sol#L251

Vulnerability details

Description

Ethos core contracts are not designed to deal with losses. This is because vaults invest in strategies that are not designed to lose money.

Impact/POC

Globally, this system doesn't handle losses, but let's take an example to show why this is critical:

Let's say a vault strategy is hacked and 10% of the total collateral disappears.

This assignment will now revert every time _rebalance() is called : ActivePool.sol#L251

vars.profit = vars.sharesToAssets.sub(vars.currentAllocated);

Now sharesToAssets < currentAllocated. Because we try to assign a negative value to an uint , _rebalance will now always revert making the system DOS :

In BorrowerOperations 100% DOS

  • openTrove
  • closeTrove
  • _adjustTrove
  • addColl, withdrawColl
  • withdrawLUSD, repayLUSD
    In TroveManager 80% DOS
  • liquidateTroves
  • batchLiquidateTroves
  • redeemCloseTrove

This will probably trigger fear in users and they will start selling their LUSD on the secondary markets causing a depeg. Probably nobody will want to buy back LUSD since the system is DOS users are no longer incentivises to maintain the peg.

Note that a hack or bug in a strategy that results in a loss of funds of just a few basis points can trigger this massive DOS.

With 2 examples we will figure out why this is really concerning

1st scenario (the repairable one) :

Context : TVL = 1 000 000 ; lossPercentage = 0.01% ⇒ loss = 10 000$

Here 10k have been hacked from a strategy. The loss is small but the protocol DOS anyway. The Ethos team can fix the protocol by manually sending 10k$ of the underlying collateral to the vault that has been hacked in order artificially increase the share price.

Impact : protocol DOS during 1 day and Ethos loss 10 000$

2nd scenario :

Context : TVL = 1B ; lossPercentage = 10% ⇒ loss = 100M$

Now the team will have to send 100M to the vault to repair the protocol. If they never find the money the other 900M$ will be stuck in the protocol forever. Making users lose 100% of their investment instead of only 10%.

Mitigation

This scenario needs to be handled properly.

A safer system would be to spread the loss over all investors.

If we take the example above, everyone loses 10%. The TCR will fall, causing some troves to be liquidated. If the loss is greater than 10%, some troves may be underwater. Liquidity providers of stability pool will absorb the loss, but at least the integrity of the system is maintained and the LUSD remains pegged.

Even though the strategies invested in are the safest in the industry, I think it's worth implementing a loss-handling mechanism to ensure that the protocol remains robust over time.

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Mar 6, 2023
code423n4 added a commit that referenced this issue Mar 6, 2023
@c4-judge c4-judge closed this as completed Mar 8, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Mar 8, 2023

trust1995 marked the issue as duplicate of #747

@c4-judge
Copy link
Contributor

c4-judge commented Mar 8, 2023

trust1995 marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Mar 8, 2023
@c4-judge c4-judge added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value downgraded by judge Judge downgraded the risk level of this issue and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Mar 20, 2023
@c4-judge
Copy link
Contributor

trust1995 changed the severity to 2 (Med Risk)

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 downgraded by judge Judge downgraded the risk level of this issue duplicate-632 edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

2 participants