Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: high
Valid

Locked Capacity Check Not Working

Summary

The VaultRouterBranch::redeem function is used to redeem a given amount of index tokens in exchange for collateral assets from the provided vault, after the withdrawal delay period has elapsed. In the end it has a check trying to ensure that there is enough unlocked credit capacity of the vault so it doesn't leave it insolvent. However, that check is broken.

Vulnerability Details

The VaultRouterBranch::redeem function is used to redeem a given amount of index tokens in exchange for collateral assets from the provided vault, after the withdrawal delay period has elapsed. In the end it has a check trying to ensure that there is enough unlocked credit capacity of the vault so it doesn't leave it insolvent. However, that check is broken.

if (
ctx.creditCapacityBeforeRedeemUsdX18.sub(vault.getTotalCreditCapacityUsd()).lte(
ctx.lockedCreditCapacityBeforeRedeemUsdX18.intoSD59x18()
)
) {
revert Errors.NotEnoughUnlockedCreditCapacity();
}

Let's have the following situation:

  1. creditCapacityBeforeRedeemUsdX18 is 50000

  2. vault.getTotalCreditCapacityUsd() is 10000

  3. lockedCreditCapacityBeforeRedeemUsdX18 is 20000

  4. creditCapacityBeforeRedeemUsdX18 - vault.getTotalCreditCapacityUsd() is 40000

    This means that 10000 are still left which is less than the locked capacity of 20000

  5. However, the check is not working correctly and the transaction will not revert

Impact

This check is used to ensure that the vault can continue operating with its markets and not be left insolvent. With it being broken the vault can become insolvent or not have enough locked capacity needed to operate with its connected markets.

Tools Used

Manual Review

Recommendations

Change the check to this one:

if (
vault.getTotalCreditCapacityUsd().lt(
ctx.lockedCreditCapacityBeforeRedeemUsdX18
)
) {
revert Errors.NotEnoughUnlockedCreditCapacity();
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

The check in VaultRouterBranch::redeem should be comparing remaining capacity against required locked capacity not delta against locked capacity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.