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 :
mainWalletmake a request toproposeWalletsto change the main and confirmation wallets which setsproposedMainWallet != address(0).confirmationWalletdoesn’t like the change so he callsreceivefunction with insufficient amount of ETH to refuse the change. Afterreceivecall,activeTimelockis set touint256.maxbutproposedMainWalletis still different fromaddress(0).mainWallettries to callproposeWalletsagain by it will always revert becauseproposedMainWallet != 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].
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
- The main wallet calls proposeWallets to set new main and confirmation wallets, making proposedMainWallet non-zero.
- 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.
- The main wallet calls proposeWallets again, but it reverts because proposedMainWallet is not address(0).
- 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.