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

In ERC20Quest withdrawFee can be called multiple times by anyone #501

Closed
code423n4 opened this issue Jan 30, 2023 · 2 comments
Closed

In ERC20Quest withdrawFee can be called multiple times by anyone #501

code423n4 opened this issue Jan 30, 2023 · 2 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-605 satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc20Quest.sol#L102

Vulnerability details

Impact

The withdrawFee function in Erc20Quest is used to transfer the protocolFee to protocolFeeRecipient . This function has access control issues. The modifier onlyAdminWithdrawAfterEnd only checks if the function is called before endTime or not and reverts if it is.

modifier onlyAdminWithdrawAfterEnd() {
        if (block.timestamp < endTime) revert NoWithdrawDuringClaim();
        _;
    } 

This function is missing the onlyOwner modifier.

Due to this issue, it can be called multiple times by anyone to transfer funds to the protocolFeeRecipient, and the legitimate users would not be able to claim their tokens as there won’t be sufficient funds in the contract anymore.

Even if the protocolFeeRecipient transfer funds back to this contract, a malicious user with an objective to not let users claim their tokens, can front-run their claim call to transfer funds back to the protocolFeeRecipient and get their transactions reverted.

POC

function withdrawFee() public onlyAdminWithdrawAfterEnd {
        IERC20(rewardToken).safeTransfer(protocolFeeRecipient, protocolFee()); //@audit anyone can call multiple times
    }

Recommendation Mitigation

Just add onlyOwner modifier.

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Jan 30, 2023
code423n4 added a commit that referenced this issue Jan 30, 2023
@c4-judge c4-judge closed this as completed Feb 6, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Feb 6, 2023

kirk-baird marked the issue as duplicate of #23

@c4-judge c4-judge added duplicate-587 satisfactory satisfies C4 submission criteria; eligible for awards and removed duplicate-23 labels Feb 14, 2023
@c4-judge
Copy link
Contributor

kirk-baird marked the issue as satisfactory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-605 satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

2 participants