GoGoPool contest - mookimgo's results

Liquid staking for Avalanche.

General Information

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

GoGoPool

Findings Distribution

Researcher Performance

Rank: 91/111

Findings: 1

Award: $21.71

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

21.713 USDC - $21.71

Labels

bug
2 (Med Risk)
satisfactory
edited-by-warden
duplicate-742

External Links

Lines of code

https://github.com/code-423n4/2022-12-gogopool/blob/main/contracts/contract/ProtocolDAO.sol#L190-L215

Vulnerability details

Impact

storage "contract.address"+name is wrongly set to zero when guardian call upgradeExistingContract with the same name

Proof of Concept

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.

Tools Used

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

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter