oracle-manipulation
What it does
This playbook guides a review of price oracles in DeFi contracts. It is for auditors and developers who need to check that prices cannot be easily manipulated.
When to use it
- βWhen a lending or trading contract reads prices from a pool's current reserves.
- βWhen you want to confirm that a time-weighted price uses a long enough window.
- βWhen an oracle feed has no check for staleness or sequencer downtime.
Skill link
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/oracle-manipulation/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βCan you check whether our lending protocol's price feed could be moved by a large trade within one block?β
5 new skills a week. 1 minute to read.
How it works
The agent finds each price read, checks whether the source is a spot price or a longer average, and tests whether stale or zero values are rejected.
Technical content (original SKILL.md)
Original text by the author, straight from 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:
- Spot-price AMM oracle β
reserve1 / reserve0of a Uniswap V2 pool. Anyone with enough capital (or a flash loan) can push the price for one block. - Manipulable TWAP β short window TWAP, or TWAP over a low-liquidity pool.
- Single Chainlink feed without staleness check β feed returns 0 / stale β uses 0 in math.
- Custom oracle reading from manipulable storage β e.g., a "fair-price" oracle that reads
totalSupply()of an LP token alongside reserves. - 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: isupdatedAtvalidated? IsansweredInRound >= roundId? Isanswer > 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
FAQ
What makes a spot price risky?
It reflects the current pool balance, which a large trade can move temporarily.
What is a safer averaging window?
The playbook suggests a longer window, around 30 minutes or more, for a time-weighted price.
Why check for staleness?
A frozen or zero feed can make calculations use a wrong value.
Details
Original description by the author
Hunt single-block oracle manipulation β spot-price AMM oracles, manipulable TWAP, dependent calculations, missing staleness checks.
Popularity
- GitHub stars
- 6.5k
- Ranking position
- #14010
- License
- Apache-2.0
- Updated
- 11/1/2026
Comments
- β¦
More skills from this repository
detector-overview
6.5kHelps your agent read code that a scanner flagged and decide which flagged spots are real security bugs and which are false alarms.
exploiter-overview
6.5kHelps your agent join several confirmed security weaknesses into one test chain and check how far that chain could reach.
llm-redteam-overview
6.5kHelps your agent find the right AI red-team guide for a test, covering 15 tactic groups from prompt injection to model abuse.
aatmf-t01-prompt-injection
6.5kExplains prompt injection, where hidden instructions try to override an AI system, so security testers can check for it.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.