It may be possible for a user to artificially increase their tracked liquidity right before claiming by rapidly entering/exiting positions. This could allow them to claim a larger % of rewards than they deserve.
Proof of Concept
The main risk of manipulating own liquidity accounting occurs in these functions:
function accrueConcentratedPositionTimeWeightedLiquidity(
address owner,
bytes32 poolIdx,
int24 lowerTick,
int24 upperTick
) internal {
// Loops through tick history and accumulates time * liquidity
// for the position's liquidity at each tick
}
function claimConcentratedRewards(
address owner,
bytes32 poolIdx,
// ...
) internal {
// Calls accrueConcentratedPositionTimeWeightedLiquidity
// Calculates and claims rewards
}
The issue arises because accrueConcentratedPositionTimeWeightedLiquidity can be called with no limitations on frequency.
This allows an attacker to exploit the accounting process as follows:
Attacker deposits a small amount of liquidity (ex: 10 ETH)
Over a 1 week period, attract little accounting rewards proportional to 10 ETH
Right before claiming rewards, rapidly exit position and re-deposit with 1000 ETH
This will register the 1000 ETH liquidity for the full week, instead of just the end
Claim rewards based on owning 1000 ETH for the full week
To prevent this manipulation, accrueConcentratedPositionTimeWeightedLiquidity should limit calls to once per 24 hours.
Tools Used
Vs
Recommended Mitigation Steps
A limit needs to be added on how often accrueConcentratedPositionTimeWeightedLiquidity can be called per position. For example, limiting it to once per day would make this attack infeasible.
Lines of code
https://github.com/code-423n4/2023-10-canto/blob/40edbe0c9558b478c84336aaad9b9626e5d99f34/canto_ambient/contracts/mixins/LiquidityMining.sol#L69-L154 https://github.com/code-423n4/2023-10-canto/blob/40edbe0c9558b478c84336aaad9b9626e5d99f34/canto_ambient/contracts/mixins/LiquidityMining.sol#L69-L154 https://github.com/code-423n4/2023-10-canto/blob/40edbe0c9558b478c84336aaad9b9626e5d99f34/canto_ambient/contracts/mixins/LiquidityMining.sol#L156-L196
Vulnerability details
Impact
It may be possible for a user to artificially increase their tracked liquidity right before claiming by rapidly entering/exiting positions. This could allow them to claim a larger % of rewards than they deserve.
Proof of Concept
The main risk of manipulating own liquidity accounting occurs in these functions:
accrueConcentratedPositionTimeWeightedLiquidity function
This function is called whenever a position is modified to accrue the time-weighted liquidity for reward calculations.
The issue is there is no check on the frequency of calls. An attacker could exploit this by:
accrueConcentratedPositionTimeWeightedLiquidity
liquidityaccounting
function accrueConcentratedPositionTimeWeightedLiquidity
function claimConcentratedRewards
The issue arises because
accrueConcentratedPositionTimeWeightedLiquidity
can be called with no limitations on frequency.This allows an attacker to exploit the accounting process as follows:
Attacker deposits a small amount of liquidity (ex: 10 ETH)
Over a 1 week period, attract little accounting rewards proportional to 10 ETH
Right before claiming rewards, rapidly exit position and re-deposit with 1000 ETH
Call
accrueConcentratedPositionTimeWeightedLiquidity
This will register the 1000 ETH liquidity for the full week, instead of just the end
Claim rewards based on owning 1000 ETH for the full week
To prevent this manipulation,
accrueConcentratedPositionTimeWeightedLiquidity
should limit calls to once per 24 hours.Tools Used
Vs
Recommended Mitigation Steps
A limit needs to be added on how often
accrueConcentratedPositionTimeWeightedLiquidity
can be called per position. For example, limiting it to once per day would make this attack infeasible.Assessed type
Timing