Open hats-bug-reporter[bot] opened 2 months ago
accountHumanity
is to keep track of humanity which are bridged. In the case of a humanity being transferred, we do overwrite the info about the previous transfer. In your specific case, there is already a registered humanity, so this is the humanity which should take precedence.
Github username: -- Twitter username: -- Submission hash (on-chain): 0x27ed1be1380e76ef468a5c6c05bc01589038111225ba504683fa5e6ee7bc1c86 Severity: medium
Description:
Inconsistent State in
CrossChainProofOfHumanity
After Failed TransferDescription
The
CrossChainProofOfHumanity
contract contains a vulnerability in itsreceiveTransfer
function. When a transfer fails (i.e., the humanity is already claimed), the function still updates certain state variables, leading to an inconsistent state. This inconsistency could potentially be exploited or cause unexpected behavior in the contract.Issue Scenario
accountHumanity
mapping for the original owner, breaking the link between the owner and their humanity.receivedTransferHashes
mapping is updated, marking the failed transfer as received.This scenario results in a state where:
humanityData
mapping.accountHumanity
mapping no longer associates the original owner with their humanity.Attachments
Test Output
Revised Code Suggestion
This fix addresses the vulnerability by:
accountHumanity
if the transfer succeeds.These changes ensure that the contract maintains a consistent state even when a transfer fails, mitigating the potential for exploitation or unexpected behavior.