Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User will lose funds #108

Open
code423n4 opened this issue May 19, 2022 · 3 comments
Open

User will lose funds #108

code423n4 opened this issue May 19, 2022 · 3 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

code423n4 commented May 19, 2022

Lines of code

https://github.com/code-423n4/2022-05-aura/blob/main/contracts/AuraClaimZap.sol#L224-L226

Vulnerability details

Impact

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);
          }
      }
@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels May 19, 2022
code423n4 added a commit that referenced this issue May 19, 2022
@itsmetechjay
Copy link
Contributor

Per help desk request, updated the recommended mitigation steps for this issue.

@0xMaharishi 0xMaharishi added disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels May 25, 2022
@0xMaharishi
Copy link

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

@dmvt
Copy link
Collaborator

dmvt commented Jun 20, 2022

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.

@dmvt dmvt added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

4 participants