Skip to content

Security: Critical Vulnerability - Oracle Manipulation (No TWAP) #233

Description

@keteng86

Vulnerability: Oracle Manipulation via Spot Price (No TWAP)

Severity: HIGH to CRITICAL

Summary

The DeXe Protocol's PriceFeed contract uses spot price from PancakeSwap V2/V3 without any Time-Weighted Average Price (TWAP) protection. This allows attackers to manipulate prices via flash loans in a single transaction.

Affected Files

  • contracts/libs/price-feed/UniswapPathFinder.sol (Lines 221-222, 249-255)
  • contracts/core/PriceFeed.sol

Vulnerability Details

The PriceFeed contract uses direct spot price queries:

  • router.getAmountsOut() for V2
  • quoter.quoteExactInputSingle() for V3

Without TWAP protection, these prices can be manipulated via flash loans.

Attack Vector

  1. Flash loan large amount from Aave/PancakeSwap
  2. Swap to manipulate pool reserves
  3. Call PriceFeed.getNormalizedPriceOutUSD()
  4. Protocol uses manipulated price
  5. Profit in same transaction

Impact

  • Token purchases at 90%+ discount
  • Voting power inflation 1000x+
  • Reward pool draining
  • Unfair liquidations

Proof of Concept

Deployed contract: 0xc7730074736c10ed0d3F928A10Ee4162DA9a7983 on BSC

Recommended Fix

  1. Implement TWAP with 30-minute minimum window
  2. Add price deviation bounds (max 5% per block)
  3. Consider using Chainlink oracle
  4. Add time delay between queries

References

  • Similar exploit: Mango Markets ($100M+ loss)
  • Best practice: Uniswap V3 TWAP implementation

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions