Skip to content
Business logic Audit finding Advanced

Adversary can make honest parties unable to retrieve their assertion stakes if the required amount is decreased

When the required stake for new assertions is lowered, an attacker can create an invalid assertion and then have a friend create a child assertion with the lower stake, allowing the attacker to withdraw their larger stake and leaving the contract insolvent so honest stakers cannot retrieve their funds.

xuwinnie Follow with Ch_301

Originally disclosed on Code4rena

Submitted by xuwinnie, also found by Ch_301

Impact

When the required stake (to create a new assertions) is updated to a lower amount, adversary can make the honest party unable to retrieve their assertion stakes.

Proof of Concept

     A -- B -- C -- D(latest confirmed) -- E

Suppose the initial stake amount is 1000 ETH, and till now no invalid assertions have been made. (A, B, C, D, E are all valid and made by the same validator). The rollup contract should hold 1000 ETH now.

     A -- B -- C -- D(latest confirmed) -- E
                                        \
                                         \ F(invalid)

Then, the admin update the required stake to 700 ETH, Alice made an invalid assertion F. Since its parent D was created before the update, Alice will still need to stake 1000 ETH, and the 1000 ETH will be sent to loserStakeEscrow.

            if (!getAssertionStorage(newAssertionHash).isFirstChild) {

                // only 1 of the children can be confirmed and get their stake refunded
                // so we send the other children's stake to the loserStakeEscrow
                IERC20(stakeToken).safeTransfer(loserStakeEscrow, assertion.beforeStateData.configData.requiredStake);
            }
     A -- B -- C -- D(latest confirmed) -- E
                                        \

                                         \ F -- G

(a) Alice creates F’s children, G. Now, only 700 ETH of stake is needed. However, as the comment suggests, no refund will be made since G’s ancestor could need more stake.

            // requiredStake is user supplied, will be verified against configHash later
            // the prev's requiredStake is used to make sure all children have the same stake
            // the staker may have more than enough stake, and the entire stake will be locked
            // we cannot do a refund here because the staker may be staker on an unconfirmed ancestor that requires more stake
            // excess stake can be removed by calling reduceDeposit when the staker is inactive
            require(amountStaked(msg.sender) >= assertion.beforeStateData.configData.requiredStake, "INSUFFICIENT_STAKE");

(b) To bypass the limit in (a), Alice calls her friend Bob to make the assertion G instead , Bob will only need to stake 700 ETH now. The rollup contract currently holds 1700 ETH. Then, Alice can withdraw her stake since she is no longer active. (her last staked assertion have a child)

        function requireInactiveStaker(address stakerAddress) internal view {
            require(isStaked(stakerAddress), "NOT_STAKED");
            // A staker is inactive if
            // a) their last staked assertion is the latest confirmed assertion
            // b) their last staked assertion have a child
            bytes32 lastestAssertion = latestStakedAssertion(stakerAddress);
            bool isLatestConfirmed = lastestAssertion == latestConfirmed();
            bool haveChild = getAssertionStorage(lastestAssertion).firstChildBlock > 0;
            require(isLatestConfirmed || haveChild, "STAKE_ACTIVE");
        }

Now the rollup contract holds 700 ETH, which means it is insolvent. The honest validator cannot withdraw her original stake. (700 < 1000)

Recommended Mitigation Steps

Ensure the following

  1. A staker is considered inactive only if her last staked assertion is confirmed.
  2. A staker can only stake on her last staked assertion’s descendants. (otherwise Alice can switch to the correct branch and withdraw)

gzeoneth (Arbitrum) confirmed and commented:

Patched with https://github.com/OffchainLabs/bold/pull/655.


The original report as published on Code4rena, by xuwinnie. 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

Likely the contract allows a staker to be considered inactive and withdraw their stake even when their last staked assertion is not confirmed, and it does not prevent staking on a different branch, enabling a withdrawal that leaves the contract undercollateralised.

Impact

The contract becomes insolvent, so honest stakers cannot retrieve their stakes.

What the attacker needed

Admin lowers required stake; attacker has a friend; attacker can create an invalid assertion

The fix

The contract was patched to ensure a staker is considered inactive only if their last staked assertion is confirmed, and to restrict staking to descendants of the last staked assertion.

How it was found

  1. The admin lowers the required stake from 1000 ETH to 700 ETH.
  2. Alice creates an invalid assertion F, which still requires the old 1000 ETH stake because its parent was created before the update.
  3. Alice asks her friend Bob to create a child assertion G of F, which only requires the new 700 ETH stake.
  4. Alice withdraws her 1000 ETH stake because her last staked assertion (F) now has a child, making her inactive.
  5. The contract holds only 700 ETH, so the honest validator cannot withdraw her original 1000 ETH stake.

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.

This is about a smart contract where people lock up money (a stake) to vouch for claims. If the amount needed to make a new claim is later reduced, someone can exploit the rules to take their money out early, leaving too little in the contract for honest people to get their own money back.

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 xuwinnie

View all

12 more disclosed reports, best first.

More from Arbitrum BoLD

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.