Open hats-bug-reporter[bot] opened 2 months ago
"Description: 2. If the success condition is true, it overwrites the existing humanity data without checking if it belongs to a different owner." This seems to be incorrect as if there is already an existing humanity on the receiving chain, it will not be overwritten.
"Attack Scenario: 3. Eve quickly submits a malicious transfer to Chain B with the same transfer hash but using her own address as the owner." This doesn't seem possible as the transfer hash is function of the Humanity ID. And as per "Attack Scenario: 1. Alice initiates a legitimate transfer of her Humanity ID from Chain A to Chain B." Alice is the owner of this Humanity ID.
Github username: -- Twitter username: -- Submission hash (on-chain): 0xaf1a5eeff9e700e9c7fa7560a4353a8fb8e3c8c3a647e31952527588ed7be2ba Severity: high
Description:
Transfer Hash Collision Allows Malicious Takeover of Humanity IDs
Description
The
receiveTransfer
function in the CrossChainProofOfHumanity contract is vulnerable to a transfer hash collision attack. This vulnerability allows a malicious actor to potentially block legitimate transfers and take over Humanity IDs that were intended for other users.The vulnerability arises from the following issues:
_transferHash
has been received before, not if the_humanityId
is already associated with an owner.success
condition is true, it overwrites the existing humanity data without checking if it belongs to a different owner.receivedTransferHashes[_transferHash]
is set to true at the end of the function, regardless of whether the transfer was successful or not.Attack Scenario
Proof of Concept
Test Output
Recommended Fix
To address this vulnerability, consider implementing the following changes:
_humanityId
is already associated with an owner before processing the transfer._transferHash
as received if the transfer is successful.Here's a potential fix:
This fix ensures that a humanity can only be claimed if it wasn't already claimed, preventing malicious actors from overwriting existing claims.
The vulnerability allows an attacker to take over someone else's Humanity ID. The proposed fix addresses the issue by adding additional checks to ensure that a humanity can only be claimed if it wasn't already claimed, thus preventing malicious actors from overwriting existing claims.