Open code423n4 opened 1 year ago
dmvt marked the issue as duplicate of #74
RedVeil marked the issue as sponsor confirmed
RedVeil marked the issue as disagree with severity
dmvt changed the severity to 2 (Med Risk)
dmvt marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/vault/Vault.sol#L429-L439 https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/vault/Vault.sol#L473 https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/vault/Vault.sol#L481
Vulnerability details
managementFee
is calculated byaccruedManagementFee
function:Impact 1
Management Fee for a vault is charged even when there is no assets under management.
The
feesUpdatedAt
variable is first assigned at block.timestamp when the vault is initialized: https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/vault/Vault.sol#L87The vault could be deployed and initialized without any asset under management at time T. For example 10 years after deployment, a user Alice deposits 100ETH into the vault, the management fee will be calculated from T to block.timestamp (which is 10 years) which is not fair. Alice will be charged immediately all majority of 100ETH as management fee. Further than that, if the totalAssets after a year is significant large, the management fee will be highly overcharged for the last year when no fund was managed.
The vault owner could create vaults, wait for a period of time and trap user to deposit. He then could immediately get user assets by claim the wrongful managemennt fee.
Proof of Concept
Impact 2
Management Fee is subject to manipulation because of
feesUpdatedAt
andtotalAssets
are varied by user or vault owner's actions To get the management fee will be lower.takeManagementAndPerformanceFees
to reset the variablefeesUpdatedAt
to block.timestamp before deposit. https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/vault/Vault.sol#L473takeManagementAndPerformanceFees
function.Vault owner will have the incentive to front run a large withdraw of assets and call
takeManagementAndPerformanceFees
to get higher management fee becausetotalAssets()
is still high.Proof of Concept
Alice deposit 1000 ETH into the vault. The vault deposit, withdraw and management fees are set to 1e17.
In the first scenario, before Alice can withdraw, vault creator front-run to call the
takeManagementAndPerformanceFees
function. Result is that feeReceipient will have 192.21 ETH.In the second scenario, no front-run to call the
takeManagementAndPerformanceFees
function happens. Result is that feeReceipient will have 190 ETHTools Used
Recommended Mitigation Steps:
feesUpdatedAt
variable is not updated frequently enough. They are only updated when callingtakeManagementAndPerformanceFees
andchangeAdapter
. The fee should be calculated and took more frequently in each deposit and withdrawal of assets.