Skip to content
Access control Audit finding Intermediate

Multiple initialization of Collateral contract

The Collateral contract's initialize function lacks an initializer modifier, allowing it to be called multiple times. An attacker could front-run the deployment, initialize with a zero factory address, perform malicious actions, and still let the project re-initialize without error.

0x1f8b Follow

Originally disclosed on Code4rena

Submitted by 0x1f8b

Impact

The attacker can initialize the contract, take malicious actions, and allow it to be re-initialized by the project without any error being noticed.

Proof of Concept

The initialize method of theCollateral contract does not contain the initializer modifier, it delegates this process to check if the factory is different from address(0) in theUFactoryProvider__initialize call, however the factory_is other than address(0), so an attacker could use front-running by listening to the memory pool, initialize the contract with a factory=address(0), perform malicious actions, and still allow it to be started later by the I draft the contract without noticing any error.

Source reference:

  • Collateral.initialize

Tools Used

Manual review

Recommended Mitigation Steps

Use initializer modifier

kbrizzle (Perennial) marked as duplicate:

Duplicate of: https://github.com/code-423n4/2021-12-perennial-findings/issues/71

Alex the Entreprenerd (judge) commented:

Disagree with sponsor that this is duplicate of #73

Alex the Entreprenerd (judge) commented:

The finding mentions that initialize can be called multiple times, specifically by first having factory set to address(0) and then setting it to it’s final value.

This is true.

Calling initialize multiple times could allow to set certain values up with a different token, then change to another token and set the factory. This could be used to trick the protocol accounting to later take advantage of other depositors.

Alex the Entreprenerd (judge) commented:

The specific vulnerability is the lack of the initializer modifier on initialize, the consequences can be problematic only if a malicious actor were to set the contracts up.

Because this can be done, and it’s reliant on a specific setup, I’ll mark the finding as medium severity, mitigation is straightforward

kbrizzle (Perennial) commented:

My understanding of these is that:

The original report as published on Code4rena, by 0x1f8b. 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 initialize function lacks the initializer modifier, so it can be invoked repeatedly; the only check is that the factory address is not zero, which an attacker can bypass by first setting it to zero.

Impact

An attacker could initialize the contract with malicious values, perform actions, and still allow the project to re-initialize without noticing, potentially tricking protocol accounting to take advantage of other depositors.

What the attacker needed

Attacker can front-run deployment; contract not yet initialized

The fix

The initialize function should be protected with the initializer modifier to prevent multiple calls.

How it was found

  1. Attacker listens to the memory pool for the contract deployment.
  2. Attacker front-runs and calls initialize with factory set to address(0).
  3. Attacker performs malicious actions.
  4. Project later calls initialize with the real factory address, which succeeds without error.

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.

When a smart contract is deployed, it often has an initialization function that sets important values like who controls it. If that function can be called more than once, an attacker might call it first with their own values, then the real owner calls it again and thinks everything is fine. This report shows such a missing guard on one contract.

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 by 0x1f8b

View all

21 more disclosed reports, best first.

More from Perennial 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.