code-423n4 / 2023-10-brahma-findings

8 stars 7 forks source link

ConsoleFallbackHandler.sol#simulate transaction cannot simulate transaction properly #467

Closed c4-submissions closed 10 months ago

c4-submissions commented 10 months ago

Lines of code

https://github.com/code-423n4/2023-10-brahma/blob/dd0b41031b199a0aa214e50758943712f9f574a0/contracts/src/core/ConsoleFallbackHandler.sol#L104

Vulnerability details

Impact

ConsoleFallbackHandler.sol does not use static call or delegate call

Proof of Concept

In the function

/**
     * @dev Performs a delegetecall on a targetContract in the context of self.
     * Internally reverts execution to avoid side effects (making it static). Catches revert and returns encoded result as bytes.
     * @param targetContract Address of the contract containing the code to execute.
     * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).
     */
    function simulate(address targetContract, bytes calldata calldataPayload)
        external
        returns (bytes memory response)
    {

the simulate function is meant to simulate a call, so to simulate a call, the transaction should use staticcall to make sure that there is no state change

but the staticcall is not used, instead, call is used

also, the parameter targetContract and calldataPayload is not really used

the simulate call is not marked as payable, so the code cannot simulate call behavior with ETH attached

In short, the simulate function cannot really simulate cal

Tools Used

Manual Review

Recommended Mitigation Steps

mark the simulate function payable and use static call to simulate the transction properly

Assessed type

Access Control

c4-pre-sort commented 10 months ago

raymondfam marked the issue as sufficient quality report

c4-pre-sort commented 10 months ago

raymondfam marked the issue as duplicate of #29

c4-pre-sort commented 10 months ago

raymondfam marked the issue as duplicate of #88

c4-judge commented 10 months ago

alex-ppg marked the issue as unsatisfactory: Invalid