Glorious Cinnabar Kestrel
Medium
The EthosProfile::registerAddress()
function allows users to add addresses to their profiles, either as new entries or by restoring previously deleted ones. However, when a user restores an address they previously removed, this address remains in Profile.removedAddresses
instead of being deleted. As a result, it is counted twice, once in Profile.addresses
and once in Profile.removedAddresses
, leading to an incorrect limitation on the total number of addresses a user can register.
The registerAddress()
function explicitly allows the user to restore previously deleted addresses:
// you may restore your own previously deleted address,
// but you cannot register an address that has been deleted by another user
if (profileIdByAddress[addressStr] != profileId && isAddressCompromised[addressStr]) {
revert AddressCompromised(addressStr);
}
However, the function does not remove the restored address from Profile.removedAddresses
. This leads to a situation where the same address is counted in both Profile.addresses
and Profile.removedAddresses
, wrongly reducing the user's maximum addresses:
function checkMaxAddresses(uint256 profileId) internal view {
uint256 sum = profiles[profileId].addresses.length;
sum += profiles[profileId].removedAddresses.length;
if (sum > maxNumberOfAddresses) {
revert MaxAddressesReached(profileId);
}
}
No response
The user must restore a previously deleted address.
The default limit of addresses is 128.
- Assume a user has 127 active addresses on
Profile.addresses
and 1 removed address onProfile.removedAddresses
- Assume the user decides to restore the previously deleted address via
EthosProfile::registerAddress()
- The user's transaction will revert with a
MaxAddressesReached
error, as the removed address will be added toProfile.addresses
, making it 128 addresses, but will not be removed fromProfile.removedAddresses
, thus being double counted
Once Profile.addresses
+ Profile.removedAddresses
reaches maxNumberOfAddresses
, users are blocked from restoring any deleted addresses.
No response
Include logic in EthosProfile::registerAddress()
to remove the address from the array of removedAddresses
when restoring an address.