Skip to content
Business logic Audit finding Intermediate

Accountant can’t be initialized

The Accountant contract's initialize function always fails because it compares the contract's token balance to the initial supply, which is always zero. This prevents a key part of the protocol from being initialized and used.

Ruhum Follow

Originally disclosed on Code4rena

Submitted by Ruhum, also found by cccz

It’s not possible to initialize the accountant because of a mistake in the function’s require statement.

I rate it as MED since a key part of the protocol wouldn’t be available until the contract is modified and redeployed.

Proof of Concept

The issue is the following require() statement: https://github.com/Plex-Engineer/lending-market/blob/main/contracts/Accountant/AccountantDelegate.sol#L29

There, the function checks whether the accountant has received the correct amount of tokens. But, it compares the accountant’s balance with the _initialSupply. That value is always 0. So the require statement will always fail

When the Note contract is initialized, _initialSupply is set to 0:

After _mint_to_Accountant() mints type(uint).max tokens to the accountant: https://github.com/Plex-Engineer/lending-market/blob/main/contracts/Note.sol#L18 That increases the totalSupply but not the _initialSupply: https://github.com/Plex-Engineer/lending-market/blob/main/contracts/ERC20.sol#L242

The _initialSupply value is only modified by the ERC20 contract’s constructor.

Recommended Mitigation Steps

Change the require statement to

require(note.balanceOf(msg.sender) == note.totalSupply(), "AccountantDelegate::initiatlize: Accountant has not received payment");

nivasan1 (Canto) confirmed

Alex the Entreprenerd (judge) increased severity to High and commented:

The warden has shown how, due to an incorrect assumption, AccountantDelegate.initialize cannot work, meaning part of the protocol will never work without fixing this issue.

While the change should be fairly trivial, the impact is pretty high, for those reasons am going to raise severity to High.


The original report as published on Code4rena, by Ruhum. 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 require statement incorrectly compares the contract's token balance to the initial supply variable, which is always zero, instead of comparing it to the total supply.

Impact

A key part of the protocol cannot be initialized, so it will not work until the contract is modified and redeployed.

What the attacker needed

None

The fix

The require statement should compare the contract's balance to the total supply instead of the initial supply.

How it was found

  1. Deploy the Note contract with initial supply set to zero.
  2. Mint the maximum number of tokens to the Accountant contract.
  3. Call the Accountant's initialize function, which checks the balance against the initial supply.
  4. The check fails because the initial supply remains zero, so initialization cannot complete.

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 has a function that checks if it received the right amount of tokens before starting up. The check compares the contract's current token balance to a stored starting value, but that stored value is always zero, so the check always fails. This means the contract can never be started, blocking part of the system.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Ruhum

View all

55 more disclosed reports, best first.

More from Canto

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.