DYAD - LeoGold'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: 158/183

Findings: 1

Award: $0.28

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

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

Vulnerability details

Impact

VaultManagerV2::collatRatio() used the totalUsdValue of the collateral of the specified Id to determine the calculation, user who made deposit and have addedv the same vault in both VaultManagerV2::add() and VaultManagerV2::addKerosene() will have their collateral being referenced twice in collatRatio calculation. (this is possible because weth and westh are added in both kerosenemanager.sol and licenser.sol)

VaultManagerV2::getNonKeroseneValue() and VaultManagerV2::getKeroseneValue() both individually referenced the same collateral and return the same value seperately which was then added together in VaultManagerV2::getTotalUsdValue(). this will raise the collateral ratio calculation to keep returning a value above 150% of their collateral and can never get liquidated, which in the real case the collateral to the dyadMinted ratio is 100% or below. This will break the protocol invariant of TVL > dyad

  • TVL == dyad at the point of minting 100% collateral,
  • TVL < dyad when collateral falls in price because it cannot be liquidated when cr keeps returning double of the actual ratio

Proof of Concept

TotalUsd Calculation

collateral ratio

kerosene manager adding the two collateral here in the deploy script

Vault Licenser adding the two collateral here also in the deploy script

github gist for POC here

copy and paste file in test/fork folder and run with forge t --mt testCollateral_Ratio_Return_Double -vv

Tools Used

foundry

The team should mitigate this risk by making sure the calculation of TotalUsdValue is not returning double of the supposed value

Assessed type

Context

#0 - c4-pre-sort

2024-04-29T07:18:20Z

JustDravee marked the issue as sufficient quality report

#1 - c4-pre-sort

2024-04-29T07:18:34Z

JustDravee marked the issue as primary issue

#2 - c4-pre-sort

2024-04-29T07:18:41Z

JustDravee marked the issue as remove high or low quality report

#3 - c4-pre-sort

2024-04-29T07:18:53Z

JustDravee marked the issue as duplicate of #966

#4 - c4-pre-sort

2024-04-29T08:37:10Z

JustDravee marked the issue as sufficient quality report

#5 - c4-judge

2024-05-04T09:46:23Z

koolexcrypto marked the issue as unsatisfactory: Invalid

#6 - c4-judge

2024-05-29T11:20:01Z

koolexcrypto marked the issue as duplicate of #1133

#7 - c4-judge

2024-05-29T14:04:04Z

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