Erc20Quest.withdrawRemainingTokens
after withdrawFee
can revert
#585
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-122
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/rabbitholegg/quest-protocol/tree/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc20Quest.sol#L81-L87
https://github.com/rabbitholegg/quest-protocol/tree/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc20Quest.sol#L102-L104
Vulnerability details
Impact
An attacker can run
Erc20Quest.withdrawFee
beforewithdrawRemainingTokens
, and as a result,withdrawRemainingTokens
can revert.Proof of Concept
In
Erc20Quest.withdrawRemainingTokens
, the admin leftprotocolFee() + unclaimedTokens
in the contract. It means that it assumeswithdrawFee()
will be called afterwithdrawRemainingTokens()
.But in fact, anyone can call
withdrawFee
after the quest's end time. So if an attacker callswithdrawFee
before the admin callswithdrawRemainingTokens
,withdrawRemainingTokens
will revert.Tools Used
Manual Review
Recommended Mitigation Steps
withdrawFee
should be called only once, and in the implementation ofwithdrawRemainingTokens
, ifwithdrawFee
is called before, no need to leaveprotocolFee()
.The text was updated successfully, but these errors were encountered: