SC02:2025 - 価格オラクル操作 (Price Oracle Manipulation)
説明:
事例 (脆弱なコントラクト):
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IPriceFeed {
function getLatestPrice() external view returns (int);
}
contract PriceOracleManipulation {
address public owner;
IPriceFeed public priceFeed;
constructor(address _priceFeed) {
owner = msg.sender;
priceFeed = IPriceFeed(_priceFeed);
}
function borrow(uint256 amount) public {
int price = priceFeed.getLatestPrice();
require(price > 0, "Price must be positive");
// Vulnerability: No validation or protection against price manipulation
uint256 collateralValue = uint256(price) * amount;
// Borrow logic based on manipulated price
// If an attacker manipulates the oracle, they could borrow more than they should
}
function repay(uint256 amount) public {
// Repayment logic
}
}影響:
対策:
事例 (修正バージョン):
価格オラクル操作攻撃の被害を受けたスマートコントラクトの事例:
Last updated