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
Rank: 104/183
Findings: 2
Award: $8.69
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xAlix2
Also found by: 0x486776, 0xabhay, 0xlucky, 0xtankr, Abdessamed, Circolors, CodeWasp, DarkTower, Egis_Security, Giorgio, Infect3d, Krace, KupiaSec, Limbooo, Maroutis, NentoR, Ryonen, SpicyMeatball, T1MOH, TheFabled, TheSavageTeddy, TheSchnilch, VAD37, XDZIBECX, btk, carrotsmuggler, cu5t0mpeo, dimulski, gumgumzum, iamandreiski, imare, itsabinashb, ke1caM, kennedy1030, lian886, n4nika, oakcobalt, sashik_eth, shaflow2, steadyman, web3km, windhustler, zhaojohnson
3.8221 USDC - $3.82
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)
🌟 Selected for report: dimulski
Also found by: 0xleadwizard, 0xlemon, Aamir, Al-Qa-qa, AvantGard, Bauchibred, Cryptor, DarkTower, Egis_Security, Giorgio, Maroutis, MrPotatoMagic, OMEN, Ocean_Sky, Ryonen, SBSecurity, Sabit, SpicyMeatball, Stefanov, T1MOH, Tigerfrake, WildSniper, atoko, bhilare_, darksnow, fandonov, grearlake, iamandreiski, igdbase, pontifex, web3km, xiao
4.8719 USDC - $4.87
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
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.
Let's consider this scenario:
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.
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.
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