Skip to content
Access control Audit finding Intermediate

Missing zero address check can cause initialize to be called more than once

The initialize function in AccountantDelegate.sol only checks that state variables are not zero, so if it is first called with zero addresses, it can be called again. An attacker with admin privileges could reinitialize the contract and change critical variables, potentially breaking all accounting.

oyc_109 Follow

Originally disclosed on Code4rena

Submitted by oyc_109

There is potential to call initialize() on AccountantDelegate.sol more than once because the require statement only checks if the state variables != address(0)

https://github.com/Plex-Engineer/lending-market-v2/blob/443a8c0fed3c5018e95f3881a31b81a555c42b2d/contracts/Accountant/AccountantDelegate.sol#L23-L25

If initialize() was called the first with these parameters as address(0x0), then initialize can be called again

https://github.com/Plex-Engineer/lending-market-v2/blob/443a8c0fed3c5018e95f3881a31b81a555c42b2d/contracts/Accountant/AccountantDelegate.sol#L17

Recommended Mitigation Steps

The require statement should also check if the parameters != zero address, similar to the check performed in TreasuryDelegate.sol

https://github.com/Plex-Engineer/lending-market-v2/blob/443a8c0fed3c5018e95f3881a31b81a555c42b2d/contracts/Treasury/TreasuryDelegate.sol#L23

Or use openzepplen initializable.

nivasan1 (Canto) acknowledged and commented:

This will be a function called by admin (Governance), as such, it is the community’s responsibility to review the parameters of the inititalize method.

Alex the Entreprenerd (judge) commented:

In contract to CantoV1, in this version of the code the initializer can be called multiple times.

This is contingent on the admin calling it, however the impact of changing any variable will most likely be complete breaking of all accounting (an exception may be a complete fresh start).

Given in the code in scope, and the conditionality (admin privilege), I believe Medium Severity to be appropriate.


The original report as published on Code4rena, by oyc_109. 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's guard only checks that state variables are not the zero address, allowing re-initialization if they were initially set to zero.

Impact

If the admin calls initialize again, changing any variable will most likely completely break all accounting, though this requires admin privileges.

What the attacker needed

Admin privileges (governance)

The fix

The require statement should also check that the parameters are not zero addresses, or use OpenZeppelin's initializable.

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.

Smart contracts often have an initialize function that sets up important settings once. This contract's check was flawed: it only verified that the settings were not zero, so if they were set to zero initially, the function could be run again. That means someone with special access could reset the contract's settings later, which could disrupt how it tracks balances.

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 oyc_109

View all

3 more disclosed reports, best first.

More from Canto v2 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.