Skip to content
Access control Audit finding Intermediate

In Cnote.sol , anyone can initially become both accountant and admin

The function _setAccountantContract() lacks access control, allowing an attacker to frontrun the initialisation transaction and become both accountant and admin. This could let them control these roles, potentially requiring a contract redeploy.

p4st13r4 Follow

Originally disclosed on Code4rena

Submitted by p4st13r4, also found by 0x52 and Tutturu

Affected code:

The function _setAccountantContract() is supposed to be called after contract initialization, so that the accountant is immediately set. However, this function completely lacks any access control (it’s just public) so an attacker can monitor the mempool and frontrun the transaction in order to become both accountant and admin

Tools Used

Editor

Recommended Mitigation Steps

The function should:

  1. have a guard that regulates access control
  2. not set the admin too, which is dangerous and out of scope

tkkwon1998 (Canto) confirmed

Alex the Entreprenerd (judge) commented:

Frontrunnable Initializer without POC (is impact having to re-deploy?).

Pretty confident will downgrade.

Alex the Entreprenerd (judge) decreased severity to Medium and commented:

The warden has shown how, due to front-running, anyone can become the accountant. With the information I have, I think the worst case scenario is a re-deploy.

Because the setter could have been written in a better way, but because the realistic consequence is a re-deploy, I think Medium Severity to be more appropriate.


The original report as published on Code4rena, by p4st13r4. 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 initialisation function _setAccountantContract() is public and lacks any access control, allowing anyone to call it before the legitimate setup.

Impact

An attacker could become both accountant and admin, potentially requiring a contract redeploy; the judge noted the worst case is a re-deploy.

What the attacker needed

Attacker can monitor mempool; attacker can frontrun transaction

The fix

The function should have an access control guard and should not set the admin role.

How it was found

  1. Monitor the mempool for the transaction calling _setAccountantContract().
  2. Frontrun that transaction with a call to _setAccountantContract() to become accountant and admin.

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 setup function that should only be called once by the deployer. Because anyone can call it, an attacker can watch pending transactions and pay a higher fee to get their call processed first, taking over important roles.

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 p4st13r4

View all

4 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.

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.