Skip to content
Smart contracts Audit finding Intermediate

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.registerWallet and 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.


The original report as published on Code4rena, by bronze_pickaxe. 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 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

  1. Alice has a Safe set up.
  2. Alice registers the Safe with Brahma via WalletRegistry.registerWallet.
  3. Alice tries to set the Brahma guard contract on the Safe.
  4. 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.

More by bronze_pickaxe

View all

2 more disclosed reports, best first.

More from Brahma

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.