SC09:2023 - ガス制限の脆弱性 (Gas Limit Vulnerabilities)
説明:
事例 :
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract TokenTransfer {
mapping(address => uint256) public balances;
function transfer(address _to, uint256 _amount) public {
require(balances[msg.sender] >= _amount, "Insufficient balance");
for (uint256 i = 0; i < _amount; i++) { // The loop iterates _amount times, which can be very inefficient and can potentially exceed the block gas limit if _amount is too large.
balances[msg.sender]--;
balances[_to]++;
}
}
}影響:
対策:
PreviousSC08:2023 - 安全でないランダム性 (Insecure Randomness)NextSC10:2023 - チェックされていない外部呼び出し (Unchecked External Calls)
Last updated