Part 2

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

Reentrancy Risk in claimFees

Summary

The claimFees function interacts with external contracts (e.g., IERC20) without implementing a reentrancy guard, exposing the contract to reentrancy attacks. This issue is critical because Zaros relies on secure fee distribution to maintain trust and maximize LP yields.


Vulnerability Details

  • The function calls IERC20(weth).safeTransfer, which could be exploited by a malicious token contract to re-enter the function.

  • Example Scenario:

    • A malicious contract calls claimFees.

    • During the fee transfer, the malicious contract re-enters claimFees before the state is updated, claiming fees multiple times.

  • This could drain the contract's WETH balance, leading to significant financial losses.


Impact

  • A reentrancy attack could drain the contract's funds, harming both the protocol and its users.

  • Such an attack would undermine trust in Zaros and disrupt its operations.

  • Insecure fee distribution would harm LPs' yield generation, contradicting Zaros's core goal.


Severity

  • **High **: This vulnerability allows attackers to potentially drain the contract's funds, posing a severe financial and operational risk to the protocol.


Tools Used

  • **Foundry **: Created test cases to simulate reentrancy attacks on the affected functions.

  • **Slither **: Identified unprotected external calls and flagged potential reentrancy risks.

  • **Echidna **: Fuzzed the contract to detect recursive call vulnerabilities.

  • **Mithril Security **: Conducted formal verification to ensure reentrancy guards were properly implemented.


Recommendations

  1. **Use OpenZeppelin's ReentrancyGuard **:

    • Add a reentrancy guard to prevent recursive calls:

  2. **Follow Checks-Effects-Interactions Pattern **:

    • Ensure all state changes occur before interacting with external contracts:

      uint256 fees = accumulatedFees[msg.sender];
      accumulatedFees[msg.sender] = 0; // State change first
      IERC20(token).transfer(msg.sender, fees); // External call last
Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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