Closed c4-submissions closed 1 year ago
raymondfam marked the issue as sufficient quality report
raymondfam marked the issue as primary issue
Invalid
while any malicious actor can come and deploy subaccount with same parameters (same operators and threshold), the subaccount will be mapped to the actor and nobody else in the Walletregistry.
In this POC the subaccount deployed is still owned by and mapped to malicious actor in walletregistry and not to originalConsoleAccount
0xad1onchain (sponsor) disputed
As the Sponsor has correctly specified, the Warden's PoC as well as understanding of the SafeDeployer::deploySubAccount
is incorrect. The SafeDeployer::deploySubAccount
function will create an initialization payload for the Gnosis Safe based on the SafeDeployer::_setupSubAccount
result which will utilize the msg.sender
.
The attack is thus unable to deploy a sub-account on a known location as the sub-account's address derivation mechanism utilizes the deployer of the sub-account as a variable that influences it, specifically as part of the _initializer
.
alex-ppg marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2023-10-brahma/blob/main/contracts/src/core/SafeDeployer.sol#L82-L103 https://github.com/code-423n4/2023-10-brahma/blob/main/contracts/lib/safe-contracts/contracts/base/ModuleManager.sol#L32-L40
Vulnerability details
Impact
Lost user funds IF a
Console
starts using the backdooredSubAccount
Description
It's possible to deploy a "fake"
SubAccount
that mimics a "real"SubAccount
that is connected to a "real"Console
: has the sameowners
, samethreshold
, samepolicyCommitment
and most importantly the sameConsole
as a module is allowed to operate on it. The trick of the attacker lies in enabling his own address as well as amodule
to operate on theSubAccount
.Since the similarities the "real"
Console
operators might start to use the "fake"SubAccount
and transfer funds to it. When this happens the attacker can drain theSubAccount
's funds completely (and could take control of the wholeSafe
).If a
Console
is already deployed on a chain and plans to deploy to different chains, the attacker can immediately mimic aSubAccount
on the original chain to deploy a fake one in the new chain tied to theConsole
. Later when the operators start to useConsole
on the new chain, they may think that theirSubAccount
was already deployed on this chain because of the similarities.Proof of Concept
test/branch-trees/SafeDeployer/deploy-console-account/DeploySubAccount.t.sol
executeSafeTxHelper()
anddeployBackdoorSubAccountHelper()
helper functions) inSafeDeployer_DeploySubAccountTest
contractrun
make test_func P=testDeploySubAccount_BaitBackdoor_0xfuje