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: 138/183
Findings: 2
Award: $4.10
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Maroutis
Also found by: 0x486776, 0xShitgem, 0xabhay, 0xleadwizard, 0xlemon, 0xnilay, 0xtankr, 3docSec, AM, Aamir, Abdessamed, Al-Qa-qa, AlexCzm, Circolors, CodeWasp, Daniel526, Egis_Security, Emmanuel, Giorgio, Honour, Hueber, Infect3d, Krace, KupiaSec, LeoGold, Limbooo, PoeAudits, SBSecurity, SpicyMeatball, T1MOH, The-Seraphs, TheSavageTeddy, TheSchnilch, Topmark, VAD37, ZanyBonzy, adam-idarrha, bhilare_, btk, carlitox477, cinderblock, dimulski, falconhoof, grearlake, gumgumzum, iamandreiski, itsabinashb, josephdara, ke1caM, kennedy1030, ljj, n0kto, n4nika, neocrao, oakcobalt, petro_1912, pontifex, poslednaya, shaflow2, shikhar229169, web3km, ych18, zhaojohnson, zigtur
0.2831 USDC - $0.28
https://github.com/code-423n4/2024-04-dyad/blob/cd48c684a58158de444b24854ffd8f07d046c31b/script/deploy/Deploy.V2.s.sol#L64-L65 https://github.com/code-423n4/2024-04-dyad/blob/cd48c684a58158de444b24854ffd8f07d046c31b/script/deploy/Deploy.V2.s.sol#L93-L94 https://github.com/code-423n4/2024-04-dyad/blob/cd48c684a58158de444b24854ffd8f07d046c31b/src/core/VaultManagerV2.sol#L75-L75 https://github.com/code-423n4/2024-04-dyad/blob/cd48c684a58158de444b24854ffd8f07d046c31b/src/core/VaultManagerV2.sol#L88-L88
Users can legitimately mint DYAD with collateralization of 75%, leading to loss of funds and protocol collapse.
In the deployment script, Deploy.V2.s.sol
, vaults ethVault
and wstEth
are both added to KerosineManager
and added to VaultLicenser
. As a result, a user can legitimately add the same vault (either ethVault
or wstEth
) as a standard vault via VaultManagerV2::add(), and as a Kerosene vault via VaultManagerV2::addKerosene(), because the same vault is licensed both as standard, and as Kerosene vault.
Further, collateralization is calculated in function collatRatio() using total USD value, which sums up collateral contained both in non-Kerosene and Kerosene vaults using function getTotalUsdValue():
function getTotalUsdValue(uint id) public view returns (uint) { return getNonKeroseneValue(id) + getKeroseneValue(id); }
As it is possible to have the same vault counted twice, a user may have their collateral twice as high as the real value, and be able to mint DYAD with collateralization of 75%, thus undermining the core function of the protocol.
ethVault
as a parameter;ethVault
as a parameter;ethVault
;Manual audit
Make sure that the vaults licensed as non-Kerosene and as Kerosene form two non-intersecting sets.
Error
#0 - c4-pre-sort
2024-04-28T19:08:01Z
JustDravee marked the issue as duplicate of #974
#1 - c4-pre-sort
2024-04-29T09:23:21Z
JustDravee marked the issue as sufficient quality report
#2 - c4-judge
2024-05-03T21:20:22Z
koolexcrypto marked the issue as unsatisfactory: Invalid
#3 - andrey-kuprianov
2024-05-16T15:23:41Z
Hello @koolexcrypto,
this finding is marked incorrectly as a duplicate of 974; in fact it's a duplicate of #966. Could you please correct this?
Thank you.
#4 - koolexcrypto
2024-05-22T16:05:32Z
Hi @andrey-kuprianov
Thank you for your feedback.
This seems similar to #872 . will double check later
#5 - andrey-kuprianov
2024-05-29T07:00:09Z
Hi @koolexcrypto, I hope it's not inappropriate to ping you: just wanted to remind that this finding is still marked as unsatisfactory and a duplicate of 974, while it seems it should be a duplicate of either #966 or #1133.
#6 - koolexcrypto
2024-05-29T10:05:43Z
No problem. I was still going through multiple issues at the same time. didn't forget this.
This is a dup of #1133
#7 - c4-judge
2024-05-29T10:05:49Z
koolexcrypto removed the grade
#8 - c4-judge
2024-05-29T10:05:55Z
koolexcrypto marked the issue as not a duplicate
#9 - c4-judge
2024-05-29T10:06:04Z
koolexcrypto marked the issue as duplicate of #1133
#10 - c4-judge
2024-05-29T11:22:05Z
koolexcrypto marked the issue as satisfactory
🌟 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
The system will become inoperable upon deployment due to underflow in Kerosine asset price calculation.
UnboundedKerosineVault::assetPrice() contains the following fragment:
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 / (10**vault.asset().decimals()) / (10**vault.oracle().decimals()); } uint numerator = tvl - dyad.totalSupply();
In the fragment above, the total value locked (tvl
) is calculated over all vaults licensed with KerosineManager
. As can be seen from the deployment script those are the freshly created ethVault
and wstEth
, which balances wrt. the corresponding assets are initially zero, while the total supply of DYAD is non-zero. As a result, any attempt to calculate assetPrice()
for the UnboundedKerosineVault
will underflow and revert.
This function is used in particular to calculate the USD value of particular note in a Kerosine vault via KerosineVault::getUsdValue(id), which in turn is used in VaultManagerV2::getKeroseneValue(). The latter is employed via getTotalUsdValue()
in collatRatio(). This function reverting will in turn make functions mintDyad()
, withdraw
, and liquidate
inoperable.
What's worth noticing is that the deployment uses MAINNET_DYAD address for the Dyad
contract, which is already in operation on Mainnet, with 625,967.4 DYAD total supply at the time of writing.
Manual audit
Other
#0 - c4-pre-sort
2024-04-27T18:17:38Z
JustDravee marked the issue as duplicate of #958
#1 - c4-pre-sort
2024-04-29T08:39:34Z
JustDravee marked the issue as sufficient quality report
#2 - c4-judge
2024-05-05T13:48:48Z
koolexcrypto marked the issue as duplicate of #308
#3 - c4-judge
2024-05-11T20:10:10Z
koolexcrypto marked the issue as satisfactory