DYAD - DarkTower'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: 104/183

Findings: 2

Award: $8.69

🌟 Selected for report: 0

🚀 Solo Findings: 0

Judge has assessed an item in Issue #1018 as 2 risk. The relevant finding follows:

[L-1] assetPrice() queries from Kerosene price to determine price will fail when TVL is 0 In the case TVL is 0, the function will revert as it attempts a subtraction from 0 operation which runs into an underflow. https://github.com/code-423n4/2024-04-dyad/blob/main/src/core/Vault.kerosine.unbounded.sol#L65

function assetPrice() public view override returns (uint) { uint tvl; address[] memory vaults = kerosineManager.getVaults(); uint numberOfVaults = vaults.length; for (uint i = 0; i < numberOfVaults; i++) { Vault vault = Vault(vaults[i]); tvl += vault.asset().balanceOf(address(vault)) * vault.assetPrice() * 1e18 / (10vault.asset().decimals()) / (10vault.oracle().decimals()); } @> uint numerator = tvl - dyad.totalSupply(); // @audit revert if TVL resolves to 0 uint denominator = kerosineDenominator.denominator(); return numerator * 1e8 / denominator; } Return 0 or implement a case where if the TVL is 0, return no price:

function assetPrice() public view override returns (uint) { uint tvl; address[] memory vaults = kerosineManager.getVaults(); uint numberOfVaults = vaults.length; for (uint i = 0; i < numberOfVaults; i++) { Vault vault = Vault(vaults[i]); tvl += vault.asset().balanceOf(address(vault)) * vault.assetPrice() * 1e18 / (10vault.asset().decimals()) / (10vault.oracle().decimals()); }

  • if (tvl == 0) { return 0;} uint numerator = tvl - dyad.totalSupply(); uint denominator = kerosineDenominator.denominator(); return numerator * 1e8 / denominator;
    }

#0 - c4-judge

2024-05-05T19:13:29Z

koolexcrypto marked the issue as duplicate of #308

#1 - c4-judge

2024-05-11T20:10:15Z

koolexcrypto marked the issue as satisfactory

#2 - c4-judge

2024-05-13T18:34:03Z

koolexcrypto changed the severity to 3 (High Risk)

Awards

4.8719 USDC - $4.87

Labels

bug
2 (Med Risk)
satisfactory
sufficient quality report
:robot:_11_group
duplicate-175

External Links

Lines of code

https://github.com/code-423n4/2024-04-dyad/blob/main/src/core/VaultManagerV2.sol#L166 https://github.com/code-423n4/2024-04-dyad/blob/main/src/core/VaultManagerV2.sol#L215

Vulnerability details

Impact

A determined set of small-scale malicious users can have multiple DYAD positions in the low 10-dollar ranges, which would result in a lossy liquidation from an honest liquidator considering incentive to liquidate and gas costs thereby leaving such underwater NOTEs non-liquidated for a long time.

Proof of Concept

Let's consider this scenario:

  • Suppose 100 small-scale minters mint 10 USD worth of DYAD each while providing 15 USD of the supposed collateral.
  • Since they're at the maximum they can mint (150% CR), any small price sensitivity south would open such positions up for liquidations.
  • On average, gas on the Ethereum mainnet is mostly above the $8.5+ range.
  • Keeping in mind the gas costs factored in and the amount of DYAD being liquidated with little to no incentive to liquidate the NOTEs, the positions will remain open.
  • These positions remaining open for too long creates bad debt for the protocol
function mintDyad(
    uint    id,
    uint    amount,
    address to
  )
    external 
      isDNftOwner(id)
  {
    uint newDyadMinted = dyad.mintedDyad(address(this), id) + amount;
    if (getNonKeroseneValue(id) < newDyadMinted)     revert NotEnoughExoCollat();
@>    dyad.mint(id, to, amount); // @audit no constraint on amount
    if (collatRatio(id) < MIN_COLLATERIZATION_RATIO) revert CrTooLow(); 
    emit MintDyad(id, amount, to);
  }

There is no minimum amount of DYAD that can be minted. Technically, you can mint 1 DYAD as long as you provide 1.50 of the underlying vault collateral you're using.

Tools Used

Manual review + foundry

Since the contracts are deployed on Ethereum mainnet and gas costs are a huge concern, liquidators will most likely not want to take on liquidations that result in a lossy investment overall. Implement a minimum amount that can be minted in DYAD.

Assessed type

Other

#0 - c4-pre-sort

2024-04-27T13:31:55Z

JustDravee marked the issue as duplicate of #1258

#1 - c4-pre-sort

2024-04-29T09:16:48Z

JustDravee marked the issue as sufficient quality report

#2 - c4-judge

2024-05-03T14:07:47Z

koolexcrypto changed the severity to QA (Quality Assurance)

#3 - c4-judge

2024-05-22T14:26:06Z

This previously downgraded issue has been upgraded by koolexcrypto

#4 - c4-judge

2024-05-28T16:53:27Z

koolexcrypto marked the issue as satisfactory

#5 - c4-judge

2024-05-28T20:05:55Z

koolexcrypto marked the issue as duplicate of #175

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