Modifying the loan term setting can default existing loans
The protocol's liquidation check uses the current global loan term setting rather than the term agreed when a position was created. If an admin reduces the loan term, existing positions can be liquidated earlier than their original terms allowed.
Submitted by adriro, also found by immeas, bin2chen, and ladboy233
Protocol admins can modify the loan term settings. This action can inadvertently default existing loans created under different terms.
Impact
Positions in the Particle LAMM protocol are created for a configurable period of time, defined by the LOAN_TERM variable. If the loan exceeds this duration, and the LP owner stops renewals that affect their position, the lien can be liquidated.
358: // check for liquidation condition
359: ///@dev the liquidation condition is that
360: /// (EITHER premium is not enough) OR (cutOffTime > startTime AND currentTime > startTime + LOAN_TERM)
361: if (
362: !((closeCache.tokenFromPremium < liquidateCache.tokenFromOwed ||
363: closeCache.tokenToPremium < liquidateCache.tokenToOwed) ||
364: (lien.startTime < lps.getRenewalCutoffTime(lien.tokenId) &&
365: lien.startTime + LOAN_TERM < block.timestamp))
366: ) {
367: revert Errors.LiquidationNotMet();
368: }
The liquidation condition in line 365 does the check using the current value of LOAN_TERM. As the loan term can be updated using updateLoanTerm(), this means that reducing this value may inadvertently cause the liquidation of existing positions that were originally intended for a longer period of time.
Proof of concept
Let’s say the current configured loan term in ParticlePositionManager is 2 weeks.
- A user creates a new position, expecting it to last at least 2 weeks.
- The owner of the LP calls
reclaimLiquidity()to stop it from being renewed. - The protocol changes the loan term setting to 1 week.
- The user is liquidated after 1 week.
Recommendation
Store the loan term value at the time the position was created in the Lien structure, e.g. in lien.loanTerm. When checking the liquidation condition, calculate the end time using this value to honor the original loan term.
if (
!((closeCache.tokenFromPremium < liquidateCache.tokenFromOwed ||
closeCache.tokenToPremium < liquidateCache.tokenToOwed) ||
(lien.startTime < lps.getRenewalCutoffTime(lien.tokenId) &&
- lien.startTime + LOAN_TERM < block.timestamp))
+ lien.startTime + lien.loanTerm < block.timestamp))
) {
revert Errors.LiquidationNotMet();
}
wukong-particle (Particle) acknowledged and commented:
Hmm we are reluctant to add more data into
lienstruct because we want to restrict it to be less than 3uint256. This can only be affected by contract level update ofLOAN_TERM, which should be quite rare (controlled by governance in the future).
Hmm we are reluctant to add more data into
lienstruct because we want to restrict it to be less than 3uint256. This can only be affected by contract level update ofLOAN_TERM, which should be quite rare (controlled by governance in the future).I don’t understand the concern here. Is this just gas? Loading
LOAN_TERMwill also require loading a word from storage. In any case, even if this is gov controlled, given enough protocol activity it will be difficult to update the setting without conflicting with existing loans.
wukong-particle (Particle) commented:
Yeah mostly gas concern. Adding loan term in the storage increases gas for opening/closing/liquidating the position.
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
The liquidation condition reads the current global LOAN_TERM instead of a per-position loan term stored when the position was created.
What the attacker needed
Protocol admin changes loan term; LP owner stops renewals; existing position
The fix
The loan term should be stored per position at creation and used in the liquidation check, though the protocol was reluctant to add storage due to gas concerns.
How it was found
- A user creates a new position expecting it to last at least 2 weeks.
- The owner of the LP calls `reclaimLiquidity()` to stop it from being renewed.
- The protocol changes the loan term setting to 1 week.
- The user is liquidated after 1 week.
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 loan term is how long a borrower has before they must repay or renew. The contract checks this using a single setting that applies to all loans, so changing that setting also changes the deadline for loans already open. That means an admin change can make old loans overdue sooner than the borrower expected.
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.