Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Compare ownership nominations against
s_owner, rather thanmsg.sender, inOwnable2Step._transferOwnership.Constructor edge case
The constructor accepts an initial owner and an optional pending owner. It sets
s_owner = newOwnerbefore calling_transferOwnership(pendingOwner). At that point,msg.senderis the deployer (or factory), not necessarily the initial owner.For distinct addresses D (deployer) and O (initial owner):
newOwner = O, pendingOwner = DCannotTransferToSelfnewOwner = O, pendingOwner = OCannotTransferToSelfThis is a constructor-validation correctness issue for specific arguments, not a demonstrated ownership-takeover vulnerability.
Fix and compatibility
Ownable2StepMsgSenderinitializes with a zero pending owner and is unaffected by the constructor edge case.Tests
Added deterministic regression tests for both constructor cases, a normal constructor nomination/acceptance test, a fuzz test over deployer/owner/nominee combinations, and a zero-address cancellation regression.
Before the fix, the added tests reproduce three failures (including the fuzz counterexample). After the fix:
git diff --checkpassed. The test file is normally excluded by the repository's test lint ignore list; it was additionally linted explicitly using--ignore-path /dev/null.Validation used Foundry v1.7.1, the
sharedprofile, Solidity 0.8.26, Paris EVM, and 1,000,000 optimizer runs. Other product suites were not run locally; upstream CI remains necessary.Includes a patch changeset and updated shared gas snapshot.