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

Use of approve Function Without safeApprove in Multiple Contracts #436

Closed
code423n4 opened this issue Aug 30, 2023 · 5 comments
Closed

Use of approve Function Without safeApprove in Multiple Contracts #436

code423n4 opened this issue Aug 30, 2023 · 5 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 duplicate-1662 low quality report This report is of especially low quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/amo/UniV2LiquidityAmo.sol#L136
https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/amo/UniV3LiquidityAmo.sol#L175
https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/core/RdpxV2Core.sol#L416
https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/perp-vault/PerpetualAtlanticVault.sol#L248

Vulnerability details

Impact

The use of the standard approve function without the safer safeApprove alternative can lead to potential issues with certain tokens. Some tokens, such as USDT and KNC, do not allow users to approve an amount M>0 when an existing amount N>0 is already approved. This can lead to failed transactions and unexpected behavior for users interacting with these tokens.

Proof of Concept

The following are direct links to the code sections in various contracts where the standard approve function is used:

UniV2LiquidityAmo.sol - Line 136
UniV3LiquidityAmo.sol - Line 175
RdpxV2Core.sol - Line 416
PerpetualAtlanticVault.sol - Line 248
In each of these instances, the approve function is used without first checking or resetting the allowance, which can lead to issues with tokens that have the aforementioned behavior.

Tools Used

Manual review

Recommended Mitigation Steps

Replace the standard approve function with a safeApprove function that first checks the current allowance and resets it to zero if necessary before setting a new allowance.
Test the updated contracts with tokens known to have the problematic behavior (e.g., USDT, KNC) to ensure compatibility.
Consider adding comments in the code to explain the rationale behind using safeApprove to guide future developers and maintainers.

Assessed type

Token-Transfer

@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 Aug 30, 2023
code423n4 added a commit that referenced this issue Aug 30, 2023
@c4-pre-sort
Copy link

bytes032 marked the issue as duplicate of #928

@c4-pre-sort c4-pre-sort added duplicate-928 low quality report This report is of especially low quality labels Sep 8, 2023
@c4-pre-sort
Copy link

bytes032 marked the issue as low quality report

@c4-pre-sort
Copy link

bytes032 marked the issue as not a duplicate

@c4-pre-sort
Copy link

bytes032 marked the issue as duplicate of #1662

@c4-judge
Copy link
Contributor

c4-judge commented Oct 6, 2023

GalloDaSballo marked the issue as unsatisfactory:
Out of scope

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Oct 6, 2023
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 duplicate-1662 low quality report This report is of especially low quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

3 participants