Exploring New Ideas to Address the Concerns Raised by the Community
By @nick.eth
However, I donât believe itâs safe in general to allow the deployer to set the primary name on a contract. Often, dedicated or shared deployment accounts are used, and ownership of the contracts is then transferred elsewhere post-deployment - if thereâs any ownership at all. Not infrequently, these deployment accounts get compromised, in which case anyone who obtains the leaked credentials would now also be in a position to set an arbitrary primary name for all the contracts the account deployed.
Proposed Solution
To address the concerns raised by the Nick, weâre introducing a tiered permission system for setting a contractâs primary ENS name:
Level 1 - Contract is Ownable/ERC-173
- If the contract implements
Ownable
orERC-173
, only theowner()
should be allowed to claim the reverseNode. - In this case, do not proceed to check the deployer.
Level 2 - Contract Deployed via ReverseClaimable Mechanism
- If the
reverseNode
has already been claimed by another account, and the sender is not that account, then reject the attempt to claim the reverse record by the deployer or set a primary name. - Do not check further conditions.
Level 3 - Fallback for Non-Ownable Contracts
- If the contract is neither Ownable/ERC-173 nor has its
reverseNode
claimed during deployment, - Then allow the sender to set the primary name only if they are the original deployer of the contract.
By @raffy
I donât think it is safe in general for contracts to be claimed by their deployer.
If we can eliminate the risk where the reverse resolution of a contract address doesnât match its forward resolution, we effectively remove the primary incentive for a scammer to manipulate the contractâs primary name.
Iâll discuss how to mitigate this risk further at the end of the proposed solution.
Currently, only a small fraction of contracts are eligible to set primary names.
If we can increase that eligibility to 80â90% of contracts (for now eliminating contracts deployed thorugh factory contracts), it would be a significant win for both the ENS and broader Ethereum communities.
By @gregskril
To explore further:
- AA deployers
- Burner/compromised key deployments
Burner/Compromised Key Deployments
While this is a broader Ethereum issue, if a private key is compromised, thereâs no truly safe recovery path, such contracts shouldnât be considered safe to interact with in the first place.
However, if we can eliminate the risk where reverse resolution does not match forward resolution, then the motivation for a scammer to set or manipulate a primary name disappears.
Account Abstraction (AA) Deployers
Since these contract deployments occur through fixed EntryPoint
contracts, we can reliably filter them.
We can enforce a rule that contracts deployed via EntryPoint
are not allowed to have their primary name set via the EntryPoint
address, thereby preventing misuse.
Revised Solution After Considering the Concerns
We need to understand the motivation of a hacker or scammer for changing the primary name of a contract, whether by gaining access to the deployerâs private key or exploiting permissions.
Legitimate Scenario (Genuine Contract Deployer)
- Contract:
0x123abcâŠ
- ENS Name:
genuine.original.eth
- Reverse Resolution:
0x123abcâŠ.addr.reverse
âgenuine.original.eth
- Forward Resolution:
genuine.original.eth
â0x123abcâŠ
Attack Scenario (Scammer/Hacker)
- Contract:
0x123abcâŠ
- ENS Name:
fake.scammer.eth
- Reverse Resolution:
0x123abcâŠ.addr.reverse
âfake.scammer.eth
- Forward Resolution:
fake.scammer.eth
â0x456defâŠ
This creates a misleading link where reverse and forward resolutions donât align, enabling scam potential.
If we can eliminate this mismatch, ensuring that reverse and forward resolution always align then we remove the scammerâs motivation to change the primary name in the first place.
Rephrasing in more technical terms - If we disallow setting any name as a contractâs primary name unless it forward-resolves to that contract address, and also prevent any name from changing its forward resolution unless it is set as the reverse resolution of a contract, we can effectively eliminate the scammerâs motivation to manipulate a contractâs primary name.
Take the previous example again:
Genuine Contract Deployer
The legitimate deployer claims the reverse node and sets the primary name for the contract:
- Contract:
0x123abcâŠ
- ENS Name:
genuine.original.eth
- Reverse Resolution:
0x123abcâŠ.addr.reverse
âgenuine.original.eth
- Forward Resolution:
genuine.original.eth
â0x123abcâŠ
Scammer/Hacker Scenario
A scammer gains the ability to change the primary name of the contract and sets it to their own ENS name:
- Contract:
0x123abcâŠ
- ENS Name:
fake.scammer.eth
They then:
- Set the forward resolution of
fake.scammer.eth
to0x123abcâŠ
- Set the reverse resolution of
0x123abcâŠ.addr.reverse
tofake.scammer.eth
Resulting in:
- Reverse Resolution:
0x123abcâŠ.addr.reverse
âfake.scammer.eth
- Forward Resolution:
fake.scammer.eth
â0x123abcâŠ
Now, under the proposed constraints, the scammer cannot change the forward resolution of fake.scammer.eth to any other address.
This effectively neutralizes the scam vector, as the ENS name becomes locked to the contract, unless a new name first forward-resolves to the contract and then replaces the old primary name through reverse resolution. This removes the incentive to exploit primary name assignments.
Implementation Plan
To achieve this, we need to create a new ContractResolver
and make some changes to the ReverseRegistrar
.
Changes in ReverseRegistrar
- Only allow a custom
ContractResolver
to be used as the resolver address when setting names viaclaimForAddr
andclaimWithResolver
. - Update the
authorised
modifier to include the deployer of the contract can also claim reverseNode.
ContractResolver
â Updates to NameResolver
Logic
- Check that the name forward-resolves to the contract address using the
addr()
function fromAddrResolver
.
ContractResolver
â Updates to AddrResolver
Logic
- Ensure the name/node is also set as a reverse record by checking the
name()
function fromNameResolver
.
The Enscribe team is keen and already working to address issues with smart contract naming. We believe that with the Namechain release and support for L2 primary names, if we can implement changes to allow all contracts to have a primary name, it would be a win for both us and the ENS community.