Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

0xdeadbeef - Malicious actor cause rebase to an old inflation multiplier #142

Open
sherlock-admin opened this issue May 25, 2023 · 7 comments
Labels
Escalation Resolved This issue's escalations have been approved/rejected Has Duplicates A valid issue with 1+ other issues describing the same vulnerability High A valid High severity issue Reward A payout will be made for this issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented May 25, 2023

0xdeadbeef

high

Malicious actor cause rebase to an old inflation multiplier

Summary

The protocol has a rebasing mechanism that allows to sync the inflation multiplier between both L1 and L2 chains.
The call to rebase is permissionless (anyone can trigger it).
Insufficant checks allow a malicious actor to rebase to an old value.

Vulnerability Detail

Rebasing from L1 to L2 is through the L1ECOBridge rebase function. It collects the inflation multiplier from the ECO token and sends a message to L2ECOBridge to update the L2 ECO token inflation multiplier.
https://github.com/sherlock-audit/2023-05-ecoprotocol/blob/main/op-eco/contracts/bridge/L1ECOBridge.sol#L296

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

        bytes memory message = abi.encodeWithSelector(
            IL2ECOBridge.rebase.selector,
            inflationMultiplier
        );

        sendCrossDomainMessage(l2TokenBridge, _l2Gas, message);
    }

A malicious actor can call this function a large amount of times to queue messages on L2CrossDomainMessenger.
Since it is expensive to execute so much messages from L2CrossDomainMessenger (especially if the malicious actor sets _l2Gas to a high value) there will be a rebase message that will not be relayed through L2CrossDomainMessenger (or in failedMessages array).

Some time passes and other legitimate rebase transactions get executed.

One day the malicious actor can execute one of his old rebase messages and set the value to the old value. The attacker will debalance the scales between L1 and L2 and can profit from it.

Impact

debalance the scales between L1 and L2 ECO token

Code Snippet

Tool used

Manual Review

Recommendation

When sending a rebase from L1, include in the message the L1 block number. In L2 rebase, validate that the new rebase block number is above previous block number

@github-actions github-actions bot added High A valid High severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels May 29, 2023
@sherlock-admin sherlock-admin added Non-Reward This issue will not receive a payout and removed High A valid High severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Jun 5, 2023
@albertnbrown albertnbrown added the Sponsor Confirmed The sponsor acknowledged this issue is valid label Jun 6, 2023
@albertnbrown
Copy link

This is legitimate because unlike upgrade functions, the rebase function has no auth guards. We have added fixes to this to this PR:

eco-association/op-eco#33

@0xdeadbeef0x
Copy link

Escalate for 10 USDC

Escalating to verify that this gets the the reward tag as it was confirmed and fixed by the sponsor.

@sherlock-admin
Copy link
Contributor Author

Escalate for 10 USDC

Escalating to verify that this gets the the reward tag as it was confirmed and fixed by the sponsor.

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.

@sherlock-admin sherlock-admin added the Escalated This issue contains a pending escalation label Jun 7, 2023
@hrishibhat
Copy link

hrishibhat commented Jun 9, 2023

Escalation accepted

Valid high

@hrishibhat hrishibhat reopened this Jun 9, 2023
@sherlock-admin
Copy link
Contributor Author

sherlock-admin commented Jun 9, 2023

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.

@sherlock-admin sherlock-admin added Reward A payout will be made for this issue and removed Non-Reward This issue will not receive a payout labels Jun 9, 2023
@hrishibhat hrishibhat added the High A valid High severity issue label Jun 9, 2023
@sherlock-admin sherlock-admin added Escalation Resolved This issue's escalations have been approved/rejected and removed Escalated This issue contains a pending escalation labels Jun 9, 2023
@hrishibhat hrishibhat added Escalated This issue contains a pending escalation Escalation Resolved This issue's escalations have been approved/rejected and removed Escalation Resolved This issue's escalations have been approved/rejected labels Jun 9, 2023
@sherlock-admin sherlock-admin added Escalation Resolved This issue's escalations have been approved/rejected and removed Escalated This issue contains a pending escalation labels Jun 9, 2023
@hrishibhat hrishibhat added the Has Duplicates A valid issue with 1+ other issues describing the same vulnerability label Jun 11, 2023
@0xffff11
Copy link
Collaborator

Added fix in: eco-association/op-eco#33

@shahrukhtrao shahrukhtrao added the Will Fix The sponsor confirmed this issue will be fixed label Jun 11, 2023
@0xffff11
Copy link
Collaborator

Fix confirmed, added block number to L1 calls to prevent any replay attacks using failed cross-bridge calls

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Escalation Resolved This issue's escalations have been approved/rejected Has Duplicates A valid issue with 1+ other issues describing the same vulnerability High A valid High severity issue Reward A payout will be made for this issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

6 participants