Open code423n4 opened 2 years ago
The reverse for a name can be set to any name a user wants to, so despite this being a bug that it is possible, the name is still registered to the correct account and alice has just registered the name for bob and paid the registration fee, and has set her reverse to bob's name (but she could do that already, because setName can be set to anything that you would like).
I'm downgrading this to QA. There is a bug, but no negative impact on Bob.
Lines of code
https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/ETHRegistrarController.sol#L170 https://github.com/code-423n4/2022-07-ens/blob/ff6e59b9415d0ead7daf31c2ed06e86d9061ae22/contracts/ethregistrar/ETHRegistrarController.sol#L270-L281
Vulnerability details
Impact
To prevent front running, the
ETHRegistrarController
contract uses a two-step process to register names. First one has to callETHRegistrarController.commit
with the desired configuration parameters and wait forminCommitmentAge
to pass by. Then a call toETHRegistrarController.register
with the same parameters as in the previous step to finally register the name. ThisETHRegistrarController.register
can be front-run without any consequences by anyone else. At least that's the case for registering the name.If
reverseRecord
is set totrue
and theETHRegistrarController.register
function is called by anyone else than theowner
, a reverse record withname
is set for the caller addressmsg.sender
instead of theowner
.Proof of Concept
ETHRegistrarController.sol#L170
ETHRegistrarController._setReverseRecord
Example
foo.eth
and callsETHRegistrarController.commit
with the appropriate parameters andreverseRecord = true
minCommitmentAge
, Bob callsETHRegistrarController.register
with the same parameters as in the step beforefoo.eth
is successfully registered (with Bob as the owner), however, Alice has now her address associated with a reverse record set tofoo.eth
and Bob is missing the reverse record for his address.Copy-paste the following test into the
TestEthRegistrarController.js
file and run the tests:Tools Used
Manual review
Recommended mitigation steps
Consider using the
owner
instead ofmsg.sender
:ETHRegistrarController.sol#L170
ETHRegistrarController._setReverseRecord