Skip to content
Business logic Audit finding Beginner

Impossible to change managed wallets with proposeWallets after first rejection

The receive function in ManagedWallet did not reset the proposedMainWallet address when the confirmation wallet rejected a wallet change. After the first rejection, proposeWallets would always revert, making it impossible to ever change the main and confirmation wallets again.

Aymen0909 Follow with J4X, jasonxiale and 19 others

Originally disclosed on Code4rena

Submitted by Aymen0909, also found by juancito (1, 2), J4X, jasonxiale, niroh, neocrao, pina, erosjohn, 0xpiken, lilizhu, oakcobalt, n0kto, ZanyBonzy, pkqs90, Drynooo, zxriptor, Ephraim, LeoGold, 0xRobocop, 0xOmer, klau5, jesjupyter, and Beepidibop

https://github.com/code-423n4/2024-01-salty/blob/main/src/ManagedWallet.sol#L67-L69

https://github.com/code-423n4/2024-01-salty/blob/main/src/ManagedWallet.sol#L48-L49

The receive function in ManagedWallet fails to reset the proposedMainWallet address to the zero address (address(0)) when the confirmation wallet rejects the wallet change:

receive() external payable {
    require(msg.sender == confirmationWallet, "Invalid sender");

    // Confirm if .05 or more ether is sent and otherwise reject.
    // Done this way in case custodial wallets are used as the confirmationWallet - which sometimes won't allow for smart contract calls.
    if (msg.value >= .05 ether)
        activeTimelock = block.timestamp + TIMELOCK_DURATION; // establish the timelock
    else activeTimelock = type(uint256).max; // effectively never
    //@audit doesn't reset proposedMainWallet to address(0)
}

This omission renders it impossible to submit new proposals for changing wallets in the future. After the confirmation wallet rejects for the first time, the proposedMainWallet remains different from address(0), causing the proposeWallets function to revert due to the check on the proposedMainWallet address:

function proposeWallets(
    address _proposedMainWallet,
    address _proposedConfirmationWallet
) external {
    ...

    //@audit revert if proposedMainWallet != address(0)
    // Make sure we're not overwriting a previous proposal (as only the confirmationWallet can reject proposals)
    require(
        proposedMainWallet == address(0),
        "Cannot overwrite non-zero proposed mainWallet."
    );

    proposedMainWallet = _proposedMainWallet;
    proposedConfirmationWallet = _proposedConfirmationWallet;

    emit WalletProposal(proposedMainWallet, proposedConfirmationWallet);
}

Impact

After the first rejection of wallet changes, the proposeWallets function will consistently revert, making it impossible to change the main and confirmation wallets indefinitely.

Proof of Concept

The scenario for this issue to occurs is straightforward :

  • mainWallet make a request to proposeWallets to change the main and confirmation wallets which sets proposedMainWallet != address(0).
  • confirmationWallet doesn’t like the change so he calls receive function with insufficient amount of ETH to refuse the change. After receive call, activeTimelock is set to uint256.max but proposedMainWallet is still different from address(0).
  • mainWallet tries to call proposeWallets again by it will always revert because proposedMainWallet != address(0).
  • Both main and confirmation wallets can never be changed again.

Tools Used

VS Code

Recommended Mitigation

In the receive function, reset the proposedMainWallet variable to address(0) after the confirmation process has been rejected (similar to the reset done in changeWallets()).

if (msg.value >= .05 ether)
    activeTimelock = block.timestamp + TIMELOCK_DURATION; // establish the timelock
else {
    //@audit Reset
    activeTimelock = type(uint256).max;
    proposedMainWallet = address(0);
    proposedConfirmationWallet = address(0);
}

othernet-global (Salty.IO) confirmed and commented:

ManagedWallet has been removed.

https://github.com/othernet-global/salty-io/commit/5766592880737a5e682bb694a3a79e12926d48a5

Picodes (Judge) decreased severity to Medium

Status: Mitigation confirmed. Full details in reports from t0x1c, 0xpiken, and [zzebra83].


The original report as published on Code4rena, by Aymen0909. 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 receive function set the timelock to its maximum value on rejection but did not reset proposedMainWallet and proposedConfirmationWallet to the zero address, so the guard in proposeWallets permanently blocked new proposals.

Impact

After the first rejection, the main and confirmation wallets could never be changed again, permanently locking the contract's wallet configuration.

What the attacker needed

Main wallet proposes new wallets; confirmation wallet rejects with <0.05 ether

The fix

The receive function should reset proposedMainWallet and proposedConfirmationWallet to address(0) when a proposal is rejected; the project ultimately removed ManagedWallet entirely.

How it was found

  1. The main wallet calls proposeWallets to set new main and confirmation wallets, making proposedMainWallet non-zero.
  2. The confirmation wallet rejects the change by calling receive with less than 0.05 ether, which sets activeTimelock to uint256.max but leaves proposedMainWallet non-zero.
  3. The main wallet calls proposeWallets again, but it reverts because proposedMainWallet is not address(0).
  4. Both wallets can never be changed again.

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 smart contract holds two special wallet addresses: a main wallet and a confirmation wallet. To change them, the main wallet proposes new addresses, and the confirmation wallet must approve by sending enough ether. If the confirmation wallet rejects by sending too little ether, the proposal should be cleared so a new one can be made. Here, the rejection left the old proposal in place, so every future attempt to propose new wallets was blocked.

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 Aymen0909

View all

22 more disclosed reports, best first.

More from Salty.IO

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.