SC08:2025 - 整数オーバーフローとアンダーフロー (Integer Overflow and Underflow)
説明:
事例 (脆弱なコントラクト):
// SPDX-License-Identifier: MIT
pragma solidity ^0.4.17;
contract Solidity_OverflowUnderflow {
uint8 public balance;
constructor() public {
balance = 255; // Maximum value of uint8
}
// Increments the balance by a given value
function increment(uint8 value) public {
balance += value; // Vulnerable to overflow
}
// Decrements the balance by a given value
function decrement(uint8 value) public {
balance -= value; // Vulnerable to underflow
}
}
影響:
対策:
事例 (修正バージョン):
整数オーバーフローとアンダーフロー攻撃の被害を受けたスマートコントラクトの事例:
Last updated