Depositor can send a positive token amount to vault but mint 0 shares when calling ReaperVaultV2._deposit
function
#714
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-848
grade-a
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultV2.sol#L59-L73
https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultERC4626.sol#L110-L112
https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultV2.sol#L302-L304
https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultV2.sol#L313-L315
https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultV2.sol#L319-L338
Vulnerability details
Impact
When an EOA or contract with the
DEPOSITOR
role calls the followingReaperVaultERC4626.deposit
,ReaperVaultV2.depositAll
, andReaperVaultV2.deposit
functions, theReaperVaultV2._deposit
function is called.https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultV2.sol#L59-L73
https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultERC4626.sol#L110-L112
https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultV2.sol#L302-L304
https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultV2.sol#L313-L315
Calling the
ReaperVaultV2._deposit
function below then executesshares = (_amount * totalSupply()) / freeFunds
. BecausetotalSupply()
can be less thanfreeFunds
, such as after profits of the vault's strategies are harvested, it is possible that_amount * totalSupply()
is less thanfreeFunds
. In this situation, the depositor, who calls theReaperVaultV2._deposit
function with such_amount
input value, would send_amount
tokens to the vault but mint 0 shares in return. As a result, this depositor loses the_amount
tokens that are sent.https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultV2.sol#L319-L338
Proof of Concept
The following steps can occur for the described scenario.
ReaperVaultV2.depositAll
function.(_amount * totalSupply()) / freeFunds = (0.9e3 * 1e6) / 1e9
rounds down to 0, the depositor mints 0 shares after theReaperVaultV2._deposit
function is called.Tools Used
VSCode
Recommended Mitigation Steps
The
ReaperVaultV2._deposit
function can be updated to ensure that calling it can revert when the calculatedshares
to be minted is 0.The text was updated successfully, but these errors were encountered: