Contract deployment restriction can be bypassed
The contract deployment restriction in Initia's EVM module only checks the sender of Create and Create2 messages, not the EVM create opcodes. A permissioned deployer could deploy a factory contract that lets anyone deploy arbitrary contracts, bypassing the restriction.
berndartmueller Follow with givn
Originally disclosed on Code4rena
Submitted by berndartmueller, also found by givn
Finding description and impact
The Create and Create2 message handlers check the sender is allowed to deploy a contract by calling assertAllowedPublishers(..) here and here.
The deployers can either be restricted to specific addresses (params.AllowedPublishers) or completely unrestricted so that anyone can deploy a contract.
However, if the deployers are restricted, a permissioned deployer can deploy a factory contract that can then be used by anyone to deploy arbitrary contracts, bypassing the restriction and potentially leading to malicious contracts being deployed.
This is contrary to Evmos which does check also the EVM create opcode if the address is allowed to deploy a contract. It adds a special “create” hook, which checks if the caller is permissioned to deploy a contract.
This hook is called by EVM::Create and EVM::Create2, which are called when the EVM encounters the CREATE and CREATE2 opcodes.
This shows that contract deployment can be fully restricted if desired.
Proof of Concept
EVMCreateWithTracer() internally calls the EVM’s Create or Create2 functions, which contain the standard implementation without any deployment restriction, found here.
Recommended mitigation steps
Consider using a similar approach to Evmos whereby the Create and Create2 are intercepted and the caller is checked for permission to deploy a contract.
leojin (Initia) disputed and commented via duplicate issue S-161:
Since the allowed publisher list is typically set at chain launch, this does not seem to be an issue that requires fixing. It also appears fine since the update parameters are controlled by an operator.
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 deployment permission check is only applied to the message handlers, not to the EVM CREATE and CREATE2 opcodes, so a permissioned contract can deploy other contracts on behalf of anyone.
Impact
If deployers are restricted, a permissioned deployer could enable anyone to deploy arbitrary contracts, potentially leading to malicious contracts being deployed.
What the attacker needed
Deployer restriction is enabled; attacker is a permissioned deployer
The fix
The Create and Create2 opcodes should be intercepted and the caller checked for permission to deploy a contract, as Evmos does.
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.
Some blockchains let only approved addresses deploy smart contracts. This report found that an approved address could deploy a 'factory' contract that then lets anyone else deploy contracts through it, so the restriction is not complete.
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.