-
Notifications
You must be signed in to change notification settings - Fork 2
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
Funds can be stuck due to wrong order of operations #122
Comments
kirk-baird marked the issue as duplicate of #42 |
kirk-baird marked the issue as not a duplicate |
kirk-baird marked the issue as duplicate of #61 |
kirk-baird marked the issue as satisfactory |
kirk-baird marked the issue as selected for report |
waynehoover marked the issue as disagree with severity |
While I agree that this is an issue, but not a high risk issue. I expect a high risk issues to be issues that can be called by anyone, not owners. As owners there are plenty of ways we can sabotage our contracts (for example via the set* functions) it is an issue for an owner. The owner understands how these functions work, so they can be sure to call them in the right order. |
I agree with the sponsor that since this is an The likelihood of this issue is reduced as it can only be called by the owner. Note: the ineffective |
kirk-baird changed the severity to 2 (Med Risk) |
Lines of code
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc20Quest.sol#L102-L104
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc20Quest.sol#L81-L87
Vulnerability details
Impact
The contract
ERC20Quest.sol
has two functions of interest here. The first iswithdrawFee()
, which is responsible for transferring out the fee amount from the contract once endTime has been passed, and the second iswithdrawRemainingTokens()
which recovers the remaining tokens in the contract which haven't been claimed yet.Function
withdrawRemainingTokens()
:As evident from this excerpt, calling this recovery function subtracts the tokens which are already assigned to someone who completed the quest, and the fee, and returns the rest. However, there is no check for whether the fee has already been paid or not. The owner is expected to first call
withdrawRemainingTokens()
, and then callwithdrawFee()
.However, if the owner calls
withdrawFee()
before calling the functionwithdrawRemainingTokens()
, the fee will be paid out by the first call, but the same fee amount will still be kept in the contract after the second function call, basically making it unrecoverable. Since there are no checks in place to prevent this, this is classified as a high severity since it is an easy mistake to make and leads to loss of funds of the owner.Proof of Concept
This can be demonstrated with this test
Even though the fee is paid, the contract still retains the fee amount. The owner receives less than the expected amount. This test is a modification of the test
should transfer non-claimable rewards back to owner
already present inERC20Quest.spec.ts
.Tools Used
Hardhat
Recommended Mitigation Steps
Only allow fee to be withdrawn after the owner has withdrawn the funds.
The text was updated successfully, but these errors were encountered: