Skip to content
Access control Audit finding Beginner

BuilderWallet init() is unprotected/re-initializable, enabling takeover and theft of builder fees

The BuilderWallet contract's init() function had no access control or one-time guard, so anyone could overwrite the stored builderAdmin address. An attacker could then call sweep() as the new admin and drain all ERC20 tokens held by any builder wallet.

darf_tech Follow with 0x04, 0xAura and 48 others

Originally disclosed on Code4rena

Submitted by darf_tech, also found by 0x04, 0xAura, 0xMirce, 0xnbvc, 0xzys, agent001, Agontuk, Agrawain, alaskanking, AlexNiht, allan31, AnantaDeva, arturtoros, AuditorPraise, axelot, BlueSheep, cheng9061, ciphermalware, critfinds, Diavolo, dtang, edoscoba, ElmInNyc99, eternal1328, forlz, Funen, Gakarot, gegul, gwumex, happykilling, ht111111, humanitia, I1iveF0rTh1Sh1t, Icarus, Ituba, jerry0422, johnyfwesh, joicygiore, K42, Kaysoft, kimnoic, lamassu, lazlosoot, legat, LimeiBBQ, LoopGhost007, lufP, Manvita, mehdi81, Merkleboy, merlin_san, mibunna, mohamedfahmy, niffylord, one, piki, qed, Race, Rifter, rox_k, s4id, SarveshLimaye, Spektor, tkmk, Trynax, Tupaia, Valves, Vemus, VulSight, Web3Angel, wilson9x1, wuji, Xylem, zcai, and zzebra83

In BuilderWallet, the admin is stored in builderAdmin but init() has no access control and no “only-once” guard:

  • BuilderWallet definition: RiskEngine.sol #L2307
  • init() (unrestricted, overwrites builderAdmin): RiskEngine.sol L2315
  • sweep() (only gated by builderAdmin): RiskEngine.sol L2319

Builder wallets are deployed by BuilderFactory.deployBuilder(...), which calls BuilderWallet(wallet).init(builderAdmin) after CREATE2 deployment: RiskEngine.sol L2371

Because init() remains callable after deployment, any attacker can overwrite builderAdmin and then legitimately pass the sweep() authorization check.

Exploit Steps

  1. Builder wallet is deployed via deployBuilder(...): RiskEngine.sol L2371
  2. Builder wallet accumulates ERC20 balances (fees/tokens).
  3. Attacker calls BuilderWallet.init(attacker) to overwrite builderAdmin: RiskEngine.solL2315
  4. Attacker calls BuilderWallet.sweep(token, attacker) to drain balances: RiskEngine.sol L2319

Impact

Direct theft of all ERC20 balances held by any builder wallet (including protocol-distributed fees/shares).

Proof of Concept (minimal, runnable Foundry test)

View detailed Proof of Concept

Panoptic mitigated:

Protect builderWallet.init.

Status: Mitigation confirmed. Full details in reports from Valves, edoscoba, and Nyx.


The original report as published on Code4rena, by darf_tech. 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 init() function lacked an access-control check and a guard preventing it from being called more than once, so it could be re-invoked to overwrite the admin address.

Impact

An attacker could steal all ERC20 balances held by any builder wallet, including protocol-distributed fees and shares.

What the attacker needed

A deployed builder wallet holding tokens; no special access needed

The fix

The project mitigated the issue by protecting builderWallet.init, and the mitigation was confirmed.

How it was found

  1. A builder wallet is deployed through deployBuilder, which calls init with the intended admin.
  2. The wallet accumulates ERC20 token balances such as fees.
  3. The attacker calls init with their own address, overwriting builderAdmin.
  4. The attacker calls sweep to transfer the tokens to themselves.

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 is a program on a blockchain that holds funds. This wallet contract had a setup function that was supposed to run once, but it could be called again by anyone. That let an attacker make themselves the wallet's admin and then use the admin-only withdrawal function to take the tokens.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More from Panoptic: Next Core

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.