Submitted by carrotsmuggler, also found by tchkvsky, pontifex, falconhoof, Hueber, Tychai0s, Evo, 0xlemon, d3e4, Mahmud, sashik_eth (1, 2), 0xleadwizard, SBSecurity, oakcobalt, Circolors, 3th, 0xSecuri, 0xtankr, alix40, ke1caM (1, 2), n4nika, TheSchnilch, btk, bbl4de, steadyman, Egis_Security, ducanh2706, lian886 (1, 2), zhuying, Aamir, TheSavageTeddy, itsabinashb (1, 2), 0xAlix2, Bauchibred, and Abdessamed
The kerosene manager is the contract responsible for managing kerosene prices. In the current state it has broken functionality due to the design. The KeroseneManager contract contains a list of vaults.
When we look at UnboundedKerosineVault contract, we see what those vaults are used for:
The KeroseneManager contract is expected to have a list of the backing vaults. This list is then queried for the individual assetPrice(). Crucially, the KeroseneManager contract will not have the vault which takes kerosene as the asset. This is because calling assetPrice on a vault handling kerosene will make it go into an infinite loop.
So this section of the code expects the KeroseneManager contract to only contain a list of the vaults which has exo collateral.
Now, lets look at VaultManagerV2.sol contracts getKeroseneValue function. This function is supposed to return the value of kerosene tokens a user has deposited. It should do this by querying all the vaults, which takes kerosene as the deposit.
So the vaultsKerosene should hold the vaults which take kerosene as its deposit. Then, the code calls keroseneManager.isLicensed(address(vault). The isLicensed function only checks in the same vaults array in the kerosene manager.
So, this expects the KeroseneManager to also contain the kerosene accepting vaults as well!
We have shown that in UnboundedKerosineVault, the KeroseneManager contract is expected to have only the backing vaults, not the kerosene deposit vaults itself, or it will enter an infinite loop. We have also shown that in VaultManagerV2, the KeroseneManager contract is expected to have the kerosene deposit vaults as well, or it will not be able to pass the isLicensed check.
Both the above statements cannot be true at the same time. This is a design flaw. The KeroseneManager contract, if it contains the kerosene deposit vaults will break the kerosene pricing mechanism, and if it does not, it will break the manager contract. Thus, the current design is flawed and will break the functionality.
If we look at the deployment script, we see that the kerosene manager only has the backing vaults:
This means the managers isLicensed call will fail for vaults which accept kerosene.
This is a design flaw as described above. A proof of concept cannot be shown since its broken functionality.
Store the kerosene vaults info in the Licenser contract. Then change the keroseneManager.isLicensed call to vaultLicenser.isLicensed in the manager contract.
Error
shafu0x (DYAD) disputed and commented:
Koolex (judge) commented:
shafu0x (DYAD) confirmed and commented:
