Part 2

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

In StabilityBranch.sol there is lack of Re-entrancy Protection for External Token Transfers

Summary

The contract performs external token transfers (e.g., via safeTransferFrom) without a re-entrancy guard. If the token contract is nonstandard or maliciously designed, it could trigger a callback and re-enter the swap function, potentially causing state inconsistencies.

Vulnerability Details

An abstraction of the vulnerable section:

function executeSwap() {
// Critical state updates are performed.
updateSwapState();
// Then an external call is made without a re-entrancy guard.
token.safeTransferFrom(vault.indexToken, address(this), amountOut + protocolReward);
// Further processing continues...
}

Impact

  • Re-entrancy Attacks: A malicious token contract could re-enter the function during the external call and manipulate the state or drain funds.

  • Unexpected Behavior: The absence of guards may lead to double spending, faulty fee calculations, or collateral mismanagement.

Tools Used

  • Manual review

  • Re-entrancy analysis tools

  • Static analysis

Recommendations

  • Implement Re-entrancy Guard: Add a standard nonReentrant modifier (using OpenZeppelin’s ReentrancyGuard) around functions performing external calls.

  • Order of Operations: Ensure that all critical state changes are made before any external call and consider using a Checks-Effects-Interactions pattern.

Updates

Lead Judging Commences

inallhonesty Lead Judge 10 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.

Give us feedback!