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

safeApprove will fail if the current approval is not 0 #269

Open
code423n4 opened this issue Jan 26, 2022 · 0 comments
Open

safeApprove will fail if the current approval is not 0 #269

code423n4 opened this issue Jan 26, 2022 · 0 comments
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working

Comments

@code423n4
Copy link
Contributor

Handle

pauliax

Vulnerability details

Impact

safeApprove will fail if the current approval is > 0 but < amount:

  if (want.allowance(address(this), address(lp)) < amount) {
    want.safeApprove(address(lp), type(uint256).max);
  }

This condition is unlikely to happen in practice as you approve the max value which should in theory last forever, but nevertheless a better option would be to reset the approval before setting it once again:

  if (want.allowance(address(this), address(lp)) < amount) {
    want.safeApprove(address(lp), 0);
    want.safeApprove(address(lp), type(uint256).max);
  }
@code423n4 code423n4 added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working labels Jan 26, 2022
code423n4 added a commit that referenced this issue Jan 26, 2022
@Evert0x Evert0x added duplicate This issue or pull request already exists sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") and removed sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels Feb 9, 2022
@CloudEllie CloudEllie removed the duplicate This issue or pull request already exists label Feb 21, 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
Projects
None yet
Development

No branches or pull requests

3 participants