Amazon EventBridge を使用して Amazon Inspector の検出結果に対するカスタムレスポンスを作成する
Amazon Inspector は、新たに生成された検出結果や集計された検出結果に対して、Amazon EventBridge のイベントを作成します。Amazon Inspector は、検出結果の状態に対する変更のイベントも作成します。つまり、リソースの再起動やリソースに関連付けられているタグの変更などのアクションを実行すると、検出結果に関する新しいイベントが生成されます。Amazon Inspector が更新された検出結果の新しいイベントを作成すると、検出結果 id
は同じままになります。
注記
アカウントが Amazon Inspector の委任管理者アカウントである場合、EventBridge はお客様のアカウントと、イベントの発行元であるメンバーアカウントにイベントを発行します。
Amazon Inspector で EventBridge イベントを使用すると、タスクを自動化し、検出結果によって明らかになったセキュリティ上の問題に対応できるようになります。EventBridge イベントに基づいて Amazon Inspector の検出結果に関する通知を受け取るには、EventBridge ルールを作成し、Amazon Inspector のターゲットを指定する必要があります。EventBridge ルールにより、EventBridge は Amazon Inspector の検出結果通知を送信でき、ターゲットは通知の送信先を指定します。
Amazon Inspector は、現在 Amazon Inspector を使用している AWS リージョン のデフォルトのイベントバスにイベントを発行します。つまり、Amazon Inspector をアクティブ化し、EventBridge イベントを受け取るように Amazon Inspector を設定した各 AWS リージョンのイベントルールを設定する必要があります。Amazon Inspector は、ベストエフォートベースでイベントを発行します。
このセクションでは、イベントスキーマの例と、EventBridge ルールの作成方法について説明します。
イベントスキーマ
以下は、EC2 の検出結果イベントの Amazon Inspector イベントフォーマットの例です。他の検出結果タイプやイベントタイプのスキーマの例については、「Amazon Inspector イベントのAmazon EventBridge イベントスキーマ」を参照してください。
{ "version": "0", "id": "66a7a279-5f92-971c-6d3e-c92da0950992", "detail-type": "Inspector2 Finding", "source": "aws.inspector2", "account": "111122223333", "time": "2023-01-19T22:46:15Z", "region": "us-east-1", "resources": ["i-0c2a343f1948d5205"], "detail": { "awsAccountId": "111122223333", "description": "\n It was discovered that the sound subsystem in the Linux kernel contained a\n race condition in some situations. A local attacker could use this to cause\n a denial of service (system crash).", "exploitAvailable": "YES", "exploitabilityDetails": { "lastKnownExploitAt": "Oct 24, 2022, 11:08:59 PM" }, "findingArn": "arn:aws:inspector2:us-east-1:111122223333:finding/FINDING_ID", "firstObservedAt": "Jan 19, 2023, 10:46:15 PM", "fixAvailable": "YES", "lastObservedAt": "Jan 19, 2023, 10:46:15 PM", "packageVulnerabilityDetails": { "cvss": [{ "baseScore": 4.7, "scoringVector": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H", "source": "NVD", "version": "3.1" }], "referenceUrls": ["https://lore.kernel.org/all/CAFcO6XN7JDM4xSXGhtusQfS2mSBcx50VJKwQpCq=WeLt57aaZA@mail.gmail.com/", "https://ubuntu.com/security/notices/USN-5792-1", "https://ubuntu.com/security/notices/USN-5791-2", "https://ubuntu.com/security/notices/USN-5791-1", "https://ubuntu.com/security/notices/USN-5793-2", "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8423f0b6d513b259fdab9c9bf4aaa6188d054c2d", "https://ubuntu.com/security/notices/USN-5793-1", "https://ubuntu.com/security/notices/USN-5792-2", "https://ubuntu.com/security/notices/USN-5791-3", "https://ubuntu.com/security/notices/USN-5793-4", "https://ubuntu.com/security/notices/USN-5793-3", "https://git.kernel.org/linus/8423f0b6d513b259fdab9c9bf4aaa6188d054c2d(6.0-rc5)", "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-3303"], "relatedVulnerabilities": [], "source": "UBUNTU_CVE", "sourceUrl": "https://people.canonical.com/~ubuntu-security/cve/2022/CVE-2022-3303.html", "vendorCreatedAt": "Sep 27, 2022, 11:15:00 PM", "vendorSeverity": "medium", "vulnerabilityId": "CVE-2022-3303", "vulnerablePackages": [{ "arch": "X86_64", "epoch": 0, "fixedInVersion": "0:5.15.0.1027.31~20.04.16", "name": "linux-image-aws", "packageManager": "OS", "remediation": "apt update && apt install --only-upgrade linux-image-aws", "version": "5.15.0.1026.30~20.04.16" }] }, "remediation": { "recommendation": { "text": "None Provided" } }, "resources": [{ "details": { "awsEc2Instance": { "iamInstanceProfileArn": "arn:aws:iam::111122223333:instance-profile/AmazonSSMRoleForInstancesQuickSetup", "imageId": "ami-0b7ff1a8d69f1bb35", "ipV4Addresses": ["172.31.85.212", "44.203.45.27"], "ipV6Addresses": [], "launchedAt": "Jan 19, 2023, 7:53:14 PM", "platform": "UBUNTU_20_04", "subnetId": "subnet-8213f2a3", "type": "t2.micro", "vpcId": "vpc-ab6650d1" } }, "id": "i-0c2a343f1948d5205", "partition": "aws", "region": "us-east-1", "type": "AWS_EC2_INSTANCE" }], "severity": "MEDIUM", "status": "ACTIVE", "title": "CVE-2022-3303 - linux-image-aws", "type": "PACKAGE_VULNERABILITY", "updatedAt": "Jan 19, 2023, 10:46:15 PM" } }
Amazon Inspector の検出結果を通知する EventBridge ルールの作成
Amazon Inspector の検出結果の可視性を高めるために、EventBridge を使用して自動検出結果アラートを設定し、メッセージングハブに送信することができます。このトピックでは、E メール、Slack、または Amazon Chime に、CRITICAL
および HIGH
の重要度の検出結果に対するアラートを送信する方法を説明します。Amazon Simple Notification Service のトピックを設定し、EventBridge イベントルールに関連付ける方法を説明します。
ステップ 1. Amazon SNS トピックおよびエンドポイントの設定
自動アラートを設定するには、まず Amazon Simple Notification Service でトピックを設定し、エンドポイントを追加する必要があります。詳細については、「SNS ガイド」を参照してください。
この手順では、Amazon Inspector の検出結果データを送信したい場所を設定します。SNS トピックは、イベントルールの作成中または作成後に EventBridge イベントルールに追加できます。
ステップ 2. Amazon Inspector の検出結果の EventBridge ルールを作成する
-
自分の認証情報を使用してサインインします。
Amazon EventBridge コンソール (https://console.aws.amazon.com/events/
) を開きます。 -
ナビゲーションペインから [ルール] を選択し、[ルールの作成] を選択します。
-
ルールの名前と必要に応じて説明を入力します。
-
[イベントパターンを持つルール] を選択してから、[次へ] を選択します。
-
[イベントパターン] ペインで [カスタムパターン (JSON エディタ)] を選択します。
-
以下の JSON をエディタに貼り付けます。
{ "source": ["aws.inspector2"], "detail-type": ["Inspector2 Finding"], "detail": { "severity": ["HIGH", "CRITICAL"], "status": ["ACTIVE"] } }
注記
このパターンは、Amazon Inspector によって検出されたアクティブな
CRITICAL
またはHIGH
重要度の検出結果に関する通知を送信します。イベントパターンの入力が終了したら、[次へ] を選択します。
-
[ターゲットを選択] ページで、[AWS のサービス] を選択します。次に、[ターゲットタイプの選択] で [SNS トピック] を選択します。
-
[トピック] で、ステップ 1 で作成した SNS トピックの名前を選択します。次いで、[次へ] を選択します。
-
必要に応じてオプションのタグを追加し、[次へ] を選択します。
-
ルールを確認し、[ルールの作成] を選択します。
Amazon Inspector マルチアカウント環境の EventBridge
Amazon Inspector の委任された管理者である場合、EventBridge ルールはメンバーアカウントの該当する検出結果に基づいてアカウントに表示されます。前のセクションで説明したように、管理者アカウントの EventBridge を通じて検出結果通知を設定すると、複数のアカウントに関する通知が届きます。つまり、ご自身のアカウントで生成された結果とイベントに加え、メンバーアカウントによって生成された結果とイベントが通知されます。
結果の JSON 詳細から accountId
を使用して、Amazon Inspector の検出結果の元となったメンバーアカウントを特定することができます。