stake.link

stake.link
DeFiHardhatBridge
27,500 USDC
View results
Submission Details
Severity: medium
Invalid

Max approve will revert for tokens that don't support approve `type(uint256).max` amount.

Summary

Large transfers may not work with some ERC20 tokens
Some IERC20 implementations (e.g UNI, COMP) may fail if the valued transferred is larger than uint96.

Vulnerability Details

approveRewardTokens will not work for tokens that don't support approve type(uint256).max amount.

Impact

Tokens that don't support approve type(uint256).max amount could not be used by calling approveRewardTokens function.

Tools Used

Manual Analysis

Recommendations

The recommendation is made to approve only the necessay amount of token to the instead of the type(uint256).max amount.

- function approveRewardTokens(address[] calldata _tokens) external onlyOwner {
+ function approveRewardTokens(address[] calldata _tokens, uint64 amount) external onlyOwner {
address router = getRouter();
for (uint256 i = 0; i < _tokens.length; i++) {
- IERC20(_tokens[i]).safeApprove(router, type(uint256).max);
+ IERC20(_tokens[i]).safeApprove(router, amount);
}
}
Updates

Lead Judging Commences

0kage Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.