Skip to content
Business logic Audit finding Intermediate

User can game protection via renewal to get free insurance

The renewal function did not check the amount of protection being renewed, allowing a user to renew for more protection than originally purchased. An attacker could exploit this to obtain full insurance coverage while paying a minimal premium.

rvierdiiev Follow with KingNFT, libratus and 5 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-02-carapace-judging/issues/293

Found by

rvierdiiev, KingNFT, libratus, jkoppel, minhtrng, 0Kage, monrel, 0x52

Summary

When renewing a position, the new protectionAmount can be higher than what was previously bought. A user can abuse this to get insurance for free. Most of the time they would keep the protection amount at 1 and pay virtually no premium. Since late payments can be seen very far in advance they would simply renew their insurance at the max value of token right before the borrower was officially late and gain the full protection.

Vulnerability Detail

https://github.com/sherlock-audit/2023-02-carapace/blob/main/contracts/libraries/ProtectionPoolHelper.sol#L383-L398

When evaluating if a user can renew their insurance only the time, token and lending contract are verified. It never checks the amount of protection that the user is renewing for. This can be abused to renew for MORE protection than originally bought. A user could abuse this to renew right before there was a late payment for the full amount of protection.

They can abuse another quirk of the renewal system to make sure they they are always able to renew at any time. Since a user is allowed to open an unlimited number of positions on a single LP token they can open a large number of positions with 1 protection amount. They would space out each protection to expire exactly with the grace period. The results it that they would be able to renew any position at a moments notice.

They would abuse this by choosing to renew their protection for the max value of the token right before a payment was officially late. This would allow them to collect a full repayment while paying basically nothing in premium.

Impact

User can get full protection for free

Code Snippet

https://github.com/sherlock-audit/2023-02-carapace/blob/main/contracts/core/pool/ProtectionPool.sol#L176-L195

Tool used

Manual Review

Recommendation

When renewing protection, the user should only be allowed to renew up to the value of their expired insurance

Discussion

vnadoda

@clems4ev3r what's the basis for the following claim? How would a buyer know abt late payment in advance? "Since late payments can be seen very far in advance they would simply renew their insurance at the max value of token right before the borrower was officially late and gain the full protection." Cc @taisukemino

clems4ev3r

@clems4ev3r what's the basis for the following claim? How would a buyer know abt late payment in advance? "Since late payments can be seen very far in advance they would simply renew their insurance at the max value of token right before the borrower was officially late and gain the full protection." Cc @taisukemino

I think this is possible due to the fact that any user can go fetch lending pool status from goldfinch directly. So they are aware of state changes not yet triggered on Carapace and can adjust their positions accordingly

vnadoda

@clems4ev3r what's the basis for the following claim? How would a buyer know abt late payment in advance? "Since late payments can be seen very far in advance they would simply renew their insurance at the max value of token right before the borrower was officially late and gain the full protection." Cc @taisukemino

I think this is possible due to the fact that any user can go fetch lending pool status from goldfinch directly. So they are aware of state changes not yet triggered on Carapace and can adjust their positions accordingly

Yeah, buyers can't see far in the future, but even early knowledge of the late payment by a couple of hours can be exploited.

We are planning to fix this issue. @taisukemino

vnadoda

@clems4ev3r PR for this fix is: https://github.com/carapace-finance/credit-default-swaps-contracts/pull/56

when you review fix PRs, please do it in sequence, they are created as I am creating a new fix branch on top of the previous fix branch to avoid merge conflicts. Cc @hrishibhat

clems4ev3r

Fix looks good

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

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 renewal logic only verified the time, token, and lending contract, but failed to validate that the renewed protection amount did not exceed the original amount.

Impact

A user could obtain full protection for free, paying only a minimal premium.

What the attacker needed

Access to the protocol; ability to open multiple positions; monitor lending pool status

The fix

The renewal function should be changed to only allow renewing up to the value of the expired insurance; a fix PR was created and reviewed.

How it was found

  1. Open many small protection positions (amount 1) on the same LP token, spaced so one expires near the grace period.
  2. Monitor the lending pool status directly to detect an impending late payment.
  3. Renew a position for the maximum token value just before the payment is officially late.
  4. Collect full protection payout while having paid minimal premium.

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.

Insurance protects against a borrower failing to repay. The system lets you renew a policy, but it didn't check if you were renewing for the same amount or a larger one. So someone could buy a tiny policy, then renew it for a huge amount just before a default, getting big protection for almost no cost.

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 rvierdiiev

View all

72 more disclosed reports, best first.

More from Carapace

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.