Quest owner of Erc1155Quest contract can withdraw all reward tokens after the Quest ends, resulting in loss to unclaimed users #275
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-528
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc1155Quest.sol#L54-L63
Vulnerability details
Impact
withdrawRemainingTokens() function allows the withdrawal of the whole Erc1155Quest contract balance. This means any users who haven't yet claimed their rewards will be unable to do so resulting in a
fund loss
.Proof of Concept
withdrawRemainingTokens
function looks like this:You can see that the amount withdrawn is given by
IERC1155(rewardToken).balanceOf(address(this), rewardAmountInWeiOrTokenId)
which is the contract balance for that particular tokenId.If some users haven't claimed their rewards yet, they will be unable to do so after the
withdrawRemainingTokens
is called.In the
Erc20Quest
contract the withdrawRemainingTokens function calculates thenonClaimableTokens
which is the allowed amount of tokens to withdraw. A similar logic should be applied, but is missing in the 1155 contract.Tools Used
VS code, Manual analysis
Recommended Mitigation Steps
I suggest, the
nonClaimableTokens
to be calculated and adjusted when calculating how much tokens to withdraw after Quest ends. The logic from Erc20Quest contract can be used here as well.The text was updated successfully, but these errors were encountered: