Skip to content
Business logic Audit finding Intermediate

Permissive Fallback Function

The multi-signature wallet contract has a fallback function that accepts any call to a function it does not implement, so third-party contracts that rely on a revert to confirm intent will instead see success. This could lead to funds being lost when such a contract assumes the wallet agreed to an action.

kankodu Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

25935 - [SC - Insight] Permissive Fallback Function

Permissive Fallback Function

Submitted on Nov 21st 2023 at 15:08:55 UTC by @kankodu for Boost | DeGate

Report ID: #25935

Report type: Smart Contract

Report severity: Insight

Target: https://etherscan.io/address/0x2028834B2c0A36A918c10937EeA71BE4f932da52#code

Impacts:

  • Contract fails to deliver promised returns, but doesn't lose value

Description

Bug Description

  • The permissive fallback function executes successfully whenever a third-party contract attempts to call a function that doesn't exist in the wallet.
  • There are multiple contracts and standards that rely on the pattern of calling a handler function on user contracts to ensure they intend to perform a specific action. The assumption is that the user contract would revert if that action was unintentional. This assumption is violated here. For this multi-sig contract, all calls to it that are not its functions would succeed.
  • Here's an example of how it can materialize to funds being lost: https://github.com/code-423n4/2023-06-lybra-findings/issues/215

Impact

  • Contract fails to deliver promised returns but doesn't lose value.

Risk Breakdown

Recommendation

References

Proof of concept

  • Initiate a new foundry repo by running forge init. see here.
  • Add the below code in test/PermissiveFallback.t.sol and run it using forge test --fork-url MAINNET_RPC_URL
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test} from "forge-std/Test.sol";

contract PermissiveFallback is Test {
    address multisig = 0x2028834B2c0A36A918c10937EeA71BE4f932da52;

    function setUp() public {}

    //This function checks that for any function signature and data, the call would succeed because of the permissive fallback function
    function test_FallbackIsPermissive(bytes memory functionSignatureAndData) public {
        (bool success,) = multisig.call(functionSignatureAndData);
        assertTrue(success);
    }
}

The original report as published on Immunefi, by kankodu. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the contract defines a fallback function that does not revert on unknown calls, so every unrecognised call returns success.

Impact

The contract fails to deliver promised returns but does not lose value directly; however, the report notes it could materialise as funds being lost in integrations that rely on a revert.

What the attacker needed

A third-party contract calls an unknown function

The fix

The fallback should be intentional, for example using a changeable fallback handler managed by a fallback manager as in Safe contracts.

How it was found

  1. Create a new Foundry project.
  2. Add a test contract that calls the multi-signature wallet with arbitrary function data.
  3. Run the test against a mainnet fork and observe that the call succeeds.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A fallback function is code that runs when a contract receives a call it does not recognise. Here it always succeeds instead of rejecting the call, so other contracts that check for a rejection are fooled into thinking the wallet agreed to something.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by kankodu

View all

5 more disclosed reports, best first.

More from DeGate

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.