Protection seller will lose unlocked capital if it fails to claim during more than one period
dec3ntraliz3d Follow with VAD37, Koolex and 6 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-02-carapace-judging/issues/142
Found by
dec3ntraliz3d, VAD37, Koolex, bin2chen, MalfurionWhitehat, XKET, Tricko, immeas, jkoppel
Summary
The protection seller will lose unlocked capital if it fails to claim during more than one period.
Vulnerability Detail
The function DefaultStateManager._calculateClaimableAmount, used by DefaultStateManager.calculateAndClaimUnlockedCapital, which in turn is used by ProtectionPool.claimUnlockedCapital, overrides the claimable unlocked capital on every loop iteration on the lockedCapitals array.
As a result, only the last snapshot is returned by this function, regardless if the protection seller has claimed the unlocked capital or not. The purpose of this code was to prevent sellers from claiming the same snapshot twice, but since the _claimableUnlockedCapital variable is being overwritten instead of incremented, on each loop iteration, it will also make sellers lose unlocked capital if they fail to claim at each snapshot.
Proof of concept:
- Pool goes to locked state with snapshotId 1
- Pool goes to active state
- Pool goes to locked state with snapshotId 2
- Pool goes to active state
- Protection seller calls
ProtectionPool.claimUnlockedCapital, but they will only receive what's due from snapshotId 2, not from snapshotId 1
Impact
The protection seller will lose unlocked capital if it fails to claim during more than one period.
Code Snippet
Tool used
Manual Review
Recommendation
Increment _claimableUnlockedCapital for all locked capital instances.
Discussion
vnadoda
@clems4ev3r PR for the fix is: https://github.com/carapace-finance/credit-default-swaps-contracts/pull/62
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.
What is known
A high-severity business logic bug in Carapace. Sherlock made it public on 11 March 2023. Found in the 40 audit contest (finding H-6), also found by 8 other wardens.
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
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.