ProtocolDAO::upgradeExistingContract
is not working as intended and can have bad consequences
#706
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-742
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2022-12-gogopool/blob/aec9928d8bdce8a5a4efe45f54c39d4fc7313731/contracts/contract/ProtocolDAO.sol#L209-L217
Vulnerability details
The contracts used in
GoGoPool
protocol are using fixed names when interacting with each other. For example:The function
upgradeExistingContract
if used to upgrade an existing contract name with a new address will result ingetContractAddress
function to return zero address for the upgraded contract address.If used with a new name then
getContractAddress
will return the supplied address but as already stated the protocol uses fixed names.Impact
If an upgrade like this happen funds can be lost for example:
When distributing rewards
funds can be lost if the upgrade happened for "Vault" when
vault.transferToken("ClaimProtocolDAO", ggp, daoClaimContractAllotment);
is called the function will not revert but also the token amount will be lostOr for example in
claimAndRestake
function:again
vault.withdrawToken(msg.sender, ggp, claimAmt);
will not work as expected.Proof of Concept
https://github.com/code-423n4/2022-12-gogopool/blob/aec9928d8bdce8a5a4efe45f54c39d4fc7313731/contracts/contract/ProtocolDAO.sol#L209-L217
Add the following test to
ProtocolDAO.t.sol
unit test file:run with
forge test -m testUpgradeExistingContract_POC1
the test will fail when comapring the expected address with the real return after upgrading an existing contract name:[FAIL. Reason: Assertion failed.] testUpgradeExistingContract_POC1() (gas: 159000) Logs: Error: a == b not satisfied [address] Expected: 0x934eb1f9d0f59695050f761dc64e443e5030a569 Actual: 0x0000000000000000000000000000000000000000
Tools Used
Manual review
Recommended Mitigation Steps
Invert the order of operation as stated in the function comment header
The text was updated successfully, but these errors were encountered: