A safe that has been created using version 1.40=< will not be compatible with Brahma
Safes created with Safe contract version 1.4.0 or later cannot set the Brahma guard contract because the guard does not implement the EIP-165 interface required by Safe's setGuard function. This prevents externally created Safes from fully integrating with Brahma, as the guard is a fundamental part of ConsoleAccount functionality.
bronze_pickaxe Follow with imare
Originally disclosed on Code4rena
Submitted by bronze_pickaxe, also found by imare
Safe’s created outside of the Brahma ecosystem should be able to seamlessly integrate into the Brahma. This Safe should call WalletRegistry.registerWallet to register. After registration, this safe will be a consoleAccount and should be able to use the same functionality that all the other consoleAccounts have.
However, Safe’s that have been created using version 1.4.0=< are not fully compatible with Brahma. This is because, in version 1.4.0, IERC165 support has been added to the GuardManager.sol, this is the code added:
+ if (guard != address(0)) {
+ require(Guard(guard).supportsInterface(type(Guard).interfaceId), "GS300");
+ }
This means that every Safe that has been created using Safe’s contract version 1.40 and up, can only add guards that support the EIP-165 interface, as read from the CHANGELOG.md
Proof of Concept
Consider the following:
- Alice has a safe setup.
- Alice wants to integrate their safe into the Brahma ecosystem.
- Alice calls
WalletRegistry.registerWalletand this call succeeds. - Alice decides they want to implement the guard contract provided by the Brahma ecosystem,
SafeModeratorOverridable.sol - Alice calls
GnosisSafe.setGuard(address(SafeModeratorOverridable)). - This will fail because of this new require statement in Safe contracts
v1.4.0=<:
function setGuard(address guard) external authorized {
if (guard != address(0)) {
require(Guard(guard).supportsInterface(type(Guard).interfaceId), "GS300");
}
Because the SafeModeratorOverridable.sol does not support the EIP-165 interface:
source: contracts/src/core/SafeModeratorOverridable.sol
contract SafeModeratorOverridable is AddressProviderService, IGuard {
This means that every Safe created with version 1.4.0 or up, can not implement the guard contract, which is a fundamental part of the way the ConsoleAccounts function.
Recommended Mitigation Steps
Add support for the EIP-165 interface or update the Safe contracts used in Brahma from 1.3.0 to the most recent version.
Assessed type
Context
0xsomeone (judge) decreased severity to Medium and commented:
This appears to be a contender for “best” as it clearly pinpoints the flaw (i.e. Gnosis Safe instances created externally rather than via the code) as well as versions (i.e.
>=1.4.0) the bug is applicable to.
0xad1onchain (Brahma) confirmed
0xad1onchain (Brahma) commented:
Fixed, added the recommended IERC165 support.
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 Brahma guard contract does not implement the EIP-165 supportsInterface function, which Safe contracts version 1.4.0 and later require before allowing a guard to be set.
What the attacker needed
Safe created with contract version 1.4.0 or later; Safe registered with Brahma
The fix
The Brahma guard contract was updated to support the EIP-165 interface, as confirmed by the Brahma team.
How it was found
- Alice has a Safe set up.
- Alice registers the Safe with Brahma via WalletRegistry.registerWallet.
- Alice tries to set the Brahma guard contract on the Safe.
- The setGuard call fails because the guard does not support EIP-165.
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 Safe is a smart contract wallet. Brahma is a system that adds extra security rules to a Safe by installing a 'guard' contract. Newer versions of Safe require guards to announce which interfaces they support, a standard called EIP-165. Brahma's guard does not make that announcement, so newer Safes reject it.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.