code-423n4 / 2024-03-coinbase-findings

1 stars 0 forks source link

User Funds at Risk of Lockup Due to Assertion Failure in `postOp` Function #40

Closed c4-bot-10 closed 6 months ago

c4-bot-10 commented 7 months ago

Lines of code

https://github.com/code-423n4/2024-03-coinbase/blob/e0573369b865d47fed778de00a7b6df65ab1744e/src/MagicSpend/MagicSpend.sol#L143-L163

Vulnerability details

Impact

If an operation fails legitimately and encounters postOpReverted, the assertion failure will prevent the remaining funds from being transferred back to the user. This could result in a situation where user funds become locked up in the contract, inaccessible to the user and unable to be recovered without manual intervention.

Proof of Concept

The vulnerability in the postOp function of the contract lies in its reliance on an assertion that PostOpMode.postOpReverted should never occur. Let's delve into the specifics:

  1. Assumption of Impossibility: The contract includes the following assertion:
    assert(mode != PostOpMode.postOpReverted);

    This assertion assumes that encountering PostOpMode.postOpReverted is impossible and should never happen during contract execution. It implies that any occurrence of postOpReverted would indicate an unexpected and erroneous state in the contract.

  2. Limited Error Handling:

Assessed type

Context

c4-pre-sort commented 7 months ago

raymondfam marked the issue as insufficient quality report

c4-pre-sort commented 7 months ago

raymondfam marked the issue as primary issue

raymondfam commented 7 months ago

This is part of the calls supported through bundler + entrypoint. So it's not going to happen as you described in the user call.

3docSec commented 6 months ago

Users seeing their UserOperation revert because they provided invalid inputs does not seem an impactful scenario, without a clear explanation of what the potentially adverse consequences could be.

c4-judge commented 6 months ago

3docSec marked the issue as unsatisfactory: Insufficient proof