Skip to content
Business logic Audit finding Intermediate

The lender could possibly lose unclaimed rewards in case a bucket goes bankrupt

When a lender calls memorializePositions after a bucket has gone bankrupt, the contract zeroes out the tracked LP balance, which also removes the basis for claiming any unclaimed rewards. The lender could therefore lose rewards that they would otherwise have been able to claim.

Koolex Follow

Originally disclosed on Code4rena

Submitted by Koolex

When the lender calls PositionManager.memorializePositions method the following happens:

  1. Records bucket indexes along with its deposit times and lpBalances
  2. Transfers LP ownership from the lender to PositionManager contract.

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

Recommended Mitigation Steps

On memorializePositions, check if the lender already claimed his/her rewards before zeroing out the previous tracked LP.

ith-harvey (Ajna) disputed

grandizzy (Ajna) commented:

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.


The original report as published on Code4rena, by Koolex. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 position manager zeroes the tracked LP balance on bankruptcy without first allowing the lender to claim accrued rewards, and the rewards manager relies on that same tracked balance.

Impact

The lender could lose unclaimed rewards when a bucket goes bankrupt; the project states this is by design and that the lender also loses all shares in that bucket, which has higher impact.

What the attacker needed

Lender has memorialized positions; bucket goes bankrupt; lender has unclaimed rewards

The fix

The project disputed the finding as by design and said coupling the position manager to the rewards manager is undesirable, though third-party implementations could add a check that rewards were claimed before zeroing the tracked LP.

How it was found

  1. The lender memorializes positions, recording bucket indexes, deposit times and LP balances.
  2. The bucket goes bankrupt after the prior memorialization.
  3. The lender calls memorializePositions again; the contract detects the bankruptcy and zeroes the previous tracked LP.
  4. The lender's unclaimed rewards are lost because claiming depends on the tracked LP balance.

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 lender deposits into a bucket and earns rewards. If that bucket later goes bankrupt, the position manager resets the lender's recorded balance to zero. Because reward claims depend on that recorded balance, the lender can no longer claim rewards they had earned before the bankruptcy.

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.

More by Koolex

View all

10 more disclosed reports, best first.

More from Ajna Protocol

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.