Platform: Code4rena
Start Date: 15/12/2022
Pot Size: $128,000 USDC
Total HM: 28
Participants: 111
Period: 19 days
Judge: GalloDaSballo
Total Solo HM: 1
Id: 194
League: ETH
Rank: 91/111
Findings: 1
Award: $21.71
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: gz627
Also found by: AkshaySrivastav, Allarious, Czar102, HE1M, HollaDieWaldfee, KmanOfficial, adriro, ast3ros, betweenETHlines, bin2chen, brgltd, cccz, chaduke, hihen, imare, mookimgo, neumo, nogo, peanuts, unforgiven
21.713 USDC - $21.71
storage "contract.address"+name is wrongly set to zero when guardian call upgradeExistingContract with the same name
It's common that a contract will get updated with the same name, thus calling upgradeExistingContract
with the same (newName is the same as the old name).
In this upgradeExistingContract
function, it will first call registerContract
function, which writes the storage setAddress(keccak256(abi.encodePacked("contract.address", name)), addr);
, but afterwards, it calls unregisterContract
, which clears the storage: deleteAddress(keccak256(abi.encodePacked("contract.address", name)));
.
So after this call, the contract.address+name
is wrongly cleared, which makes getContractAddress fails in https://github.com/code-423n4/2022-12-gogopool/blob/1c30b320b7105e57c92232408bc795b6d2dfa208/contracts/contract/BaseAbstract.sol#L90 :
if (contractAddress == address(0x0)) { revert ContractNotFound(); }
This further makes all functionalities relying on getContractAddress fail
For example, after upgrade Staking
contract, isEligible function in https://github.com/code-423n4/2022-12-gogopool/blob/1c30b320b7105e57c92232408bc795b6d2dfa208/contracts/contract/ClaimNodeOp.sol#L47 will fail.
reading code
change to unregister first.
function upgradeExistingContract( address newAddr, string memory newName, address existingAddr ) external onlyGuardian { unregisterContract(existingAddr); registerContract(newAddr, newName); }
#0 - c4-judge
2023-01-09T10:05:20Z
GalloDaSballo marked the issue as duplicate of #742
#1 - c4-judge
2023-02-08T20:09:47Z
GalloDaSballo marked the issue as satisfactory