Skip to content
Access control Audit finding Intermediate

Pool functions can be called before initialization in `init ()` of Pools.sol

The smart contract's external functions can be called before the contract is initialised, potentially causing exceptions, state corruption, or incorrect accounting in other contracts. An attacker could front-run the initialisation to call functions prematurely.

Vader Protocol contest

Originally disclosed on Code4rena

All the external/public functions of Pools.sol can be called by other contracts even before Pools.solcontract is initialized. This can lead to exceptions, state corruption or incorrect accounting in other contracts, which may require redeployment of said contract.

Recommend using a factory pattern that will deploy and initialize atomically to prevent front-running of the initialization,

OR

Given that contracts are not using delegatecall proxy pattern, it is not required to use a separate init() function to initialize parameters when the same can be done in a constructor. If the reason for doing so is to get the deployment addresses of the various contracts, which may not all be available at the same time, then consider rearchitecting to create a “globals” contract which can hold all the globally required addresses of various contracts. see Maple protocol’s for example.

OR

Prevent external/public functions from being called until after initialization is done by checking initialization state tracked by the inited variable.

strictly-scarce (vader) dipsuted:

https://github.com/code-423n4/2021-04-vader-findings/issues/39

dmvt (judge) commented:

Same general comments apply to this issue as with issue #18, but it is a separate type of exploit that would be slightly less detectable. This increase in risk is balanced against the exploit being much harder to effect and the likely impact being lower.

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

Likely the contract uses a separate initialisation function instead of a constructor, and external functions lack a check that initialisation has completed.

Impact

This could lead to exceptions, state corruption, or incorrect accounting in other contracts, potentially requiring redeployment, though the judge notes the exploit is hard to effect and impact likely lower.

What the attacker needed

Contract not yet initialized; attacker can call functions before init

The fix

The report recommends using a factory pattern for atomic deployment and initialisation, or replacing the init function with a constructor, or adding an initialisation check to external functions.

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 on a blockchain can have functions that anyone can call. If the contract isn't set up yet, calling those functions early can mess up its internal state or cause errors. This report says that's possible here and suggests ways to prevent it.

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 Vader Protocol contest

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.