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

Should call want.safeApprove(address(lp), 0); #57

Closed
code423n4 opened this issue Jan 23, 2022 · 1 comment
Closed

Should call want.safeApprove(address(lp), 0); #57

code423n4 opened this issue Jan 23, 2022 · 1 comment
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists

Comments

@code423n4
Copy link
Contributor

Handle

cccz

Vulnerability details

Impact

In the deposit function, when want.allowance(address(this), address(lp)) < amount, the contract should call want.safeApprove(address(lp), 0);

Proof of Concept

https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/managers/AaveV2Strategy.sol#L70-L72

Tools Used

Manual analysis

Recommended Mitigation Steps

  function deposit() external override whenNotPaused {
    ILendingPool lp = getLp();
    // Checking the USDC balance of this contract
    uint256 amount = want.balanceOf(address(this));
    if (amount == 0) revert InvalidConditions();

    // If allowance for this contract is too low, approve the max allowance
    if (want.allowance(address(this), address(lp)) < amount) {
+   want.safeApprove(address(lp), 0);
      want.safeApprove(address(lp), type(uint256).max);
    }

    // Deposits the full balance of USDC held in this contract into Aave's lending pool
    lp.deposit(address(want), amount, address(this), 0);
  }
@code423n4 code423n4 added 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 labels Jan 23, 2022
code423n4 added a commit that referenced this issue Jan 23, 2022
@Evert0x Evert0x added disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists labels Feb 9, 2022
@Evert0x
Copy link
Collaborator

Evert0x commented Feb 9, 2022

#269

@jack-the-pug jack-the-pug added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants