TempleGold

TempleDAO
Foundry
25,000 USDC
View results
Submission Details
Severity: high
Invalid

Chain id variable _mintChainId should be updatable on TempleGold.sol in case of chain hard-fork

Summary

Variable that holds the block.chainid is immutable - therefore it can not be changed. This could lead to vulnerabilities in case the built-in block.chainid changes due to a hard fork.

Vulnerability Details

Due to the nature of the blockchain logic, it can go through a hard fork when going through an update. In such cases - the built-in variable block.chainid can change to a new value.
This will break the TempleGold contract since it has an immutable _mintChainId variable to determine if its being used on Arbitrum. Once the chain goes through a hipothetical hard fork - the contract is left useless since this modifier will not go through:

modifier onlyArbitrum() {
if (block.chainid != _mintChainId) { revert WrongChain(); }
_;
}

It will revert with WrongChain().

In order for this to happen - Arbitrum has to go through a hard fork that changes its chain id. Even though its unlikely - it has the potential to completely break the protocol.

Inspiration for submission found here:
https://zokyo-auditing-tutorials.gitbook.io/zokyo-tutorials/tutorials/tutorial-4-block.chainid-domain_separator-and-eip-2612-permit/understanding-block.chainid-and-domain_separator

Impact

Impact is sufficient to break entire protocol functionality since minting is not possible on the main chain - in case it changes its block.chainid after hard fork.

Tools Used

Manual review

Recommendations

Store _mintChainId in a mutable variable so it can be updated if a fork happens and the in-built block.chainid variable changes.

Add following function:

function updateChainId(uint256 updatedChainId) external onlyOwner {
_mintChainId = updatedChainId;
}

Alternatively, implement a mechanism for pausing mints and distributions of tokens in order to setup a new contract on the forked chain.

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Appeal created

matejdb Submitter
about 1 year ago
matejdb Submitter
about 1 year ago
matejdb Submitter
about 1 year ago
inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.