SC03:2023 - タイムスタンプの依存性 (Timestamp Dependence)
説明:
事例:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract DiceRoll {
uint256 public lastBlockTime;
constructor() payable {}
function rollDice() external payable {
require(msg.value == 5 ether, "Must send 5 ether to play"); // Player must send 5 ether to play
require(block.timestamp != lastBlockTime, "Only 1 transaction per block allowed"); // Ensures only 1 transaction per block
lastBlockTime = block.timestamp;
// Player wins if the last digit of the block timestamp is less than 5
if (block.timestamp % 10 < 5) {
(bool sent,) = msg.sender.call{value: address(this).balance}("");
require(sent, "Failed to send Ether");
}
}
}影響:
対策:
PreviousSC02:2023 - 整数オーバーフローとアンダーフロー (Integer Overflow and Underflow)NextSC04:2023 - アクセス制御の脆弱性 (Access Control Vulnerabilities)
Last updated