-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fix for sherlock issues 46, 43, 42 #10
Conversation
(address[] memory modulesWith1, address next) = safe.getModulesPaginated(SENTINEL_OWNERS, 1); | ||
// ensure that there is only one module... | ||
if ( | ||
// if the length is 0, we know this module has been removed | ||
// forgefmt: disable-next-line | ||
modulesWith1.length == 0 | ||
/* per Safe ModuleManager.sol#137, "If all entries fit into a single page, the next pointer will be 0x1", ie SENTINEL_OWNERS. | ||
Therefore, if `next` is not SENTINEL_OWNERS, we know another module has been added. */ | ||
|| next != SENTINEL_OWNERS | ||
) { | ||
revert SignersCannotChangeModules(); | ||
} // ...and that the only module is this contract | ||
else if (modulesWith1[0] != address(this)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine. You are checking three conditions with the same error message (and we exit the if early if modulesWith1.length == 0, so the indexing will work), so probably easiest to just stack them into one statement like:
if(
modulesWith1.length == 0
|| next != SENTINEL_OWNERS
|| modulesWith1[0] != address(this)
) ...
Honestly, I would probably just get a page of 2 modules and simply check:
if(modulesWith1.length != 1 || modulesWIth1[0] != address(this)) ...
But either way works. This solution will accomplish the goal, so marking it as approved.
Fix for sherlock issue 93
Fix for sherlock issue 41
Fix for sherlock issue 38
Fix for sherlock issue 50
Address the following issues by disallowing any modules other than (M)HSG:
sherlock-audit/2023-02-hats-judging#46
sherlock-audit/2023-02-hats-judging#43
sherlock-audit/2023-02-hats-judging#42