Skip to content
Business logic Audit finding Intermediate

User will lose funds

A missing else condition in the claimRewards function causes a user's CVX tokens to be transferred to the contract but not locked when the LockCvx option is false, leaving the funds stuck. An attacker cannot exploit this; it is a user error that results in lost funds.

Anurag Jain Follow

Originally disclosed on Code4rena

Submitted by csanuragjain, also found by hyh and kirk-baird

AuraClaimZap.sol#L224-L226

It was observed that User will lose funds due to missing else condition.

Proof of Concept

  1. User call claimRewards at ClaimZap.sol#L103 with Options.LockCvx as false
  2. claimRewards internally calls _claimExtras
  3. Everything goes good until AuraClaimZap.sol#L218
if (depositCvxMaxAmount > 0) {
            uint256 cvxBalance = IERC20(cvx).balanceOf(msg.sender).sub(removeCvxBalance);
            cvxBalance = AuraMath.min(cvxBalance, depositCvxMaxAmount);
            if (cvxBalance > 0) {
                //pull cvx
                IERC20(cvx).safeTransferFrom(msg.sender, address(this), cvxBalance);
                if (_checkOption(options, uint256(Options.LockCvx))) {
                    IAuraLocker(locker).lock(msg.sender, cvxBalance);
                }
            }
        }
  1. Since user cvxBalance>0 so cvxBalance is transferred from user to the contract.
  2. Now since Options.LockCvx was set to false in options so if (_checkOption(options, uint256(Options.LockCvx))) does not evaluate to true and does not execute
  3. This means User cvx funds are stuck in contract

Recommended Mitigation Steps

The condition should check if user has enabled lock for cvx, otherwise cvx should not be transferred from user

if (depositCvxMaxAmount > 0 && _checkOption(options, uint256(Options.LockCvx))) {
          uint256 cvxBalance = IERC20(cvx).balanceOf(msg.sender).sub(removeCvxBalance);
          cvxBalance = AuraMath.min(cvxBalance, depositCvxMaxAmount);
          if (cvxBalance > 0) {
              //pull cvx
              IERC20(cvx).safeTransferFrom(msg.sender, address(this), cvxBalance);

                  IAuraLocker(locker).lock(msg.sender, cvxBalance);
          }
      }

0xMaharishi (Aura Finance) confirmed, but disagreed with severity and commented:

This is valid, although it:

  • relies on user function input
  • does not affect user deposits
  • requires pre-approval of tokens

Therefore, I don’t think this should be a 3 severity. 2 at most.

LSDan (judge) decreased severity to Medium and commented:

This is a tough one, but I agree that medium severity makes more sense here since we’re talking about a user acting on their own behalf in a very specific way. This does not open up an attack vector which would allow a malicious actor to lock a user’s funds.

0xMaharishi (Aura Finance) resolved:

code4rena aurafinance/aura-contracts#84 All code4rena fixes code-423n4/2022-05-aura#6


The original report as published on Code4rena, by csanuragjain. 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 code transfers CVX from the user before checking if the LockCvx option is enabled, and if it is not, the tokens remain in the contract without being locked or returned.

Impact

The user's CVX tokens become stuck in the contract, resulting in a loss of funds for that user; this requires the user to call the function with a specific option and does not allow an attacker to lock funds.

What the attacker needed

User calls claimRewards with LockCvx false; user has approved CVX transfer

The fix

The condition should be changed to only transfer CVX if the LockCvx option is enabled, as shown in the recommended mitigation.

How it was found

  1. User calls claimRewards with Options.LockCvx set to false.
  2. claimRewards internally calls _claimExtras.
  3. The code reaches the block that handles depositCvxMaxAmount.
  4. Since cvxBalance is greater than zero, CVX is transferred from the user to the contract.
  5. Because LockCvx is false, the lock function is not called, leaving the CVX stuck in the contract.

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 a smart contract bug where a user's tokens get stuck because the code takes the tokens but doesn't do anything with them if a certain option is off. The user has to call a function with a specific setting, and then their tokens are transferred to the contract but not locked, so they can't get them back. It's not an attack; it's a mistake in the code that can cause users to lose money.

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 Anurag Jain

View all

63 more disclosed reports, best first.

More from Aura 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.