ERC4626 vault vulnerable to price inflation leading to loss of funds #437
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-848
grade-c
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/ReaperVaultERC4626.sol#L110
https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultV2.sol#L319
https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperVaultV2.sol#L336
Vulnerability details
Impact
During periods of low share liquidity the Ethos Vault ERC4626 implementation (ReaperVaultERC4626) is vulnerable to price inflation attacks from EOAs or smart contracts that are granted the
DEPOSITOR
role.L61 of ReaperVaultV2.sol states the
DEPOSITOR
role can be conferred to multiple EOAs or contracts;{DEPOSITOR} - Role conferred to EOAs/contracts that are allowed to deposit in the vault.
One of these
DEPOSITORS
acting in their own self interest can front-run deposits and withdrawals causing;The most likely victim is the ActivePool itself which will be depositing funds in the ERC4626 vault. With only a single malicious
DEPOSITOR
either of both the scenarios above are possible.Note the
DEPOSITOR
is the minimum role required to perform this attack. It could also be performed by aSTRATEGIST
,GUARDIAN
, orADMIN
. L320 of ReaperVaultV2.sol details the access check.Proof of Concept
Scenario #1 - Attacker front-runs a transaction resulting in a deposit but no shares minted.
DEPOSITOR
deposits 1 token in the ERC4626 vault ReaperVaultERC4626 and mints a single share as the deposit amount becomes the share issue amount at this stage of low liquidity.Scenario #2 - Attacker doesn’t front run but just removes their share after a successful deposit from the ActivePool (or other depositor).
The following Foundry test demonstrates these different scenarios;
Recommended mitigation steps
UniswapV2 has solved this by minting an amount of shares (MINIMUM_LIQUIDITY) to address(0) ensuring that price manipulation is more difficult and expensive to perform. Another option is to track total assets internally so that assets directly transferred to the vault are unaccounted for but may be retrieved by an administrator. This ensures that only deposits and redeem functions can change the tracked balances of the vault.
The text was updated successfully, but these errors were encountered: