Closed code423n4 closed 1 year ago
Related to #345 and #346 by the same warden
Picodes changed the severity to 2 (Med Risk)
MikeHathaway marked the issue as sponsor disputed
These aren't real attacks. If you move your tokens, you should get re stamped, and only earn interest from that point forward. This is by design, and is actually to avoid gaming the system, by joining buckets post hoc that earned interest
Picodes marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-core/src/RewardsManager.sol#L180
Vulnerability details
Impact
The
moveStakedLiquidity
function will updatetoBucket.rateAtStakeTime
to the current ExchangeRate every time.If an epoch is the first epoch for a position, the
bucketRate
isbucketSnapshot.rateAtStakeTime
, otherwise thebucketRate
is uniformlybucketExchangeRates[ajnaPool_][bucketIndex][epoch_]
. So in a certain epoch, the reward ratio of positions is the same in most cases. But for positions staked in this epoch, the reward rate is different and depends onrateAtStakeTime
.An attacker can use the
moveStakedLiquidity
function to updaterateAtStakeTime
to obtain the maximum reward ratio. This makes his reward potentially much higher than other positions in the epoch, and the excess is stolen from other user rewards.Proof of Concept
Tools Used
Manual review
Recommended Mitigation Steps
It is recommended to update the bucketRate according to the ratio of moved LP to original LP.
Assessed type
Other