Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oxchryston - Calling the initialize function in the constructor() while passing address(0) as parameters will render contract unusable. #72

Open
sherlock-admin2 opened this issue Sep 25, 2024 · 0 comments

Comments

@sherlock-admin2
Copy link

sherlock-admin2 commented Sep 25, 2024

oxchryston

Medium

Calling the initialize function in the constructor() while passing address(0) as parameters will render contract unusable.

Summary

Passing address(0) as parameters when calling the initialize function from the constructor(0) will lock the contract and the right addresses cannot be set again.

Vulnerability Detail

The bug affects; L2StandardBridge.sol, L1StandardBridge.sol, L1crossDomainMessenger.sol and L2crossDomainMessenger.sol and optimismportal2.sol. The initialie() function in these contracts implements the initializer modifier which ensures that the initialize function can only be called once. The bug here is that the initialize function is called in the constructor() using null addresses as parameters and since the initialize function cannot be called again, the contract becomes locked.

Impact

Contracts are initialized with the zero address which renders them unusable.

Code Snippet

constructor(uint256 _proofMaturityDelaySeconds, uint256 _disputeGameFinalityDelaySeconds) {
        PROOF_MATURITY_DELAY_SECONDS = _proofMaturityDelaySeconds;
        DISPUTE_GAME_FINALITY_DELAY_SECONDS = _disputeGameFinalityDelaySeconds;

        initialize({
            _disputeGameFactory: DisputeGameFactory(address(0)),
            _systemConfig: SystemConfig(address(0)),
            _superchainConfig: SuperchainConfig(address(0)),
            _initialRespectedGameType: GameType.wrap(0)
        });
    }

Code Links

https://github.com/sherlock-audit/2024-08-tokamak-network/blob/main/tokamak-thanos/packages/tokamak/contracts-bedrock/src/L1/OptimismPortal2.sol#L153
https://github.com/sherlock-audit/2024-08-tokamak-network/blob/main/tokamak-thanos/packages/tokamak/contracts-bedrock/src/L1/OptimismPortal2.sol#L169

Tool used

Manual Review

Recommendation

Use proper addresses in initializing the contracts instead of the zero address

@sherlock-admin4 sherlock-admin4 changed the title Faint Chartreuse Pelican - Calling the initialize function in the constructor() while passing address(0) as parameters will render contract unusable. oxchryston - Calling the initialize function in the constructor() while passing address(0) as parameters will render contract unusable. Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant