The last council member cannot claim his allocated TELCOIN after someone's token is burnt.
Summary
When burning a token, the last council member lost his balance, and cannot claim his allocated TELCOIN.
Vulnerability Detail
When burning a target tokenId, the balances of that tokenId will be cleared. It will be set to 0 in _withdrawAll, this is fine. But the tokenId is then poped from the balances array in the burn() function. Actually it is the last tokenId is poped, and the last tokenId's balance is set to the target tokenId. This creates a problem that the last tokenId's owner will lost his balance in balances array, and will not be able to claim his allocated TELCOIN.
ydlee
high
The last council member cannot claim his allocated TELCOIN after someone's token is burnt.
Summary
When burning a token, the last council member lost his balance, and cannot claim his allocated TELCOIN.
Vulnerability Detail
When burning a target
tokenId
, thebalances
of thattokenId
will be cleared. It will be set to 0 in_withdrawAll
, this is fine. But thetokenId
is then poped from thebalances
array in theburn()
function. Actually it is the lasttokenId
is poped, and the lasttokenId
's balance is set to the targettokenId
. This creates a problem that the lasttokenId
's owner will lost his balance inbalances
array, and will not be able to claim his allocated TELCOIN.https://github.com/sherlock-audit/2024-01-telcoin/blob/main/telcoin-audit/contracts/sablier/core/CouncilMember.sol#L210-L222
POC: The following test case can show the problem. Add the test case to
CouncilMember.test.ts#CouncilMember.tokenomics
and run it.The result of the test case is:
Impact
The last council member cannot claim his allocated TELCOIN after some other
tokenId
is burnt.Code Snippet
https://github.com/sherlock-audit/2024-01-telcoin/blob/main/telcoin-audit/contracts/sablier/core/CouncilMember.sol#L210-L222
Tool used
Manual Review
Recommendation
Do not pop
tokenId
frombalances
arrary while burning, i.e. remove the lines of CouncilMember.sol#L218-L220.Duplicate of #199