Near-One / rainbow-token-connector

ERC-20/NEP-141 Token Connector for Rainbow Bridge
62 stars 18 forks source link

Token Factory can be abused #5

Closed mfornet closed 3 years ago

mfornet commented 3 years ago

I see an issues with the function deposit from BridgeTokenFactory.

This function receives as a parameter a proof that contains relevant information of an event that took place on Ethereum side, and relevant tokens are locked, so they can be safely minted in the NEAR side. The strategy to avoid double mints are storing all proofs in the state, and checking no repeated proof is stored.

  1. This approach has a clear drawback, which is that state might blow up, just from usage by legitimate users.
  2. Inside the deposit function, the first step is calling record_proof. This means, that any proof that is submitted, disregarding if it is correct or not, will be stored inside the contract. I think we should only store valid proofs, with valid merkle-roots from the Ethereum blockchain.
  3. Malicious user can prevent another user to mint its tokens if it call deposit with an invalid proof. In this case the deposit call will fail, but before failing, will store proof information with record_proof inside the contract, so this proof can't be used anymore.