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 approve instead of safeApprove #31

Closed
code423n4 opened this issue Dec 9, 2021 · 2 comments
Closed

Use approve instead of safeApprove #31

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

Comments

@code423n4
Copy link
Contributor

Handle

robee

Vulnerability details

Some tokens don't correctly implement the EIP20 standard and their approve function returns void instead of a success boolean.
Calling these functions with the correct EIP20 function signatures will always revert.
Tokens that don't correctly implement the latest EIP20 spec, like USDT, will be unusable in the mentioned contracts as they revert the transaction because of the missing return value.
We recommend using OpenZeppelin’s SafeERC20 versions with the safeApprove function that handle the return value check as well as non-standard-compliant tokens.
The list of occurrences in format (solidity file, line number, actual line)
CreditLine.sol, 646, IERC20(_collateralAsset).approve(_strategy, _amount);
CreditLine.sol, 774, IERC20(_borrowAsset).approve(_defaultStrategy, _amount);
Strategy.sol, 41, // IERC20(token).approve(mcd_join_eth_a, uint256(-1));
yVault.sol, 169, callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
yVault.sol, 178, callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
yVault.sol, 187, callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
AaveYield.sol, 293, IERC20(asset).approve(lendingPool, 0);
AaveYield.sol, 294, IERC20(asset).approve(lendingPool, amount);
AaveYield.sol, 303, IERC20(IWETHGateway(wethGateway).getAWETHAddress()).approve(wethGateway, amount);
AaveYield.sol, 320, IERC20(aToken).approve(lendingPool, amount);
CompoundYield.sol, 207, IERC20(asset).approve(cToken, 0);
CompoundYield.sol, 208, IERC20(asset).approve(cToken, amount);
YearnYield.sol, 206, IERC20(asset).approve(vault, 0);
YearnYield.sol, 207, IERC20(asset).approve(vault, amount);

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Dec 9, 2021
code423n4 added a commit that referenced this issue Dec 9, 2021
@ritik99 ritik99 added the duplicate This issue or pull request already exists label Dec 25, 2021
@ritik99
Copy link
Collaborator

ritik99 commented Dec 25, 2021

Duplicate of #2

@ritik99 ritik99 marked this as a duplicate of #2 Dec 25, 2021
@ritik99 ritik99 closed this as completed Dec 25, 2021
@0xean
Copy link
Collaborator

0xean commented Jan 21, 2022

downgrading based on the duplicate and risk implications of the approve.

@0xean 0xean added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Jan 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 duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants