Open code423n4 opened 1 year ago
MikeHathaway marked the issue as sponsor disputed
MikeHathaway marked the issue as sponsor acknowledged
Picodes marked the issue as satisfactory
ith-harvey marked the issue as sponsor disputed
That is by design and we acknowledge that documentation of bucket bankruptcy can be improved. When a bucket goes bankrupt (which shouldn't happen often but only when there's bad debt in pool to settle) the lender won't lose only their rewards but will also lose all the shares in that bucket / LP (which has higher impact than rewards). Also the recommendation of
On memorializePositions, check if the lender already claimed his/her rewards before zeroing out the previous tracked LP.
would imply making position manager contract aware of rewards manager contract and we don't want to couple those 2 in reference implementation. However, additional position and rewards manager could be developed by 3rd parties and could take into consideration this recommendation.
Lines of code
https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-core/src/PositionManager.sol#L192-L199
Vulnerability details
Impact
When the lender calls
PositionManager.memorializePositions
method the following happens:In point 1, it checks if there is a previous deposit and the bucket went bankrupt after prior memorialization, then it zero out the previous tracked LP. However, the lender could still have unclaimed rewards. In this case, the lender loses the rewards due to the lack of claiming rewards before zeroing out the previous tracked LP balance. If you check claim rewards functionality in RewardsManager, the bucket being not bankrupt is not a requirement. Please note that claiming rewards relies on the tracked LP balance in PositionManager.
Proof of Concept
PositionManager.memorializePositions
methodIn RewardsManager, check
claimRewards
and_claimRewards
method. there is no a check for bucket's bankruptcy.https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-core/src/RewardsManager.sol#L114
https://github.com/code-423n4/2023-05-ajna/blob/main/ajna-core/src/RewardsManager.sol#L561
Tools Used
Manual analysis
Recommended Mitigation Steps
On memorializePositions, check if the lender already claimed his/her rewards before zeroing out the previous tracked LP.
Assessed type
Other