User token withdraws from vaults can be griefed #1323
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-118
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2024-04-dyad/blob/main/src/core/VaultManagerV2.sol#L134-L153
https://github.com/code-423n4/2024-04-dyad/blob/main/src/core/VaultManagerV2.sol#L119-L131
Vulnerability details
Impact
The withdraw() function in implements the following check:
not allowing withdraws in the same block, in which someone has already deposited into a so called Note. As can be seen from the deposit() function:
There are no minimum deposits required, so a malicious actor can frontrun the Note owner call to withdraw(), deposit as little as 1 WEI and the withdraw function will revert, thus griefing the Note owner. A malicious actor can do this as many times as he wants, and the Note owner won't be able to withdraw his deposited tokens. In a turbulent market conditions (which are a typical occurrence in crypto), a Note owner may have decided that he would like to convert his crypto assets to fiat currency, already burned all of his minted DYAD tokens in order to free all of his collateral. However as he is trying to withdraw all of his deposited collateral, a malicious actor can grief him as described above, while the deposited collateral falls in value. Thus resulting in immense losses for the owner of the Note. The same griefing attack can be performed when a user is trying to remove a vault from his
vaults
, orvaultsKerosene
lists. For example he has liquidated an undercollateralized position of somebody, he already has 5 vaults in hisvaults
list but a big portion of the collateral he received as a reward are in a vault he hasn't added to hisvaults
list. In order to withdrawn them he will have to remove one vault and add another, however a malicious user can keep depositing 1 WEI, thus restricting this functionality. Considering when a positions gets liquidated, it is typically because the collateral asset fell in dollar value, and is probably going to continue falling in price due to some turbulent market conditions, this may result in a big loss for users.Tools Used
Manual review
Recommended Mitigation Steps
Consider allowing only the DNFT Owner to be able to deposit assets via the deposit() function, set the modifier from
isValidDNft(id)
toisDNftOwner(id)
Assessed type
DoS
The text was updated successfully, but these errors were encountered: