oracle-manipulation
Skill này làm gì
Playbook này hướng dẫn rà soát các oracle giá trong hợp đồng DeFi. Playbook dành cho kiểm toán viên và lập trình viên cần kiểm tra giá không dễ bị thao túng.
Khi nào nên dùng
- ✓Khi một hợp đồng cho vay hoặc giao dịch đọc giá từ số dư hiện tại của pool.
- ✓Khi bạn muốn xác nhận một giá trung bình theo thời gian dùng cửa sổ đủ dài.
- ✓Khi một nguồn oracle không kiểm tra độ cũ dữ liệu hoặc thời gian ngừng hoạt động của sequencer.
Liên kết skill
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/oracle-manipulation/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể kiểm tra xem nguồn giá của giao thức cho vay của chúng tôi có thể bị thay đổi bởi một giao dịch lớn trong một khối không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent tìm mọi lần đọc giá, kiểm tra nguồn là giá tức thời (spot) hay trung bình dài hơn, rồi kiểm tra xem các giá trị cũ hoặc bằng không có bị từ chối không.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Điều gì làm giá tức thời rủi ro?
Nó phản ánh số dư pool hiện tại, và một giao dịch lớn có thể làm thay đổi nó tạm thời.
Cửa sổ trung bình an toàn hơn là bao lâu?
Playbook gợi ý cửa sổ dài hơn, khoảng 30 phút trở lên, cho giá trung bình theo thời gian.
Vì sao phải kiểm tra độ cũ?
Nguồn bị đóng băng hoặc bằng không có thể khiến phép tính dùng giá trị sai.
Chi tiết
Mô tả gốc của tác giả
Hunt single-block oracle manipulation — spot-price AMM oracles, manipulable TWAP, dependent calculations, missing staleness checks.
Độ phổ biến
- Sao GitHub
- 6.5k
- Vị trí xếp hạng
- #14010
- Giấy phép
- Apache-2.0
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
detector-overview
6.5kGiúp agent của bạn đọc code mà một công cụ quét đã đánh dấu, rồi quyết định điểm nào là lỗ hổng bảo mật thật và điểm nào là báo động giả.
exploiter-overview
6.5kGiúp agent của bạn ghép nhiều lỗ hổng bảo mật đã xác nhận thành một chuỗi kiểm thử và kiểm tra chuỗi đó có thể gây hậu quả đến đâu.
llm-redteam-overview
6.5kGiúp agent của bạn tìm đúng hướng dẫn red-team AI cho một bài kiểm thử, bao quát 15 nhóm chiến thuật từ prompt injection đến lạm dụng mô hình.
aatmf-t01-prompt-injection
6.5kGiải thích prompt injection, khi các chỉ dẫn ẩn cố ghi đè một hệ thống AI, để chuyên gia bảo mật có thể kiểm tra lỗi này.
Skill tương tự
reverse-engineer-anything
422kGiúp agent của bạn xem bên trong các app và package đã phát hành để giải thích tính năng, so sánh phiên bản hoặc hướng dẫn dựng lại bằng công cụ REA.
1password
394kGiúp agent của bạn cài đặt CLI của 1Password, đăng nhập, và đọc hoặc đưa thông tin bí mật vào mà không in giá trị ra cuộc trò chuyện.
healthcheck
394kGiúp agent của bạn rà soát bảo mật máy tính hoặc máy chủ đang chạy OpenClaw, như SSH, tường lửa, cập nhật và sao lưu, rồi đề xuất cách sửa an toàn.