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.
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:
- have a guard that regulates access control
- not set the
admintoo, which is dangerous and out of scope
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.
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
- Monitor the mempool for the transaction calling _setAccountantContract().
- 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.