Saltar al contenido
Skillpedia
Seguridad6,5 mil · #14010

oracle-manipulation

Qué hace

Esta guía orienta la revisión de los oráculos de precios en contratos DeFi. Está pensada para auditores y desarrolladores que necesitan comprobar que los precios no se pueden manipular fácilmente.

Cuándo usarla

  • ✓Cuando un contrato de préstamos o de intercambio lee precios de las reservas actuales de un pool.
  • ✓Cuando quieres confirmar que un precio ponderado por tiempo usa una ventana lo bastante larga.
  • ✓Cuando un feed de oráculo no comprueba si el dato está desactualizado o si el secuenciador está caído.

Link de la skill

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/oracle-manipulation/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/oracle-manipulation/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“¿Puedes comprobar si el feed de precios de nuestro protocolo de préstamos podría moverse con una operación grande dentro de un solo bloque?”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

El agente encuentra cada lectura de precio, comprueba si la fuente es un precio puntual o un promedio más largo, y prueba si se rechazan los valores desactualizados o cero.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

Oracle Manipulation Playbook

DeFi protocols that read a price from an on-chain source are vulnerable when the source can be moved within a single transaction or block. Classic vectors:

  1. Spot-price AMM oracle — reserve1 / reserve0 of a Uniswap V2 pool. Anyone with enough capital (or a flash loan) can push the price for one block.
  2. Manipulable TWAP — short window TWAP, or TWAP over a low-liquidity pool.
  3. Single Chainlink feed without staleness check — feed returns 0 / stale → uses 0 in math.
  4. Custom oracle reading from manipulable storage — e.g., a "fair-price" oracle that reads totalSupply() of an LP token alongside reserves.
  5. L2 sequencer offline — L2 oracles need a "is sequencer up?" check or attacker can exploit when sequencer downs and feeds freeze.

Audit steps

1. Locate price-reading code

# Common patterns
grep -rn 'getReserves\|getAmountsOut\|getPriceFromSqrtPriceX96\|latestAnswer\|latestRoundData' src/

# Custom oracle reads
grep -rn 'IPriceOracle\|getPrice\|consult' src/

2. Trace each price use

For each call:

  • Is the price read from a Uniswap V2 / Sushi / Camelot pool's reserves? → spot price = manipulable
  • Is the price read from a Uniswap V3 pool's slot0.sqrtPriceX96? → manipulable
  • Is it a Uniswap V3 TWAP via OracleLibrary.consult? → check the secondsAgo window (>= 1800s = 30 min is the safe minimum)
  • Is it a Chainlink latestRoundData() call? → check: is updatedAt validated? Is answeredInRound >= roundId? Is answer > 0? Are L2 sequencer feeds checked?

3. Validate staleness handling

// MISSING — vulnerable
(, int256 price, , , ) = priceFeed.latestRoundData();

// GOOD — explicit staleness + sequencer
(uint80 roundId, int256 price, , uint256 updatedAt, uint80 answeredInRound) = priceFeed.latestRoundData();
require(price > 0, "ORACLE_NEGATIVE");
require(updatedAt > block.timestamp - MAX_DELAY, "ORACLE_STALE");
require(answeredInRound >= roundId, "ORACLE_OLD_ROUND");
// On L2: also check sequencer uptime feed (L2 SequencerUptimeFeed)

4. Trace the price's use

The bug isn't oracle-reading — it's oracle-trusting. Find where the price drives a state change:

  • Liquidation thresholds
  • Collateral valuation
  • Borrow limits
  • Swap output amounts (slippage check)
  • LP token pricing for vaults

PoC via Foundry

Flash-loan price push (Uniswap V2 reserves)

// Pseudo:
contract Test_oracle is Test {
    function test_manipulate() public {
        // 1. Flash-loan WETH from Aave / Balancer / Uniswap V3
        // 2. Swap WETH → token in target pool, draining one side
        // 3. Reserves now skewed → spot price way off
        // 4. Call vulnerable protocol's price-dependent function
        //    (e.g., borrow USDC against overvalued collateral)
        // 5. Reverse the swap, repay flash loan
        // 6. Profit = whatever was extracted in step 4
        assertGt(USDC.balanceOf(attacker), 0, "should profit");
    }
}

Decepticon helper:

foundry_oracle_test(target="LendingPool", price_feed="UniV2Pair",
                    token0="WETH", token1="TARGETTOKEN", target_path="src/LendingPool.sol")

Chainlink stale check missing

function test_stale_price() public {
    // mock the feed to return updatedAt that's 24h old
    vm.mockCall(
        address(priceFeed),
        abi.encodeWithSignature("latestRoundData()"),
        abi.encode(uint80(1), int256(STALE_PRICE), uint256(0), block.timestamp - 86400, uint80(1))
    );

    // call function — should revert if staleness checked, should proceed if not
    target.priceDependentFunction();
    // If we reach here w/o revert → bug
}

Severity calibration

Manipulation surface Typical impact Severity
Spot-price oracle drives liquidation Drain LPs via fake liquidations Critical
Spot-price drives borrow limit Borrow more than collateral worth Critical
TWAP < 30 min Still manipulable on low-liquidity pairs High
TWAP 30 min+ on high-liquidity ETH-USDC Hard to exploit profitably Medium-Low
Missing staleness check, but feed updates often Edge-case impact during outages Medium
L2 sequencer not checked Exploitable during sequencer downtime High (timing-dependent)

CVSS

  • Spot-oracle + flash-loan available + drains protocol: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H = 10.0 (Crit)
  • 30-min TWAP on illiquid pair: 7-8 (High)
  • Missing staleness + Chainl
Preguntas frecuentes

¿Qué hace arriesgado un precio puntual?

Refleja el saldo actual del pool, que una operación grande puede mover temporalmente.

¿Qué ventana de promedio es más segura?

La guía sugiere una ventana más larga, de unos 30 minutos o más, para un precio ponderado por tiempo.

¿Por qué comprobar si el dato está desactualizado?

Un feed congelado o a cero puede hacer que los cálculos usen un valor erróneo.

Detalles

Descripción original del autor

Hunt single-block oracle manipulation — spot-price AMM oracles, manipulable TWAP, dependent calculations, missing staleness checks.

repo: BitterSecurity/Decepticon

Popularidad

Estrellas en GitHub
6,5 mil
Posición en el ranking
#14010
Licencia
Apache-2.0
Actualizada
1/11/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas