SC08:2023 - 安全でないランダム性 (Insecure Randomness)
説明:
事例 :
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract InsecureRandomNumber {
constructor() payable {}
function guess(uint256 _guess) public {
uint256 answer = uint256(
keccak256(
abi.encodePacked(block.timestamp, block.difficulty, msg.sender) // Using insecure mechanisms for random number generation
)
);
if (_guess == answer) {
(bool sent,) = msg.sender.call{value: 1 ether}("");
require(sent, "Failed to send Ether");
}
}
}影響:
対策:
安全でないランダム性攻撃の被害を受けたスマートコントラクトの事例:
Last updated