Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Tomo - 【Tomo-M#2】create safe version ERC20-approve function #203

Closed
github-actions bot opened this issue Mar 10, 2023 · 0 comments
Closed

Tomo - 【Tomo-M#2】create safe version ERC20-approve function #203

github-actions bot opened this issue Mar 10, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@github-actions
Copy link

github-actions bot commented Mar 10, 2023

Tomo

medium

【Tomo-M#2】create safe version ERC20-approve function

Summary

You should create a safe version of the ERC20 approve function like safeTransfer and safeTransferFrom.

Vulnerability Detail

The Pool contract has safeTransfer and safeTransferFrom functions to prevent some attack vectors. However, there is no safe version of the ERC20-approve function.

Therefore it happens "Multiple Withdrawal Attack"

Impact

It happens Multiple Withdrawal Attack

Code Snippet

/// @notice Approves an address to spend pool tokens on behalf of the sender
/// @param spender The address of the spender
/// @param amount The amount of pool tokens to approve
/// @return bool that indicates if the operation was successful
function approve(address spender, uint amount) external returns (bool) {
    allowance[msg.sender][spender] = amount;
    emit Approval(msg.sender, spender, amount);
    return true;
}

https://github.com/sherlock-audit/2023-02-surge/blob/main/surge-protocol-v1/src/Pool.sol#L295-L303

Tool used

Manual Review

Recommendation

Add safeIncreaseAllowance and safeDecreaseAllowance refer to SafeERC20 by OpenZeppelin

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/utils/SafeERC20.sol#L56-L75

Similar Issue

code-423n4/2022-04-backd-findings#180

Duplicate of #154

@github-actions github-actions bot added Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue labels Mar 10, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Mar 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant