Dividend reward can be gamed
The dividend reward mechanism in the Router contract can be manipulated by an attacker who makes small trades to reset the average fee to zero, then generates a fee to claim half of the daily allocation repeatedly, draining the reserve.
Submitted by cmichel
The Router.addDividend function tells the reserve to send dividends to the pool depending on the fees.
- The attacker provides LP to a curated pool. Ideally, they become a large LP holder to capture most of the profit, they should choose the smallest liquidity pool as the dividends are pool-independent.
- The
normalAverageFeevariable that determines the pool dividends can be set to zero by the attacker by trading a single wei in the poolarrayFeeSize(20) times (usebuyTo). The fees of the single wei trades will be zero and thus thenormalAverageFeewill also be zero as, seeaddTradeFee. - The attacker then does a trade that generates some non-zero fees, setting the
normalAverageFeeto this trade’s fee. ThefeeDividendis then computed as_fees * dailyAllocation / (_fees + normalAverageFee) = _fees * dailyAllocation / (2 * _fees) = dailyAllocation / 2. Half of thedailyAllocationis sent to the pool. - The attacker repeats the above steps until the reserve is almost empty. Each time the
dailyAllocationgets smaller but it’s still possible to withdraw almost all of it. - They redeem their LP tokens and gain a share of the profits
The reserve can be emptied by the attacker.
Counting only the last 20 trades as a baseline for the dividends does not work. It should probably average over a timespan but even that can be gamed if it is too short. I think a better idea is to compute the dividends based on volume traded over a timespan instead of looking at individual trades.
verifyfirst (Spartan) acknowledged:
Only very deep pools will be curated for dividends. Variables can be changed reactively to alter the dividends. Whilst we were aware of this and feel the attack is limited its sparked some discussion for some new ideas to solve this.
Keeping high risk as the report is valid
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the dividend calculation uses a manipulable average fee based on only the last 20 trades, which an attacker can reset to zero with zero-fee trades and then set to a chosen value, causing the dividend to be half of the daily allocation regardless of actual fees.
Impact
The reserve can be emptied by the attacker, though the program acknowledged the attack is limited because only very deep pools will be curated for dividends.
What the attacker needed
Attacker provides liquidity to a curated pool; pool has small liquidity; attacker can make many small trades
The fix
The dividends should be computed based on volume traded over a timespan instead of looking at individual trades.
How it was found
- The attacker provides liquidity to a curated pool, preferably a small one to capture most of the profit.
- The attacker makes 20 tiny trades of one wei each to set the normalAverageFee to zero.
- The attacker makes a trade that generates non-zero fees, setting normalAverageFee to that fee.
- The attacker receives half of the dailyAllocation as dividend.
- The attacker repeats the above steps until the reserve is almost empty.
- The attacker redeems their LP tokens and gains a share of the profits.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract pays out dividends to liquidity providers based on recent trading fees. An attacker can trick the contract into paying out much more than intended by making tiny trades that reset the fee average, then making one trade that sets the average to a known value, allowing them to claim half of the daily reward repeatedly. This drains the reserve that holds the rewards.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.