Platform: Code4rena
Start Date: 13/11/2023
Pot Size: $24,500 USDC
Total HM: 3
Participants: 120
Period: 4 days
Judge: 0xTheC0der
Id: 306
League: ETH
Rank: 31/120
Findings: 1
Award: $207.11
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Krace
Also found by: 0xAadi, 0xpiken, AS, D1r3Wolf, PENGUN, SpicyMeatball, Yanchuan, bin2chen, d3e4, ether_sky, glcanvas, immeas, lanrebayode77, leegh, mojito_auditor, rvierdiiev, tnquanghuy0512
207.1122 USDC - $207.11
https://github.com/code-423n4/2023-11-canto/blob/main/1155tech-contracts/src/Market.sol#L156-L159
In the buy function, the fee which is split amount the stake holders is being restricted not for the self. It is being done by changing the rewardsLastClaimedValue
of user to current shareHolderRewardsPerTokenScaled
In the remaining functions (sell, mint, burn), the updated shareHolderRewardsPerTokenScaled
is being considered for rewardsSinceLastClaim
calculation, and the rewardsLastClaimedValue
of user is being updated with the used shareHolderRewardsPerTokenScaled
.
Whereas in buy
function, the rewardsLastClaimedValue
value of user is being updated to current shareHolderRewardsPerTokenScaled
, with using that value for reward calculation at the start (which is main cause of this issue.)
So the users portion of fees which should be claimed by considering the current shareHolderRewardsPerTokenScaled
is not going that user and those funds are getting locked forever.
Lets take the current state of the Market's share values as
Now that user (0x1) is depositing 100 ETH to get 1000 more tokens. Now in buy function link rewardsSinceLastClaim = 0 _splitFees(_id, 5 ETH, 1000)
rewardsLastClaimedValue[_id][msg.sender] = shareData[_id].shareHolderRewardsPerTokenScaled;
The shareHolderRewardsPerTokenScaled is directly override into the rewardsLastClaimedValue, without claiming the rewards using the shareHolderRewardsPerTokenScaled value.There are two solution for this:
buy fee
to old holder shares of the same user.buy fee
to old holder shares of the same user is big concern, then subtract the tokensByAddress[_id][msg.sender]
value from totalCirculation
for _splitFees
function call in buy
function._splitFees(_id, fee, totalCirculation);``` ## Assessed type DoS
#0 - c4-pre-sort
2023-11-18T04:11:35Z
minhquanym marked the issue as duplicate of #302
#1 - c4-judge
2023-11-28T22:39:43Z
MarioPoneder changed the severity to 2 (Med Risk)
#2 - c4-judge
2023-11-28T22:40:32Z
MarioPoneder marked the issue as satisfactory
#3 - c4-judge
2023-11-28T23:54:05Z
MarioPoneder marked the issue as duplicate of #9