Doc mentions:
There is only a single
Vault
at launch, but a newVault
can be made withcreateVault
The current carbon zETH
token is mapped to Vault.CARBON
having vault id as 1. This is through the mapping: mapping(address zeth => uint256 vault) zethVault
. The check in createVault() ensures same carbon zETH
token can not map to another vault.
A new vault should be created with a new zETH token.
Imagine the protocol owner or DAO
wants to create a new vault with a new token. Let's call this nzETH
(new zETH). So DAO
would ideally call the function in the following way to create a new vault:
This would create a new vault with vault id 5. No problems here.
Suppose now DAO
wants to create another new vault for an another token pzETH
(popular zETH). He wishes to use vault id 8 for this purpose. He calls the following, making a user input error:
The impact of this input error is high:
First, since the code only checks if (s.zethVault[address(pzETH)] != 0) revert Errors.VaultAlreadyCreated();
, this won't revert and pzETH
will be mapped to vault id in the next line via s.zethVault[address(pzETH)] = 5;
.
Vault 5 now has 2 tokens. Also, params for vault 5 like tithe
, dittoMatchedRate
& dittoShorterRate
are now reset using popularVaultParams
instead of the old newVaultParams
.
This could be problematic because now an external user can call depositZETH() with pzETH
.
and this will pass all the checks there, burn some pzETH
from external user's wallet, and increase user's ethEscrowed
as if he deposited carbon zETH
.
The second impact is: Since there is no unmapTokenFromVault()
or similar function in the protocol, there is no way for DAO
now to create another vault using pzETH
. Calling createVault()
will fail at if (s.zethVault[address(pzETH)] != 0) revert Errors.VaultAlreadyCreated();
since it has a value of 5 now.
He also can not "unmerge" these 2 tokens within the vault.
Owner's input error --> High impact on the protocol with no way to correct it, hence raising as medium severity.
Paste the following code inside test/Owner.t.sol
and run via forge test --mt test_InsufficientCheckInCreateVault -vv
. The test would revert with Reason: VaultAlreadyCreated()
-
Manual inspection, forge test.
Maintain a mapping of already created vault ids and check that too.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.