Skip to content
Business logic Audit finding Intermediate

Donated Tokens Cannot Be Recovered If A Shelter Is Deactivated

When a shelter is deactivated, donated LP tokens are transferred back to the ConvexStakingWrapper contract and become stuck because they are not credited to any user. An attacker could donate tokens and then trigger deactivation, causing those tokens to be permanently lost.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood, also found by reassor

The shelter mechanism can be activated and deactivated on a target LP token. The owner of the ConvexStakingWrapper.sol contract can initiate the shelter whereby LP tokens are sent to the Shelter.sol contract. However, if the owner decides to deactivate the shelter before the grace period has passed, all LP tokens are transferred back to the ConvexStakingWrapper.sol contract. Donated tokens are also sent back to the contract. As a result, these tokens do not actually belong to any user and will effectively be lost in the contract.

Proof of Concept

Shelter.sol#L32-L36

function donate(IERC20 _token, uint256 _amount) external {
    require(activated[_token] != 0, "!activated");
    savedTokens[_token] += _amount;
    _token.safeTransferFrom(msg.sender, address(this), _amount);
}

ConvexStakingWrapper.sol#L107-L130

function enterShelter(uint256[] calldata _pids) external onlyOwner {
    for(uint256 i = 0; i<_pids.length; i++){
        IRewardStaking pool = IRewardStaking(convexPool[_pids[i]]);
        uint256 amount = pool.balanceOf(address(this));
        pool.withdrawAndUnwrap(amount, false);
        IERC20 lpToken = IERC20(
            pool.poolInfo(_pids[i]).lptoken
        );
        amountInShelter[lpToken] = amount;
        lpToken.safeTransfer(address(shelter), amount);
        shelter.activate(lpToken);
    }
}

function exitShelter(uint256[] calldata _pids) external onlyOwner {
    for(uint256 i = 0; i<_pids.length; i++){
        IRewardStaking pool = IRewardStaking(convexPool[_pids[i]]);
        IERC20 lpToken = IERC20(
            pool.poolInfo(_pids[i]).lptoken
        );
        amountInShelter[lpToken] = 0;
        shelter.deactivate(lpToken);
    }
}

Recommended Mitigation Steps

Consider allocating donated LP tokens to the contract owner when a shelter is deactivated. This can be done by checking for an excess of LP tokens. Anything greater than amountInShelter can be considered as donated.

leekt (Concur) acknowledged

Alex the Entreprenerd (judge) commented:

The warden has indentified a way to potentially lose tokens, ultimately the contract could be rewritten to constantly allow redemption.

For those reasons, and because the sponsor acknowledged, I believe the finding to be valid and of medium severity.


The original report as published on Code4rena, by leastwood. 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 exitShelter function deactivates the shelter and transfers all LP tokens back to the wrapper without distinguishing donated tokens from user deposits, leaving donated tokens stranded.

Impact

Donated LP tokens could be permanently lost if the shelter is deactivated, as they become stuck in the wrapper contract.

What the attacker needed

Shelter is activated; user donates tokens; owner deactivates shelter

The fix

The contract should be modified to allocate donated LP tokens to the contract owner upon shelter deactivation, by checking for excess tokens above the recorded amount.

How it was found

  1. Owner activates shelter for a target LP token via enterShelter.
  2. A user donates LP tokens to the shelter using the donate function.
  3. Owner calls exitShelter to deactivate the shelter before the grace period ends.
  4. All LP tokens, including donated ones, are transferred back to the ConvexStakingWrapper contract.
  5. Donated tokens remain stuck in the contract with no way to recover them.

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 shelter is a temporary holding place for tokens. Users can donate tokens to it. If the shelter is turned off, all tokens go back to the main contract, but the contract does not know who donated them, so they get stuck. This means donated tokens can be lost forever.

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 leastwood

View all

70 more disclosed reports, best first.

More from Concur Finance contest

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.