Submitted by d4r3d3v1l
https://github.com/code-423n4/2025-01-initia-move/blob/main/usernames-module/sources/name_service.move#L350
https://github.com/code-423n4/2025-01-initia-move/blob/main/usernames-module/sources/name_service.move#L158
https://github.com/code-423n4/2025-01-initia-move/blob/main/usernames-module/sources/name_service.move#L175
The register_domain function doesnt properly clean up old mappings (name_to_addr and addr_to_name) when a new user registers an expired domain. While it removes the old name_to_token mapping, it leaves the previous users address mappings.
When a new user re-registers an expired domain:
Loss of Funds: get_address_from_name returns the address of the previous user.
While sending tokens, we can enter either domain or address. If we enter the domain name, it uses get_address_from_name function to retrieve the address. The funds will be transferred to the previous user, not to the one who owns the domain.
Request to fetch the address from the domain name:
Initial State:
After Domain Expires:
User2 Registers Expired Domain:
Note : User2 didnt call the set_name.
Loss of funds scenario: User X want to transfer some tokens to User2 and  type the abc.init in the address input,the function get_address_from_name fetch the User1 address instead and funds will transfer to User1 instead of User2.
Note: I verified the loss of funds scenario in the testnet with the help of this site. 
I changed the end_to_end test in name_service.move: 
Remove the previous values after registering the domain in the register_domain function, instead of handling it in set_name.
andrew (Initia) confirmed and commented:
LSDan (judge) decreased severity to Medium and commented:
d4r3d3v1l (warden) commented:
LSDan (judge) commented:
