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

[audit] #21: Add Controllers to ReverseRegistrar #43

Merged
merged 7 commits into from
Jul 9, 2024

Conversation

stevieraykatz
Copy link
Collaborator

@stevieraykatz stevieraykatz commented Jun 24, 2024

The RegistrarController needs to be a permissioned caller to the ReverseRegistrar or it will not be able to set reverse records upon registration. Somehow when migrating from the ENS contracts, I missed this pattern. This PR:

  • Adds the concept of permissioned controllers via a mapping address => bool
  • Adds unit tests for the new onlyOwner setter method and checks that a permissioned controller passes the authoriszed check
  • Fixes the deployment script to match the new constructor args

From Spearbit:

Description
For RegistrarController to be able to call reverseRegistrar using the current implementations, the msg.sender must have approved RegistrarController in Registry so that the following would return true:

// msg.sender to `RegistrarController`
registry.isApprovedForAll(msg.sender, RegistrarController)

Recommendation
To avoid having all the users to set the above permission/approval, one can do either of the following:

  1. have the ReverseRegistrar to be automatically approved for all users in Registry or
  2. have the ReverseRegistrar to be an authorised entity for all users in ReverseRegistrar.

Second option might be preferred since it limits how much privilege the ReverseRegistrar would have in the whole ecosystem.

@stevieraykatz stevieraykatz changed the title Add Controllers to ReverseRegistrar [audit] #21: Add Controllers to ReverseRegistrar Jun 25, 2024
Comment on lines +69 to +82
function test_allowsController_toClaimForAddr_forUserAddress() public {
bytes32 labelHash = Sha3.hexAddress(user);
bytes32 reverseNode = keccak256(abi.encodePacked(ADDR_REVERSE_NODE, labelHash));

vm.expectEmit(address(reverse));
emit ReverseRegistrar.ReverseClaimed(user, reverseNode);
vm.prank(controller);
bytes32 returnedReverseNode = reverse.claimForAddr(user, user, resolver);
assertTrue(reverseNode == returnedReverseNode);
address retOwner = registry.owner(reverseNode);
assertTrue(retOwner == user);
address retResolver = registry.resolver(reverseNode);
assertTrue(retResolver == resolver);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be also best to add a test for a caller which is non of the valid 4 options.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have that above? see test_reverts_ifNotAuthorized

@stevieraykatz stevieraykatz merged commit 5cc7f34 into main Jul 9, 2024
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants