hats-finance / Intuition-0x538dbadc50cc87b281cd655f1edbc6ebda02a66a

The smart contracts of the Intuition protocol v1.
https://intuition.systems
Other
0 stars 1 forks source link

Missing Nonce Validation in AtomWallet Contract #18

Open hats-bug-reporter[bot] opened 5 months ago

hats-bug-reporter[bot] commented 5 months ago

Github username: -- Twitter username: -- Submission hash (on-chain): 0xf4248046b3d18747563bcd905d0c6d0ab222b0a44e81966ad0980bb8863621d9 Severity: high

Description: Description\ The AtomWallet contract inherits from the BaseAccount abstract contract. The BaseAccount contract includes a virtual function, validateUserOp, which is designed to validate user operations, including signature and nonce validations. However, the AtomWallet contract does not override the _validateNonce function. This omission can lead to replay attacks on the protocol.

Attack Scenario\

  1. Initial Transaction by User:

    • Alice initiates a transaction to transfer 10 tokens using the AtomWalletVulnerable contract.
    • The transaction includes:
      • A nonce (nonce_A) to uniquely identify this transaction.
      • A signature (signature_A) of the transaction data.
      • A user operation hash (userOpHash_A).
    • The transaction is successfully processed by the contract, transferring 10 tokens from Alice's account.
  2. Capture and Replay Attack:

    • Eve, an attacker, intercepts and captures the signed transaction data (nonce_A, signature_A, userOpHash_A).
    • Eve replays the exact same transaction data (nonce_A, signature_A, userOpHash_A) to the AtomWalletVulnerable contract.
  3. Execution of Replay Attack:

    • The AtomWalletVulnerable contract receives the replayed transaction from Eve.
    • Since the contract does not validate the nonce (nonce_A), it considers the replayed transaction as a new and valid operation.
    • The contract again transfers 10 tokens from Alice's account to Eve's account.
  4. Impact on Alice:

    • Alice's account is debited twice for the same operation (transferring 20 tokens in total), despite her intending to perform the transaction only once.
    • Alice incurs a loss of additional tokens due to the unauthorized replay attack.

Attachments

  1. Proof of Concept (PoC) File

  2. Revised Code File (Optional)

Files:

mihailo-maksa commented 4 months ago

Upon careful review, we believe the concern about nonce validation is based on a misunderstanding of how nonce management works within the EntryPoint contract in the account abstraction model. Here are the key points supporting our position:

  1. Nonce Management by EntryPoint: The validateUserOp function in the BaseAccount contract already includes nonce validation through the _validateNonce function, which is managed by the EntryPoint contract. This ensures that nonce collisions and replay attacks are prevented as part of the standard account abstraction implementation.
  2. Role of EntryPoint: The EntryPoint contract is responsible for handling the nonce and ensuring that each transaction is unique and cannot be replayed. This functionality is inherent in the design of account abstraction and is already implemented in our system.
  3. Additional Checks: While _validateNonce is critical for preventing replay attacks, we have verified that nonce validation is appropriately handled when transactions are processed through the EntryPoint.

In conclusion, the concern about missing nonce validation is invalid as nonce management is already handled by the EntryPoint contract in the account abstraction model. The system works as intended, and the PoC provided does not demonstrate a valid vulnerability, and is not even correctly representing our AtomWallet contract; instead it uses the AtomWalletVulnerable contract, which is not reflecting the feature set of our original AtomWallet contract correctly. Therefore, no changes are required and the issue is considered to be invalid.