# Attacker can make 0 value deposit() calls to deny user from redeeming or withdrawing collateral

DYAD's deposit() used isValidDNft instead of isDNftOwner, letting anyone frontrun a 0-value deposit to block a victim's withdraw/redeem and force liquidation.

- Payout: Audit contest
- Severity: high
- Program: DYAD
- Found by: MrPotatoMagic
- Disclosed: 2024-06-17
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-04-dyad-findings/issues/1001
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-dyad%3AH-03
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:access-control vuln:business-logic vuln:dos vuln:liquidation

**Target:** VaultManagerV2.deposit()/withdraw()/remove() on-chain contract
**Root cause:** deposit() is guarded by isValidDNft() rather than isDNftOwner(), so any caller can set idToBlockOfLastDeposit[id] for an arbitrary DNft id; withdraw() reverts when that block equals the current block.
**Steps:**
1. Victim calls redeemDyad()/withdraw() to burn DYAD and pull collateral.
2. Attacker frontruns with `deposit(id, vault, 0)`; 0-value safeTransferFrom succeeds and sets `idToBlockOfLastDeposit[id] = block.number`.
3. Victim's withdraw() hits `if (idToBlockOfLastDeposit[id] == block.number) revert DepositedInSameBlock();` and reverts.
4. Repeat each block; if collateral price drops and ratio < 1.5e18, attacker calls liquidate() to profit.
5. Second variant: frontrun remove() with a 1 wei deposit so `id2asset(id) > 0` triggers `revert VaultHasAssets()`.
**How found:** Code review of access-control modifiers on deposit(): noticed it used isValidDNft (existence check) instead of isDNftOwner, then traced the idToBlockOfLastDeposit same-block guard in withdraw() to see the griefing path.
**Exploitation:** Attacker needs no capital for the 0-value deposit, only gas; frontruns every withdraw/redeem attempt to keep the victim locked out of deleveraging, then liquidates when the collateral ratio falls below the minimum.
**Escalation:** Griefing denial-of-withdrawal escalates to forced liquidation and attacker profit during high price volatility.
**Insight:** When a function writes per-id state used as a same-block guard elsewhere, check whether its access modifier only proves existence rather than ownership; zero-value transfers often bypass amount checks and still mutate that state.

