Open hats-bug-reporter[bot] opened 2 months ago
From my understanding of your report, there is no bugs, but you argue that if we were to change stuff we could introduce a bug. We can always introduce bugs by making changes.
As per contest rules: Only the smart contracts of the V2 are in scope. (so any hypothetical version would be out of scope)
As per the contest rules are excluded: Issues which can arise at deployment time but which didn't arise in the provided deployments (assume the contracts will always be deployed the way they were, this means that some are deployed using an upgradability proxy). In particular, the upgradable contracts use an initializer called during the deployment.
Github username: -- Twitter username: -- Submission hash (on-chain): 0xdeb98c21c483c87212467bd0f84f975dbf70ae384df677da8be460d3e7469eed Severity: low
Description:
Lack of Type Safety in Cross-Chain Message Encoding
Description
The
CrossChainProofOfHumanity
contract usesabi.encodeWithSelector
to encode cross-chain messages in theupdateHumanity
andtransferHumanity
functions. This method of encoding is not type-safe, which could lead to potential vulnerabilities if the interface of the receiving contract changes or if there are discrepancies in argument types.The lack of type safety means that any changes to the function signatures in the
ICrossChainProofOfHumanity
interface might not be caught at compile-time. This could result in runtime errors or unexpected behavior when messages are decoded and executed on the receiving chain.While the current implementation appears to match the expected function signatures, the use of
abi.encodeWithSelector
introduces unnecessary risk and reduces the contract's robustness against future changes or errors.Attack Scenario
ICrossChainProofOfHumanity
interface, changing the parameter types or order in thereceiveUpdate
orreceiveTransfer
functions.CrossChainProofOfHumanity
contract is not updated to reflect these changes.updateHumanity
ortransferHumanity
is called, the message is encoded with the old parameter types/order.Proof of Code
Problemaitc Code https://github.com/hats-finance/Proof-Of-Humanity-V2-0xef0709445d394a22704850c772a28a863bb780b0/blob/master/contracts/CrossChainProofOfHumanity.sol#L231-L232
Revised Code