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

PRAISE - Spender can frontrun setApprovalForERC20() in FootiumEscrow.sol #8

Closed
sherlock-admin opened this issue May 5, 2023 · 7 comments
Labels
Escalation Resolved This issue's escalations have been approved/rejected Low/Info A valid Low/Informational severity issue Non-Reward This issue will not receive a payout Sponsor Confirmed The sponsor acknowledged this issue is valid

Comments

@sherlock-admin
Copy link
Contributor

PRAISE

high

Spender can frontrun setApprovalForERC20() in FootiumEscrow.sol

Summary

The approve function is frontrunnable.

Vulnerability Detail

Lets say Alice is the owner of these tokens and Bob is the spender:

  • Now Alice approves Bob to spend his tokens by passing in Bob's address
  • she approves him to transfer 1000 tokens.
  • After sometime she decide to change from 1000 tokens to 500 tokens
  • Bob notices the Alice's second transaction before it was mined and quickly sends another transaction that calls the .transferFrom method to transfer 1000 tokens from Alice somewhere
  • If the Bob's transaction will be executed before the Alice's transaction, then Bob will successfully transfer 1000 tokens from Alice and will gain an ability to transfer another 500 tokens too
  • Before Alice noticed that something went wrong, Bob calls the .transferFrom method again, this time to transfer 500 tokens from Alice.
  • So, Alice's attempt to change the Bob's allowance from 1000 to 500 made it possible for Bob to transfer 1000+500 of Alice's tokens, while Alice never wanted to allow so many of her tokens to be transferred by Bob.

Impact

It can result in losing tokens when club owner approves ERC20 tokens to any malicious Spender.

Code Snippet

    function setApprovalForERC20(
        IERC20 erc20Contract,
        address to,
        uint256 amount
    ) external onlyClubOwner {
        erc20Contract.approve(to, amount);
    }

https://github.com/sherlock-audit/2023-04-footium/blob/main/footium-eth-shareable/contracts/FootiumEscrow.sol#L75-L81

Tool used

Manual Review

Recommendation

Use increaseAllowance and decreaseAllowance instead of approve as OpenZeppelin ERC20 implementation. Please see details here:

https://forum.openzeppelin.com/t/explain-the-practical-use-of-increaseallowance-and-decreaseallowance-functions-on-erc20/15103/4

@github-actions github-actions bot added High A valid High severity issue Has Duplicates A valid issue with 1+ other issues describing the same vulnerability labels May 10, 2023
This was referenced May 10, 2023
@logiclogue logiclogue added the Sponsor Confirmed The sponsor acknowledged this issue is valid label May 16, 2023
@logiclogue
Copy link

This is a duplicate for another issue in this list. However, this one has a better suggestion

@hrishibhat hrishibhat added Medium A valid Medium severity issue and removed High A valid High severity issue labels May 20, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label May 22, 2023
@GalloDaSballo
Copy link

Escalate for 10 USDC

The finding says that the allowance can be front-run, but it fails to acknowledge the fact that if the spender didn't want to allow the extra allowance to be at risk, they would have sent a approve(0) first in a separate transaction

The finding is also logically equivalent to saying that granting allowance to a scammer is a vulnerability, which would be considered out of scope / invalid

I would recommend closing as invalid

If you believe that the allowance is a honey-pot vector then you should merge it with: #291

@sherlock-admin
Copy link
Contributor Author

Escalate for 10 USDC

The finding says that the allowance can be front-run, but it fails to acknowledge the fact that if the spender didn't want to allow the extra allowance to be at risk, they would have sent a approve(0) first in a separate transaction

The finding is also logically equivalent to saying that granting allowance to a scammer is a vulnerability, which would be considered out of scope / invalid

I would recommend closing as invalid

If you believe that the allowance is a honey-pot vector then you should merge it with: #291

You've created a valid escalation for 10 USDC!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

@sherlock-admin sherlock-admin added the Escalated This issue contains a pending escalation label May 23, 2023
@securitygrid
Copy link

This question really doesn't matter much. Can't reach M, suggest low/info.

@ctf-sec
Copy link
Collaborator

ctf-sec commented May 23, 2023

Agree with GalloDaSballo, can be a valid low / informational

@hrishibhat
Copy link

Escalation accepted

Valid low
Based on the escalation and other comments this issue can be considered as low/informational.

@sherlock-admin sherlock-admin added Escalated This issue contains a pending escalation Non-Reward This issue will not receive a payout Escalation Resolved This issue's escalations have been approved/rejected and removed Escalated This issue contains a pending escalation Reward A payout will be made for this issue labels Jun 3, 2023
@sherlock-admin
Copy link
Contributor Author

Escalation accepted

Valid low
Based on the escalation and other comments this issue can be considered as low/informational.

This issue's escalations have been accepted!

Contestants' payouts and scores will be updated according to the changes made on this issue.

@ctf-sec ctf-sec removed the Escalated This issue contains a pending escalation label Jun 3, 2023
@hrishibhat hrishibhat removed the Medium A valid Medium severity issue label Jun 9, 2023
@sherlock-admin sherlock-admin added Low/Info A valid Low/Informational severity issue and removed Has Duplicates A valid issue with 1+ other issues describing the same vulnerability labels Jun 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Escalation Resolved This issue's escalations have been approved/rejected Low/Info A valid Low/Informational severity issue Non-Reward This issue will not receive a payout Sponsor Confirmed The sponsor acknowledged this issue is valid
Projects
None yet
Development

No branches or pull requests

6 participants