Skip to content
Business logic Audit finding Intermediate

First block proposer check in the LibProposing._isProposerPermitted function is errorneous

The first block proposer check in LibProposing._isProposerPermitted is flawed: when the caller is proposer_one, the function can still return false if a separate proposer address is set and differs from the caller. This prevents the first block after genesis from being proposed, blocking subsequent block proposals.

Shield Follow with monrel and blockdev

Originally disclosed on Code4rena

Submitted by Shield, also found by monrel and blockdev

https://github.com/code-423n4/2024-03-taiko/blob/main/packages/protocol/contracts/L1/libs/LibProposing.sol#L93-L94

https://github.com/code-423n4/2024-03-taiko/blob/main/packages/protocol/contracts/L1/libs/LibProposing.sol#L299-L317

The LibProposing.proposeBlock function calls the _isProposerPermitted private function, to ensure if the proposer is set. Only that specific address has the permission to propose the block.

In the _isProposerPermitted function, for the first block after the genesis block only the proposerOne is allowed to propose the first block as shown below:

            address proposerOne = _resolver.resolve("proposer_one", true);
            if (proposerOne != address(0) && msg.sender != proposerOne) {
                return false;
            }

But the issue here is that when the msg.sender == proposerOne the function does not return true if the following conditions occur.

If the proposer != address(0) && msg.sender != proposer. In which case even though the msg.sender == proposerOne is true for the first block the _isProposerPermitted will still return false thus reverting the block proposer for the first block.

Hence even though the proposer_one is the proposer of the first block the transaction will still revert if the above mentioned conditions occur and the _isProposerPermitted returns false for the first block after the genesis block.

Hence this will break the block proposing logic since the proposal of the first block after the genesis block reverts thus not allowing subsequent blocks to be proposed.

Proof of Concept

        TaikoData.SlotB memory b = _state.slotB;
        if (!_isProposerPermitted(b, _resolver)) revert L1_UNAUTHORIZED();

https://github.com/code-423n4/2024-03-taiko/blob/main/packages/protocol/contracts/L1/libs/LibProposing.sol#L93-L94

    function _isProposerPermitted(
        TaikoData.SlotB memory _slotB,
        IAddressResolver _resolver
    )
        private
        view
        returns (bool)
    {
        if (_slotB.numBlocks == 1) {
            // Only proposer_one can propose the first block after genesis
            address proposerOne = _resolver.resolve("proposer_one", true);
            if (proposerOne != address(0) && msg.sender != proposerOne) {
                return false;
            }
        }

        address proposer = _resolver.resolve("proposer", true);
        return proposer == address(0) || msg.sender == proposer;
    }

https://github.com/code-423n4/2024-03-taiko/blob/main/packages/protocol/contracts/L1/libs/LibProposing.sol#L299-L317

Tools Used

VSCode

Recommended Mitigation Steps

It is recommended to add logic in the LibProposing._isProposerPermitted function to return true when the msg.sender == proposerOne, for proposing the first block after genesis block.

dantaik (Taiko) confirmed and commented:

I think this is a valid bug: fixing it here


The original report as published on Code4rena, by Shield. 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 function does not return true early when msg.sender equals proposerOne; it falls through to a second check against the general proposer address, which can still return false.

Impact

The first block after genesis cannot be proposed, which breaks the block proposing logic and prevents subsequent blocks from being proposed.

What the attacker needed

Proposer_one is set; a separate proposer address is set and differs; caller is proposer_one

The fix

The function should return true when msg.sender equals proposerOne, and the project confirmed a fix was made.

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 checks who is allowed to propose the first block after the start. It has two checks: one for a special 'proposer_one' address and one for a general 'proposer' address. The bug is that passing the first check does not stop the second check from failing, so even the correct special address can be rejected.

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 Shield

View all

3 more disclosed reports, best first.

More from Taiko

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.