DYAD - 0xDemon's results

The first capital efficient overcollateralized stablecoin.

General Information

Platform: Code4rena

Start Date: 18/04/2024

Pot Size: $36,500 USDC

Total HM: 19

Participants: 183

Period: 7 days

Judge: Koolex

Id: 367

League: ETH

DYAD

Findings Distribution

Researcher Performance

Rank: 180/183

Findings: 1

Award: $0.02

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2024-04-dyad/blob/cd48c684a58158de444b24854ffd8f07d046c31b/src/core/VaultManagerV2.sol#L119-L131

Vulnerability details

Impact

User who own the deposited ID cannot make withdrawal

Proof of Concept

VaultManagerV2::deposit() functions for users to deposit collateral into the vault they own. This function allows anyone to make a deposit to a valid DNFT ID using the isValidDNft modifier. In this function there is also logic to block the possibility of a flash loan attack by applying the code as below:

    idToBlockOfLastDeposit[id] = block.number;

By implementing this, users cannot make withdrawals on the same block number

    if (idToBlockOfLastDeposit[id] == block.number) revert DepositedInSameBlock();

The main problem here lies in the modifier used, isValidDNft. isValidDNft only checks that the owner of the ID is not address(0). This way, it allows anyone to make a deposit to the vault from a valid ID and blocks the owner of the vault (deposited ID) from making withdrawals.

The scenario will be like this :

  1. Bob as malicious actor deposit to vault owned by Alice by entering the address of the vault and DNFT ID owned by Alice.
  2. This will work because isValidDNft only checks whether Alice's DNFT ID = address(0) or not (since the beginning Alice's DNFT ID is valid, not address(0))
  3. Once successful, the value of idToBlockOfLastDeposit[id] will be updated according to the block.number when Bob made the deposit.
  4. That way, when Alice wants to make a deposit on the same block.number, Alice's withdrawal will always revert because idToBlockOfLastDeposit[id] == block.number
  5. Bob can do this continuously because there is no minimum amount requested for a user to make a deposit, he can even send 1 wei and update the value of idToBlockOfLastDeposit

Tools Used

Manual review

Consider limiting only DNFT ID owners who can make deposits using the isDNftOwner modifier

  function deposit(
    uint    id,
    address vault,
    uint    amount
  ) 
    external 
      isValidDNft(id)
      isDNftOwner(id)
  {
    idToBlockOfLastDeposit[id] = block.number;
    Vault _vault = Vault(vault);
    _vault.asset().safeTransferFrom(msg.sender, address(vault), amount);
    _vault.deposit(id, amount);
  }

Assessed type

DoS

#0 - c4-pre-sort

2024-04-27T11:28:59Z

JustDravee marked the issue as duplicate of #1103

#1 - c4-pre-sort

2024-04-27T11:45:41Z

JustDravee marked the issue as duplicate of #489

#2 - c4-pre-sort

2024-04-29T09:26:20Z

JustDravee marked the issue as sufficient quality report

#3 - c4-judge

2024-05-05T20:38:13Z

koolexcrypto marked the issue as unsatisfactory: Invalid

#4 - c4-judge

2024-05-05T20:39:22Z

koolexcrypto marked the issue as unsatisfactory: Invalid

#5 - c4-judge

2024-05-05T21:31:20Z

koolexcrypto marked the issue as nullified

#6 - c4-judge

2024-05-05T21:31:27Z

koolexcrypto marked the issue as not nullified

#7 - c4-judge

2024-05-08T15:29:06Z

koolexcrypto marked the issue as duplicate of #1001

#8 - c4-judge

2024-05-11T19:50:47Z

koolexcrypto marked the issue as satisfactory

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter