Closed c4-bot-6 closed 7 months ago
DadeKuma marked the issue as duplicate of #10
DadeKuma marked the issue as sufficient quality report
DadeKuma marked the issue as duplicate of #88
OpenCoreCH marked the issue as selected for report
OpenCoreCH marked issue #48 as primary and marked this issue as a duplicate of 48
OpenCoreCH changed the severity to 2 (Med Risk)
OpenCoreCH marked the issue as satisfactory
Lines of code
https://github.com/code-423n4/2024-03-acala/blob/main/src/modules/incentives/src/lib.rs#L230 https://github.com/code-423n4/2024-03-acala/blob/main/src/modules/incentives/src/lib.rs#L248
Vulnerability details
Impact
A malicious user can claim majority of the reward pool, by front-running and staking a large amount of LP tokens before the reward is accumulated (i.e accumulating period). Afterwards when the rewards gets accumulated and gets deposited to the pool, the malicious user can withdraw it. This guarentees that the malicious user will receive a majority chunk of the reward, than the rest of previously staked users. The user can use this method, to claim majority chunk of the reward pool for every reward accumulate period.
It also impacts the rest of the staked user. As they will lose maximum percent of their share of the reward.
Proof of Concept
Consider the scenerio below, and for simplicity, we will consider reward accumulated in single reward_currency
accumulate_incentives
function, and then stakedeposit_dex_share
, just before the AccumulatePeriodreward_inflation
variable by a significant amount, which in-turn will increase thetotal_reward
andtotal_withdrawn_reward
variable. Furthermorewithdrawn_reward
is also increased.total_reward
variable of the pool by the reward amount accumulated.withdraw_dex_share
function, with our staked LP token amount. This will return our staked LP token, along with the majority share of the reward, that was accumulated.Hence a direct POC is : deposit_dex_share(origin, lp_currency_id, amount) - where amount is a very large amount of LP tokens AccumulatePeriod starts and rewards get accumulated. total_reward of the pool increased withdraw_dex_share(origin, lp_currency_id, amount) - where amount is the staked LP token
User will now receive a larger share of the reward. I was able to get a 90% share of the reward using this vulnerability.
Tools Used
Manual review
Recommended Mitigation Steps
It is recommended to implement delays while staking and unstaking
Assessed type
Other