Part 2

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

Reentrancy Attack in Credit Delegation & Withdrawal Mechanism

Summary

A Reentrancy Attack exists in the Credit Delegation & Withdrawal Mechanism of the vault system. The vulnerability arises due to improper sequencing of state updates and external calls, allowing an attacker to recursively exploit credit delegation and drain excess funds.

Vulnerability Details

The vault manages credit delegation and collateralized assets, interacting with external markets, DEX swaps, and debt distribution systems. The issue occurs in the function recalculateVaultsCreditCapacity(), which modifies credit delegation values before fully completing state updates.

Affected Code:

creditDelegation.weight = newWeight;
market.updateTotalDelegatedCredit(creditDeltaUsdX18);
  1. The function first updates creditDelegation.weight.

  2. Only afterward, it calls market.updateTotalDelegatedCredit(creditDeltaUsdX18).

  3. If an attacker finds a way to recursively trigger this function (e.g., via external market contracts), they might artificially inflate their credit delegation weight.

  4. This could allow them to withdraw more than their legitimate credit, draining funds from the vault.

Impact

  • Funds Drain: Attackers can recursively manipulate credit delegation, withdrawing more than their actual deposited value.

  • Credit Inflation: They can artificially increase their borrowing power across connected markets.

  • System Instability: The exploit could lead to unintended credit distribution, potentially affecting overall liquidity.

Tools Used

  • Slither: For detecting reentrancy vulnerabilities.

  • Foundry/Hardhat: To simulate recursive execution and observe unintended balance changes.

  • Echidna: Fuzz testing to identify unintended state alterations.

Recommendations

  • Implement Reentrancy Guards (nonReentrant) on functions modifying credit delegation and withdrawal logic.

  • Ensure state updates occur before external calls to prevent manipulation.

  • Validate credit delegation limits before executing external transactions.

  • Use checks-effects-interactions pattern to ensure internal variables are finalized before external interactions.

Updates

Lead Judging Commences

inallhonesty Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Too generic

Support

FAQs

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