Skip to content
Access control Audit finding Intermediate

fallback() function can bypass permission/auth checks imposed in execute()

The vault's fallback function allows calls to installed plugins without checking caller permissions, unlike the execute function. An attacker who is a previous owner or installs a malicious plugin can use this to transfer NFTs out of the vault without the current owner's consent.

bbrho Follow

Originally disclosed on Code4rena

Submitted by bbrho, also found by 0xNazgul, codexploder, infosec_us_team, s3cunda, Saintcode_, and zzzitron

Vault owners can install plugins via Vault.install(), with calls to the installed plugins made through the vault’s fallback function. Unlike the vault’s external Vault.execute() function, fallback() imposes no checks on the permissions of the caller, assuming proper installation of the plugin by the owner at install time.

While this design seems intentional given NFTReceiver.sol, it can lead to unintended vulnerabilities, like loss of vault NFTs, if the vault owner:

  • Mistakenly installs a plugin not intended for unpermissioned use or installs a malicious plugin
  • Is transferred vault ownership from a prior owner who misconfigured vault plugin installations

Proof of Concept

Example successful test similar to those from Vault.t.sol below.

The original vault owner installs a transfer target plugin, with selector ERC721TransferFrom on the vault. Ownership is then transferred to Bob, but the original owner uses the installed transfer plugin to steal the NFT deposited in the vault and send it to Alice (without Bob’s permission):

function testFallbackWithTransferPlugin() public {
    bytes memory data = setUpExecute(alice);

    // install transfer from on vault
    address[] memory plugins = new address[](1);
    bytes4[] memory selectors = new bytes4[](1);

    plugins[0] = address(transferTarget);
    selectors[0] = transferTarget.ERC721TransferFrom.selector;
    vaultProxy.install(selectors, plugins);

    // set bob as the owner
    vaultProxy.transferOwnership(bob.addr);

    // check vault originally has the nft
    assertEq(IERC721(erc721).balanceOf(vault), 1);
    assertEq(IERC721(erc721).balanceOf(alice.addr), 0);

    // execute the nft transfer via plugin with fallback
    (bool success,) = address(vaultProxy).call(data);

    // check this contract transferred nft out of vault to alice
    // even after bob became owner
    assertEq(IERC721(erc721).balanceOf(vault), 0);
    assertEq(IERC721(erc721).balanceOf(alice.addr), 1);
}

Recommended Mitigation Steps

Consider tracking which installed plugins might require permissions alongside the methods mapping in storage. Potentially:

/// @notice Mapping of function selector to plugin address
mapping(bytes4 => address) public methods;

/// @notice Mapping of plugin address to whether permissions required
mapping(address => bool) public auths;

with auths[plugin] used in fallback().

stevennevins (Fractional) confirmed

HardlyDifficult (judge) decreased severity to Medium and commented:

A malicious owner is given a lot of flexibility which can be abused to steal funds. I believe this is a Medium risk issue and not a High as it was reported as by many of the dupe submissions because the issues all originate from either a malicious owner or a faulty plugin.

See also https://github.com/code-423n4/2022-07-fractional-findings/issues/266#issuecomment-1189217586

I’m selecting this submission as the primary for including a coded POC, helping to understand one potential path of abuse this could lead to.


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

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

The fallback function does not verify caller permissions for plugin functions, relying only on the assumption that the owner installed safe plugins.

Impact

A previous owner or a malicious plugin installer could steal NFTs from the vault, but the judge noted this requires a malicious owner or faulty plugin and rated it Medium severity.

What the attacker needed

Vault owner installs a plugin; ownership transferred to another party; attacker is previous owner or malicious plugin installer

The fix

The fallback function should check a mapping that tracks whether each installed plugin requires permissions before allowing calls.

How it was found

  1. The original vault owner installs a transfer plugin with selector ERC721TransferFrom on the vault.
  2. Ownership of the vault is transferred to Bob.
  3. The original owner calls the vault's fallback function with data that triggers the transfer plugin.
  4. The plugin transfers the NFT from the vault to Alice without Bob's permission.

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 vault is a smart contract that holds digital assets like NFTs. The vault owner can add plugins that let people call certain functions. The fallback function lets anyone call those plugin functions without checking if they are allowed, so a former owner could use a plugin to steal NFTs from the vault even after ownership changed.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More from Fractional v2 contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.