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

SingleJoin/SingleExit ignore the return value of ERC20.approve #114

Closed
code423n4 opened this issue Dec 17, 2021 · 1 comment
Closed

SingleJoin/SingleExit ignore the return value of ERC20.approve #114

code423n4 opened this issue Dec 17, 2021 · 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 duplicate This issue or pull request already exists

Comments

@code423n4
Copy link
Contributor

Handle

Ruhum

Vulnerability details

Impact

According to the ERC20 standard, the approve() function returns a boolean value indicating whether the call was successful or not, see https://eips.ethereum.org/EIPS/eip-20#methods

The SingleJoin/SingleExit contracts ignore that return value when approving tokens for the uniswap router. It might lead to a failed transaction because the contract proceeded with the swap although the approve() call failed.

Proof of Concept

relevant line:
https://github.com/code-423n4/2021-12-amun/blob/main/contracts/basket/contracts/singleJoinExit/SingleNativeTokenExit.sol#L44

https://github.com/code-423n4/2021-12-amun/blob/main/contracts/basket/contracts/singleJoinExit/SingleNativeTokenExitV2.sol#L55

https://github.com/code-423n4/2021-12-amun/blob/main/contracts/basket/contracts/singleJoinExit/SingleTokenJoin.sol#L43

https://github.com/code-423n4/2021-12-amun/blob/main/contracts/basket/contracts/singleJoinExit/SingleTokenJoinV2.sol#L53

Tools Used

Slither

Recommended Mitigation Steps

Use SafeERC20.safeApprove() which reverts when the call fails or returns false.

@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 Dec 17, 2021
code423n4 added a commit that referenced this issue Dec 17, 2021
@loki-sama
Copy link
Collaborator

duplicate #294

@loki-sama loki-sama added the duplicate This issue or pull request already exists label Jan 4, 2022
@ghost ghost closed this as completed Jan 10, 2022
This issue was closed.
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 duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants