thehubbleproject / hubble-contracts

Hubble optimistic rollup
https://thehubbleproject.github.io/docs/
MIT License
133 stars 29 forks source link

C2T to non-existent PublicKey #669

Closed b-tarczynski closed 3 years ago

b-tarczynski commented 3 years ago

Right now it's possible to create a C2T transaction to an account that doesn't exist and that transaction would be impossible to dispute. If user creates and signs C2T transaction with ToPublicHash = keccak256(abi.encode(0)) that will create UserState with pubkeyID that isn't assigned to anyone. These funds will be available to the user with publicKey that will get this pubkeyID due to future account registration.

I think that single if statement would fix this problem after this require. https://github.com/thehubbleproject/hubble-contracts/blob/c1d1f197ba9b68284cbc4ec145e286a4e84c0eaf/contracts/libs/Authenticity.sol#L177

if (proof.pubkeyHashesReceiver[i] == MerkleTree.getRoot(0)) {
    return Types.Result.NonexistentReceiver;
}