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
_rebalance() may overflow #747
Comments
trust1995 marked the issue as primary issue |
trust1995 marked the issue as satisfactory |
Within this test https://github.com/code-423n4/2023-02-ethos/blob/73687f32b934c9d697b97745356cdf8a1f264955/Ethos-Vault/test/starter-test.js#L332 one can add console logs for Moreover,
|
tess3rac7 marked the issue as sponsor disputed |
I don't think it is a fair certainty that strategies will not yield losses. In light of that, med severity seems appropriate. |
trust1995 marked issue #632 as primary and marked this issue as a duplicate of 632 |
Lines of code
https://github.com/code-423n4/2023-02-ethos/blob/73687f32b934c9d697b97745356cdf8a1f264955/Ethos-Core/contracts/ActivePool.sol#L251
Vulnerability details
Impact
There may be a loss of precision in the vault deposit, resulting in _rebalance overflow
Proof of Concept
After executing ActivePool.rebalance() it will first calculate the current profit
The code is as follows:
where vars.fit is uint256, the default is not negative
The documentation is described below:
The vault will be farming the lowest-risk yield possible, so you can assume that the principal will be protected from loss
But there is a problem, if the vault is not exclusive (only one depositor), when making a deposit is generally a loss of precision
If you deposit 100 (* e18), you will get 99.99999999999999999999 (*e18) if you take it immediately
Simplify ReaperVaultV2.sol as follows:
This will result in
vars.profit = vars.sharesToAssets.sub(vars.currentAllocated);
overflowActivePool.sendCollateral()/ActivePool.pullCollateralFromBorrowerOperationsOrDefaultPool() will revert
Until there are gains or other depositors
Tools Used
Recommended Mitigation Steps
vars.sharesToAssets.sub(vars.currentAllocated)
If less than 0, then set profit=0The text was updated successfully, but these errors were encountered: