ParthMandale - The incorrect address is removed in _deleteAddressAtIndexFromArray() #316
Labels
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
ParthMandale
Medium
The incorrect address is removed in _deleteAddressAtIndexFromArray()
Summary
function
_deleteAddressAtIndexFromArray
- is used to delete the address of the user that is associated with that current profile id at that index.And therefore this function is supposed to - remove that particular index of arrays(addresses) from the
addresses
array.And at the same time that same particular address of index of arrays(addresses) is supposed to be added in
removedAddresses
array.But here the last index is added in removedAddresses array ->
removedAddresses.push(addr);
which is completely wrong.Root Cause
https://github.com/sherlock-audit/2024-10-ethos-network/blob/db37b9dc2b792e245eb683d8a956bcb7ef2f1a27/ethos/packages/contracts/contracts/EthosProfile.sol#L591
Whenever a user deletes an address at an index through
deleteAddressAtIndex()
it would delete wrong address.Then in function
_deleteAddressAtIndexFromArray
is getting executed -We can clearly see that, here the last index is added in removedAddresses array ->
removedAddresses.push(addr);
which is wrong and insteadindex
that was passed was supposed to be push into thisremovedAddresses
array.Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
No response
Impact
The incorrect address is removed in _deleteAddressAtIndexFromArray()
If someone has two addresses, one is compromised, but the other one is still valid. If removal of the wrong address is happening, the other account that was supposed to be removed index, is now has control over the account. The attacker can archive the profile and front-run any attempt to un-archive it, keeping the profile permanently out of the hands of the valid owner.
PoC
No response
Mitigation
Implement
_deleteAddressAtIndexFromArray
function like this -The text was updated successfully, but these errors were encountered: