Protection buyer may buy multiple protections for same goldfinch NFT
The Carapace protocol only checked that a single protection did not exceed the loan's remaining principal, but allowed a buyer to purchase multiple protections for the same Goldfinch NFT. An attacker could overprotect a loan position to claim more than they lent on default, or lock all protocol funds to prevent new protections.
Source: https://github.com/sherlock-audit/2023-02-carapace-judging/issues/112
Found by
libratus, jkoppel, ctf_sec, bin2chen, minhtrng, modern_Alchemist_00, clems4ever, immeas, 0Kage, c7e7eff, chaduke, Allarious, 0x52, __141345__
Summary
The Carapace protocol checks that a protection buyer does not buy a protection for an amount greater than the remainingPrincipal in the corresponding loan. However it possible for the buyer to buy multiple different protections for the same Goldfinch loan.
Vulnerability Detail
The check for the possibility for a user to buy a protection is done here in ReferenceLendingPools.canBuyProtection:
https://github.com/sherlock-audit/2023-02-carapace/blob/main/contracts/core/pool/ReferenceLendingPools.sol#L132-L168
It checks the protection about to be created does not cross remaining principal. But it still allows the user to create multiple protections for the same loan position.
Impact
The malicious user can overprotect their loan position on Goldfinch and thus claim a larger amount on loan default than what they lended. For now as the default claiming feature is not implemented, they can use this bug to DOS the protocol by using all funds deposited into the protocol reaching leverageRatioFloor and not allowing any new protections to be bought.
Code Snippet
Tool used
Manual Review
Recommendation
Keep track of the total protection subscribed for a given loan and limit total protection value to remaining capital
Discussion
vnadoda
@clems4ev3r this is duplicate of #193 & #139
hrishibhat
Sponsor comment from #193:
Double buying of protections for the same NFT is a known issue and we were planning to tackle it in an upcoming version because even after buying multiple protections buyers won't be able to claim for the same position as default payout will require NFT lock/transfer in the carapace vault.
This double counting of locked capital issue seems a legit concern. Now we are considering fixing this with other audit issues.
vnadoda
@clems4ev3r PR for this fix: https://github.com/carapace-finance/credit-default-swaps-contracts/pull/59
clems4ev3r
Fix looks good
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 protocol checked each protection individually against the remaining principal but did not track the total protection already purchased for a given loan.
Impact
A malicious user could overprotect their loan position and claim more than they lent on default, or currently use all deposited funds to reach the leverage ratio floor and block new protections, causing a denial of service.
What the attacker needed
A Goldfinch loan position; ability to buy protections
The fix
The fix was to track the total protection subscribed for a given loan and limit the total protection value to the remaining capital.
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 protection is like insurance on a loan: you pay a premium and get paid if the borrower defaults. The protocol checked each insurance policy separately against the loan amount, but never added up all policies for the same loan. So someone could buy several policies on one loan and potentially claim more than they should.
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.