Part 2

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

Reentrancy Risks

Summary

https://github.com/Cyfrin/2025-01-zaros-part-2/blob/39e33b2f6b3890573bb1affc41a7e520277ceb2c/src/market-making/branches/FeeDistributionBranch.sol#L82

https://github.com/Cyfrin/2025-01-zaros-part-2/blob/39e33b2f6b3890573bb1affc41a7e520277ceb2c/src/market-making/branches/FeeDistributionBranch.sol#L27

https://github.com/Cyfrin/2025-01-zaros-part-2/blob/39e33b2f6b3890573bb1affc41a7e520277ceb2c/src/market-making/branches/FeeDistributionBranch.sol#L284

The FeeDistributionBranch contract exhibits several potential vulnerabilities, with reentrancy risks being among the most critical. These vulnerabilities arise from the contract's reliance on external calls, lack of input validation, and insufficient safeguards against malicious behaviors. Addressing these issues is crucial to prevent the exploitation of the contract and to ensure its safe operation in a production environment.

Vulnerability Details

The contract interacts with external contracts, such as IERC20 tokens and DEX adapters, without implementing safeguards against reentrancy attacks.

Affected Functions:

receiveMarketFee: Invokes IERC20.safeTransferFrom for asset transfers.

claimFees: Calls IERC20.safeTransfer to distribute rewards.

_performMultiDexSwap: Executes swaps through DEX adapters, which may call back maliciously.

Reason: Reentrancy can occur if a token contract or DEX adapter is compromised and invokes the contract during an external call, potentially causing unauthorized state changes.

Impact

Unauthorized Asset Drains: Attackers could repeatedly call vulnerable functions to withdraw assets or fees beyond their entitlement.

State Corruption: Reentrant calls may leave the contract in an inconsistent or invalid state.

Ecosystem Risk: If exploited, the contract could compromise user funds and diminish trust in the protocol.

Tools Used

slither

Recommendations

contract FeeDistributionBranch is ReentrancyGuard {
function receiveMarketFee(address asset, uint256 amount, address market)
external
onlyRegisteredEngine
nonReentrant
{
// Function logic
}
}
Updates

Lead Judging Commences

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

Support

FAQs

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