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

8 stars 7 forks source link

ownerSafeCount gets updated while not deploying safe, leading to unexpected behavior #396

Closed c4-submissions closed 1 year ago

c4-submissions commented 1 year ago

Lines of code

https://github.com/code-423n4/2023-10-brahma/blob/main/contracts/src/core/SafeDeployer.sol#L253-L255

Vulnerability details

Impact

In SafeDepoyer, a consoleAccount and a subAccount can be created using either deployConsoleAccount or deploySubAccount. Both these functions will make an internal call to _createSafe. In _createSafe there is a do-while loop that tries to deploy a gnosis proxy using these parameters gnosisSafeSingleton, _initializer, nonce.

If this deployment fails with the _SAFE_CREATION_FAILURE_REASON error message, the deployment will be tried again by generating a new nonce:

function _createSafe(..){
//.. ommitted code
nonce = _genNonce(ownersHash, _salt);
} catch {
//.. ommitted code
}

Here lays the problem.

Proof of Concept

Consider the following:

Assessed type

Other

c4-pre-sort commented 1 year ago

raymondfam marked the issue as low quality report

c4-pre-sort commented 1 year ago

raymondfam marked the issue as duplicate of #129

c4-judge commented 1 year ago

alex-ppg marked the issue as not a duplicate

alex-ppg commented 1 year ago

The Warden appears to not understand what the loop within the SafeDeployer::_createSafe function is meant for.

Essentially, the loop will attempt to deploy a multi-signature wallet and will retry if a wallet has already been deployed at the relevant address. As such, the nonce will increase only when a multi-signature wallet has actually been deployed at the relevant address.

c4-judge commented 1 year ago

alex-ppg marked the issue as unsatisfactory: Invalid

alex-ppg commented 1 year ago

A slight misbehaviour that may arise in the current code is that the nonce of an owner-set hash is not tied to the salt being utilized.

As such, it is possible for the nonce to not represent the actual number of wallets deployed for a particular hash. It will, however, represent at least the minimum number of wallets deployed for an owner-set.

The Sponsor is advised to evaluate whether they wish to attach owner-sets with the salt_ being used to avoid potential griefing attacks in cross-chain deployments.

The Warden remains ineligible for a reward given that the above misbehaviour is not actually identified in their submission.