code-423n4 / 2024-04-dyad-findings

8 stars 6 forks source link

Missing vault address validation in the `VaultManagerV2` for `deposit()` and `withdraw()`, exposes protocol to risk of reentrancy, unfair liquidation and phishing #1221

Closed c4-bot-6 closed 6 months ago

c4-bot-6 commented 6 months ago

Lines of code

https://github.com/code-423n4/2024-04-dyad/blob/cd48c684a58158de444b24854ffd8f07d046c31b/src/core/VaultManagerV2.sol#L134-L145 https://github.com/code-423n4/2024-04-dyad/blob/cd48c684a58158de444b24854ffd8f07d046c31b/src/core/VaultManagerV2.sol#L119-L131

Vulnerability details

Impact

There is no address validation for the vault parameter in the VaultManagerV2, for the vault address in the deposit()and withdraw() which exposes the protocol to different set of risks:


```diff
function withdraw(
    uint    id,
    address vault,
    uint    amount,
    address to
  ) 
    public
      isDNftOwner(id)
  {
    if (idToBlockOfLastDeposit[id] == block.number) revert DepositedInSameBlock();
+    if (!(vaults[id].contains(vault) || vaultsKerosene[id].contains(vault))) revert NotAdded();
    uint dyadMinted = dyad.mintedDyad(address(this), id);
    Vault _vault = Vault(vault);

Assessed type

Invalid Validation

c4-pre-sort commented 6 months ago

JustDravee marked the issue as duplicate of #555

c4-pre-sort commented 6 months ago

JustDravee marked the issue as sufficient quality report

c4-judge commented 6 months ago

koolexcrypto marked the issue as unsatisfactory: Invalid