サービス拒否のテスト (Testing for Denial of Service (DoS))
説明
例: ユーザー入力による無制限ループ
pragma solidity ^0.8.0;
contract GasDoSVulnerable {
mapping(address => uint256) public balances;
// Allows a user to send tokens to many recipients in one transaction.
function bulkTransfer(address[] memory recipients, uint256[] memory amounts) public {
require(recipients.length == amounts.length, "Invalid input");
for (uint256 i = 0; i < recipients.length; i++) {
require(amounts[i] > 0, "Amount must be greater than zero");
balances[recipients[i]] += amounts[i];
}
}
}影響
対策
効率的なループと関数の設計 (Efficient Loop and Function Design):
フォールバックメカニズム (Fallback Mechanisms):
レート制限とリソース管理 (Rate Limiting and Resource Management):
エラー処理 (Error Handling):
テスト 1: 無制限ループを検出する
目的
脆弱なコード:
なぜ脆弱なのか
チェック方法
修正されたコード:
テスト 2: 非効率なネストされたループを特定する
目的
脆弱なコード:
なぜ脆弱なのか
チェック方法
Previous算術と論理のセキュリティのテスト (Testing Arithmetic and Logic Security)Nextブロックチェーンデータと状態管理のテスト (Testing Blockchain Data and State Management)
Last updated