Open c4-bot-9 opened 6 months ago
JustDravee marked the issue as high quality report
JustDravee marked the issue as duplicate of #1103
JustDravee marked the issue as duplicate of #489
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 not a duplicate
koolexcrypto marked the issue as duplicate of #1266
koolexcrypto changed the severity to 3 (High Risk)
koolexcrypto marked the issue as satisfactory
koolexcrypto marked the issue as not a duplicate
koolexcrypto marked the issue as primary issue
koolexcrypto marked the issue as selected for report
For transparency, the DYAD team (shafu) confirmed this finding outside of github. The appropriate sponsor labeling has been added on their behalf.
Lines of code
https://github.com/code-423n4/2024-04-dyad/blob/cd48c684a58158de444b24854ffd8f07d046c31b/src/core/VaultManagerV2.sol#L127
Vulnerability details
Impact
User's withdrawals will be prevented from success and an attacker can keep up without a cost using fake vault and fake token.
Proof of Concept
There is a mechanisms for a flash loan protection that saves the current block number in a mapping of dNft token id, and then prevent it from withdrawing at the same block number, as we can see in the
VaultManagerV2::deposit()
function which can be called by anyone with a valid dNft id:The attacker can use this to prevent any withdrawals in the current block, since it will be checked whenever an owner of dNft token try to withdraw:
Test Case (Foundry)
Tools Used
Recommended Mitigation
Consider limiting anyone with any token vaults to update
idToBlockOfLastDeposit
. One of these mitigation can be used:Prevent anyone to deposit to un-owned dNft token
Allow to only depositing using licensed vaults, so if the attacker try to front-runs he will lose some real tokens.
Since this used to protect against flash loans, no need to use it with all token vaults and should be used only with vaults that can be used to mint DYAD. So, we can check if the deposit included in the
vaultLicenser
andkeroseneManager
licenser, we need to update theidToBlockOfLastDeposit
. Here is a git diff for this fix:Assessed type
Invalid Validation