Skip to content
Business logic Audit finding Advanced

Stale inflationMultiplier in L1ECOBridge

The L1ECOBridge contract stores an inflationMultiplier that is only updated when a separate rebase function is called; if rebase is delayed, the stored multiplier becomes stale relative to the L1 ECO token's actual inflation multiplier. An attacker can deposit tokens while the stale multiplier is larger than the current one, causing the bridge to record an inflated gons amount and receive more tokens on L2 than deserved.

0xRobocop Follow with Dug, GimelSec and 4 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-05-ecoprotocol-judging/issues/126

Found by

0xRobocop, Dug, GimelSec, J4de, n33k, nobody2018, toshii

Summary

L1ECOBridge::inflationMultiplier is updated through L1ECOBridge::rebase on Ethereum, and it is used in _initiateERC20Deposit and finalizeERC20Withdrawal to convert between token amount and _gonsAmount. However, if rebase is not called in a timely manner, the inflationMultiplier value can be stale and inconsistent with the value of L1 ECO token during transfer, leading to incorrect token amounts in deposit and withdraw.

Vulnerability Detail

The inflationMultiplier value is updated in rebase with an independent transaction on L1 as shown below:

Solidity
    function rebase(uint32 _l2Gas) external {
        inflationMultiplier = IECO(l1Eco).getPastLinearInflation(block.number);

However, in both _initiateERC20Deposit, transferFrom is called before the inflationMultiplier is used, which can lead to inconsistent results if rebase is not called on time for the inflationMultiplier to be updated. The code snippet for _initiateERC20Deposit is as follows:

Solidity
        IECO(_l1Token).transferFrom(_from, address(this), _amount);
        _amount = _amount * inflationMultiplier;

finalizeERC20Withdrawal has the same problem.

Solidity
        uint256 _amount = _gonsAmount / inflationMultiplier;
        bytes memory _ecoTransferMessage = abi.encodeWithSelector(IERC20.transfer.selector,_to,_amount);

The same problem does not exist in L2ECOBridge. Because the L2 rebase function updates inflationMultiplier and rebase l2Eco token synchronously.

Solidity
    function rebase(uint256 _inflationMultiplier)
        external
        virtual
        onlyFromCrossDomainAccount(l1TokenBridge)
        validRebaseMultiplier(_inflationMultiplier)
    {
        inflationMultiplier = _inflationMultiplier;
        l2Eco.rebase(_inflationMultiplier);
        emit RebaseInitiated(_inflationMultiplier);
    }

Impact

The attacker can steal tokens with this.

He can deposit to L1 bridge when he observes a stale larger value and he will receive more tokens on L2.

Code Snippet

https://github.com/sherlock-audit/2023-05-ecoprotocol/blob/main/op-eco/contracts/bridge/L1ECOBridge.sol#L244-L251

https://github.com/sherlock-audit/2023-05-ecoprotocol/blob/main/op-eco/contracts/bridge/L1ECOBridge.sol#L333-L335

Tool used

Manual Review

Recommendation

Calling IECO(l1Eco).getPastLinearInflation(block.number) instead of using inflationMultiplier.

Discussion

syjcnss

Escalate for 10 USDC.

This is different from #52 which is about desynced inflationMultiplier between L1&L2 bridges.

#17, #83, #110 and #126 are about desynced inflationMultiplier between the L1ECOBridge and the L1 ECO token.

In L1, the actually transfered gos amount will be different from the gos amount deposited if the inflationMultiplier is stale and not updated by calling rebase. This has nothing to do with the L2 inflationMultiplier.

Solidity
bridge/L1ECOBridge.sol:_initiateERC20Deposit

IECO(_l1Token).transferFrom(_from, address(this), _amount);    // <- transfer underlying gos amount(_amount * 'inflationMultiplier' inside the L1 ECO token) of tokens to deposit
_amount = _amount * inflationMultiplier;  // <- record a wrong gos deposited token amount if inflationMultiplier is stale

In the PoC, @albertnbrown proves that a desynced inflationMultiplier between L1&L2 bridges does not cause a problem. The PoC has a synced value between L1ECOBridge and the L1 ECO token at desposit because the constructor initiated inflationMultiplier with IECO(l1Eco).getPastLinearInflation(block.number). So it doesn't invalidate this issue.

sherlock-admin

Escalate for 10 USDC.

This is different from #52 which is about desynced inflationMultiplier between L1&L2 bridges.

#17, #83, #110 and #126 are about desynced inflationMultiplier between the L1ECOBridge and the L1 ECO token.

In L1, the actually transfered gos amount will be different from the gos amount deposited if the inflationMultiplier is stale and not updated by calling rebase. This has nothing to do with the L2 inflationMultiplier.

Solidity
bridge/L1ECOBridge.sol:_initiateERC20Deposit

IECO(_l1Token).transferFrom(_from, address(this), _amount);    // <- transfer underlying gos amount(_amount * 'inflationMultiplier' inside the L1 ECO token) of tokens to deposit
_amount = _amount * inflationMultiplier;  // <- record a wrong gos deposited token amount if inflationMultiplier is stale

In the PoC, @albertnbrown proves that a desynced inflationMultiplier between L1&L2 bridges does not cause a problem. The PoC has a synced value between L1ECOBridge and the L1 ECO token at desposit because the constructor initiated inflationMultiplier with IECO(l1Eco).getPastLinearInflation(block.number). So it doesn't invalidate this issue.

You've created a valid escalation for 10 USDC!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

albertnbrown

This is a legitimate high issue and we found it and addressed it on our own already, but were having trouble looking through the duplicates for #52 for issues like this to correctly reward them. Thanks for escalating it for visibility.

albertnbrown

We fixed this here https://github.com/eco-association/op-eco/pull/40

ctf-sec

I agree with

This is different from https://github.com/sherlock-audit/2023-05-ecoprotocol-judging/issues/52 which is about desynced inflationMultiplier between L1&L2 bridges.

https://github.com/sherlock-audit/2023-05-ecoprotocol-judging/issues/17, https://github.com/sherlock-audit/2023-05-ecoprotocol-judging/issues/83, https://github.com/sherlock-audit/2023-05-ecoprotocol-judging/issues/110 and https://github.com/sherlock-audit/2023-05-ecoprotocol-judging/issues/126 are about desynced inflationMultiplier between the L1ECOBridge and the L1 ECO token.

while this is the context read me

#17, #83, #110 and #126 and #13

are all duplicate of #126, can mark as high severity

hrishibhat

Escalation accepted

Valid high

sherlock-admin

Escalation accepted

Valid high

This issue's escalations have been accepted!

Contestants' payouts and scores will be updated according to the changes made on this issue.

0xffff11

Approved fix in: https://github.com/eco-association/op-eco/pull/40

0xffff11

Fixed confirmed. Using the token inflationMultiplier instead of the bridge inflationMultiplier

The original report as published on Sherlock, by 0xRobocop. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

Likely the bridge caches the inflationMultiplier in storage and only updates it via a separate rebase transaction, so the cached value can diverge from the token's current multiplier used during transferFrom.

Impact

An attacker could steal tokens by depositing when the stored multiplier is stale and larger, receiving more tokens on L2 than they deposited.

What the attacker needed

Rebase not called recently; attacker can deposit to L1 bridge

The fix

The bridge should read the token's current inflation multiplier directly from the L1 ECO token instead of using the stored value; the report states this was fixed.

How it was found

  1. Observe that the bridge's stored inflationMultiplier is larger than the L1 ECO token's current multiplier because rebase has not been called.
  2. Deposit tokens to the L1 bridge; transferFrom moves the correct gons amount but the bridge multiplies the amount by the stale larger multiplier.
  3. Receive more tokens on L2 than the deposit was worth.

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 bridge moves tokens between two blockchains. This bridge uses a number called inflationMultiplier to convert between the token's internal units and the amount users see. That number is only refreshed when someone calls a separate function. If nobody calls it for a while, the bridge uses an old number. An attacker can deposit at that moment and the bridge will think they deposited more than they did, so they get extra tokens on the other chain.

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 0xRobocop

View all

15 more disclosed reports, best first.

More from Eco Protocol

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.