DYAD - valentin_s2304'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: 166/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/main/src/core/VaultManagerV2.sol#L134

Vulnerability details

Impact

A malicious user can cause a DoS attack on the withdraw function for other users by using deposit() function in VaultManagerV2 providing the id of the victim's NFT and 0 amount for depositing into the specified vault. This will cause locked funds for the victim.

Proof of Concept

idToBlockOfLastDeposit[id] is a protection for the protocol from flash loan attacks but other users can manipulate it. Deposit function gives the right to any user to deposit for another user's NFT, the problem is there that a malicious user can call deposit function with 0 amount to cause short-term DOS to the victim.

function deposit(
    uint    id,
    address vault,
    unit amount
  ) 
    external 
      isValidDNft(id)
  {
    idToBlockOfLastDeposit[id] = block.number; //here malicious user sets the block of the last deposit to the current one which will cause prevention of user calling withdraw function
    Vault _vault = Vault(vault);
    _vault.asset().safeTransferFrom(msg.sender, address(vault), amount);
    _vault.deposit(id, amount);
  }

  /// @inheritdoc IVaultManager
  function withdraw(
    uint    id,
    address vault,
    uint    amount,
    address to
  ) 
    public
      isDNftOwner(id)
  {//ok
    if (idToBlockOfLastDeposit[id] == block.number) revert DepositedInSameBlock(); //this if statement causes the revert of the function withdraw 

    Vault _vault = Vault(vault);
    uint value = amount * _vault.assetPrice() 
                  * 1e18 
                  / 10**_vault.oracle().decimals() 
                  / 10**_vault.asset().decimals();
    if (getNonKeroseneValue(id) - value < dyadMinted) revert NotEnoughExoCollat();//ok
    _vault.withdraw(id, to, amount);
    if (collatRatio(id) < MIN_COLLATERIZATION_RATIO)  revert CrTooLow(); 
  }

Tools Used

Manual review

use isDnftOwner modifier in deposit function or add amount == 0 check

Assessed type

DoS

#0 - c4-pre-sort

2024-04-27T11:54:29Z

JustDravee marked the issue as duplicate of #489

#1 - c4-pre-sort

2024-04-29T09:31:32Z

JustDravee marked the issue as sufficient quality report

#2 - c4-judge

2024-05-05T20:39:24Z

koolexcrypto marked the issue as unsatisfactory: Invalid

#3 - c4-judge

2024-05-05T20:39:58Z

koolexcrypto marked the issue as unsatisfactory: Invalid

#4 - c4-judge

2024-05-05T21:45:03Z

koolexcrypto marked the issue as nullified

#5 - c4-judge

2024-05-05T21:45:06Z

koolexcrypto marked the issue as not nullified

#6 - c4-judge

2024-05-08T15:27:52Z

koolexcrypto marked the issue as duplicate of #1001

#7 - c4-judge

2024-05-11T19:49:38Z

koolexcrypto marked the issue as satisfactory

#8 - c4-judge

2024-05-13T18:34:30Z

koolexcrypto changed the severity to 3 (High Risk)

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