Closed c4-bot-4 closed 6 months ago
JustDravee marked the issue as duplicate of #489
JustDravee marked the issue as sufficient quality report
koolexcrypto marked the issue as unsatisfactory: Invalid
koolexcrypto marked the issue as unsatisfactory: Invalid
koolexcrypto marked the issue as unsatisfactory: Invalid
koolexcrypto marked the issue as nullified
koolexcrypto marked the issue as not nullified
koolexcrypto marked the issue as duplicate of #1001
koolexcrypto marked the issue as satisfactory
koolexcrypto changed the severity to 3 (High Risk)
Lines of code
https://github.com/code-423n4/2024-04-dyad/blob/4a987e536576139793a1c04690336d06c93fca90/src/core/VaultManagerV2.sol#L119-L131 https://github.com/code-423n4/2024-04-dyad/blob/4a987e536576139793a1c04690336d06c93fca90/src/core/VaultManagerV2.sol#L134-L153
Vulnerability details
Impact
Denial of Service for the Victim User of
withdraw
&redeemDyad
functions of VaultManagerV2.sol .Proof of Concept
The current implementation of
VaultManagerV2.sol#withdraw
function has the following check before withdrawal from Vault where the stateidToBlockOfLastDeposit
is being checked as shown below :https://github.com/code-423n4/2024-04-dyad/blob/main/src/core/VaultManagerV2.sol#L134C1-L153C4
This check is implemented to prevent flashloan attacks . But the problem arises when a Malicious user can simply deposit a small amount of token to the Vault to prevent the withdrawal process . This arises due to the fact that the
VaultManagerV2.sol#deposit
does not have a strict access modifier to prevent such attacks . Let's see how it can be executed . As shown below theVaultManagerV2.sol#deposit
function has a lineant function access modifier which just checks whether thednft
used exists or not . And the function has this line of code where it changes the stateidToBlockOfLastDeposit
to current block.number as shown below.https://github.com/code-423n4/2024-04-dyad/blob/main/src/core/VaultManagerV2.sol#L119C2-L131C4
The
isValidDNft
is shown below : https://github.com/code-423n4/2024-04-dyad/blob/main/src/core/VaultManagerV2.sol#L42C1-L44C4So whenever a Victim User tries to withdraw the asset's from the Vault , a Malicious User can frontrun the transaction and deposit 1 wei of token to the Vault to change the
idToBlockOfLastDeposit
to current block.number , thereby preventing the Victim User from withdrawing the funds .Tools Used
Manual Review
Recommended Mitigation Steps
To prevent this attack the access modifier for the deposit function should be made more strict . Either the access modifier should be changed from
isValidDNft
toisDNftOwner
or the User should be allowed to create a allowlist of Trusted Users , who would be allowed to deposit on behalf of theDNFTOwner
.Assessed type
Access Control