Skip to content
Access control Audit finding Intermediate

InfernalRiftBelow.thresholdCross verify the wrong msg.sender

The `thresholdCross` function in `InfernalRiftBelow` checks that the caller is the aliased address of `InfernalRiftAbove`, but the actual caller is the relayer address. As a result, cross-chain NFT transfers fail and user assets are lost.

Ali9955 Follow with Tendency, ZeroTrust and 1 other

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/405

The protocol has acknowledged this issue.

Found by

Ali9955, Tendency, ZeroTrust, novaman33

Summary

InfernalRiftBelow.thresholdCross verify the wrong msg.sender, thresholdCross will fail to be called, resulting in the loss of user assets.

Vulnerability Detail

thresholdCross determines whether msg.sender is expectedAliasedSender:

Solidity
    address expectedAliasedSender = address(uint160(INFERNAL_RIFT_ABOVE) + uint160(0x1111000000000000000000000000000000001111));
    // Ensure the msg.sender is the aliased address of {InfernalRiftAbove}
    if (msg.sender != expectedAliasedSender) {
        revert CrossChainSenderIsNotRiftAbove();
    }

but in fact the function caller should be RELAYER_ADDRESS, In sudoswap, crossTheThreshold check whether msg.sender is RELAYER_ADDRESS: https://github.com/sudoswap/InfernalRift/blob/7696827b3221929b3fa563692bd4c5d73b20528e/src/InfernalRiftBelow.sol#L56

L1 across chain message through the PORTAL.depositTransaction, rather than L1_CROSS_DOMAIN_MESSENGER.

To avoid confusion, use in L1 should all L1_CROSS_DOMAIN_MESSENGER.sendMessage to send messages across the chain, avoid the use of low level PORTAL. depositTransaction function.

Solidity
 function crossTheThreshold(ThresholdCrossParams memory params) external payable {
        ......
        // Send package off to the portal
        PORTAL.depositTransaction{value: msg.value}(
            INFERNAL_RIFT_BELOW,
            0,
            params.gasLimit,
            false,
            abi.encodeCall(InfernalRiftBelow.thresholdCross, (package, params.recipient))
        );

        emit BridgeStarted(address(INFERNAL_RIFT_BELOW), package, params.recipient);
    }

Impact

When transferring nft across chains,thresholdCross cannot be called in L2, resulting in loss of user assets.

Code Snippet

https://github.com/sherlock-audit/2024-08-flayer/blob/0ec252cf9ef0f3470191dcf8318f6835f5ef688c/moongate/src/InfernalRiftBelow.sol#L135-L145

Tool used

Manual Review

Recommendation

Solidity
    // Validate caller is cross-chain
    if (msg.sender != RELAYER_ADDRESS) { //or L2_CROSS_DOMAIN_MESSENGER
        revert NotCrossDomainMessenger();
    }

    // Validate caller comes from {InfernalRiftBelow}
    if (ICrossDomainMessenger(msg.sender).xDomainMessageSender() != InfernalRiftAbove) {
        revert CrossChainSenderIsNotRiftBelow();
    }

Discussion

zhaojio

We asked sponsor:

InfernalRiftBelow.claimRoyalties function of the msg.sender, is RELAYER_ADDRESS? right??

Sponsor reply:

good catch, it should be L2_CROSS_DOMAIN_MESSENGER instead

The original report as published on Sherlock, by Ali9955. 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 access control check in `thresholdCross` compares `msg.sender` to an aliased address of `InfernalRiftAbove` instead of the actual relayer or cross-domain messenger address.

Impact

Cross-chain NFT transfers cannot be completed, resulting in loss of user assets.

What the attacker needed

Cross-chain NFT transfer; user initiates bridge

The fix

The check should validate that `msg.sender` is the relayer address or the L2 cross-domain messenger, and optionally verify the original sender via `xDomainMessageSender`.

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.

When you send an NFT from one blockchain to another, a contract on the second chain must accept the message. This report says that contract checks for the wrong sender address, so it always rejects the message. The NFT gets stuck or lost because the transfer never completes.

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.

More from Flayer

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.