Closed sherlock-admin2 closed 7 months ago
This is actually a valid issue. I introduced a PR that removed unnecessary functionality but that additionally erroneously introduced this bug that only account holders can stop earning on their own account. Originally it was supposed to be that anybody can stop earning on an account that is no longer in the earners list.
It is actually a valid issue since as the watson mentioned, stopEarning()
is only callable by the earner itself and if he is removed from the TTG Registrar earner list, he has no incentive to call this function.
The issue has been fixed in this PR by adding stopEarning(address account)
that is callable by anyone:
https://github.com/MZero-Labs/protocol/pull/162
1 comment(s) were left on this issue during the judging contest.
takarez commented:
valid; medium(2)
araj
high
ApprovedEarner
can still earnEarnerRate
even after removal fromEARNERS_LIST
Summary
ApprovedEarner
can still earnEarnerRate
even after removal fromEARNERS_LIST
as there is no way to stop aRemovedEarner
from earning.Vulnerability Detail
Only
approvedEarners
are can earn theearnerRate
by callingMToken::startEarning()
which checks an Earner is approved(ie inEARNERS_LIST
) or not & mark isEarning = trueTo stop earning
EarnerRate
, Earner needs to callMToken::stopEarning()
which sets isEarning = falseBut the problem is, when an Earner is removed from
EARNERS_LIST
, it's on EarnerGoodwill
to callMToken::stopEarning()
as this function stops onlycaller
of this functions iemsg.sender
from earningEarnerRate
(ie isEarning = false).There is no other way to stop an
RemovedEarner
from earningEarnerRate
.//Here is the POC
Impact
RemovedEarner
will keep earningEarnerRate
foreverCode Snippet
https://github.com/sherlock-audit/2023-10-mzero/blob/main/protocol/src/MToken.sol#L100
https://github.com/sherlock-audit/2023-10-mzero/blob/main/protocol/src/MToken.sol#L106C4-L108C6
https://github.com/sherlock-audit/2023-10-mzero/blob/main/protocol/src/MToken.sol#L262C2-L288C6
https://github.com/sherlock-audit/2023-10-mzero/blob/main/protocol/src/MToken.sol#L294C2-L318C6
Tool used
Manual Review
Recommendation
Take
address
as parameter instopEarning()
, check if address is removed fromEARNERS_LIST
& also check that address is earningDuplicate of #33