GuardDuty Findings (アラート)を EventBridge でフィルタリングする
目次
概要
やりたいこと
GuardDuty アラートを Slack への通知している。 EventBridge + SNS + Chatbot で行っている。
GuardDuty 委任管理者を利用している。
GuardDuty委任管理者を利用すると、各メンバーアカウントの GuardDuty の設定変更ができなくなり、GuardDuty へ抑制ルールを設定できなくなる。
そのため、アラートのフィルタリングを EventBridge で行う。
EventBridge ルール
AWS イベントのイベント形式のサンプルが下記。
これらのイベントにマッチするルールを作成してルーティングするのが EventBridge の役割。
{ "version": "0", "id": "6a7e8feb-b491-4cf7-a9f1-bf3703467718", "detail-type": "EC2 Instance State-change Notification", "source": "aws.ec2", "account": "111122223333", "time": "2017-12-22T18:43:48Z", "region": "us-west-1", "resources": [ "arn:aws:ec2:us-west-1:123456789012:instance/i-1234567890abcdef0" ], "detail": { "instance-id": " i-1234567890abcdef0", "state": "terminated" } }
この detail が AWS サービスごとに異なる。
GuardDuty の場合 findings のイベント形式は下記?
GuardDuty のイベントにマッチするマッチングパターンの基本は以下。
{ "source": [ "aws.guardduty" ], "detail-type": [ "GuardDuty Finding" ], "detail": { "severity": [ { "numeric": [ ">=", 7 ] } ] } }
基本以外のマッチングパターンは以下を参照。
例えば「以外」のマッチングをしたい場合、 anything-but を利用し、マッチしたら通知しないフィルタリングする。
{ "detail": { "state": [ { "anything-but": [ "stopped", "overloaded" ] } ] } }
CloudFormation
EventBridge のブラックリスト追加
タイプ「UnauthorizedAccess:EC2/RDPBruteForce」のみマッチするパターン。
GuardDutyRule: Type: AWS::Events::Rule Properties: Name: dmm-sec-GuardDuty-Finding-To-Slack Description: "This Rule was created by Security Team." EventPattern: !Sub | { "source": ["aws.guardduty"], "detail-type": ["GuardDuty Finding"], "detail": { "type": ["UnauthorizedAccess:EC2/RDPBruteForce"], "severity": [ {"numeric": [">=", ${SeverityThreshold}]} ] } } State: 'ENABLED' Targets: - Arn: !Ref GuardDutyTopic Id: GuardDutySNSTopic
インスタンス「i-99999999」のアラートのみマッチするパターン。
GuardDutyRule: Type: AWS::Events::Rule Properties: Name: dmm-sec-GuardDuty-Finding-To-Slack Description: "This Rule was created by Security Team." EventPattern: !Sub | { "source": ["aws.guardduty"], "detail-type": ["GuardDuty Finding"], "detail": { "resource": { "instanceDetails": { "instanceId":["i-99999999"] } }, "severity": [ {"numeric": [">=", ${SeverityThreshold}]} ] } } State: 'ENABLED' Targets: - Arn: !Ref GuardDutyTopic Id: GuardDutySNSTopic
EventBridge のホワイトリスト追加
タイプ「UnauthorizedAccess:EC2/RDPBruteForce」以外のアラートにマッチするパターン。
GuardDutyRule: Type: AWS::Events::Rule Properties: Name: dmm-sec-GuardDuty-Finding-To-Slack Description: "This Rule was created by Security Team." EventPattern: !Sub | { "source": ["aws.guardduty"], "detail-type": ["GuardDuty Finding"], "detail": { "type": [ {"anything-but": "UnauthorizedAccess:EC2/RDPBruteForce"} ], "severity": [ {"numeric": [">=", ${SeverityThreshold}]} ] } } State: 'ENABLED' Targets: - Arn: !Ref GuardDutyTopic Id: GuardDutySNSTopic
インスタンス「i-99999999」以外ののアラートのみマッチするパターン。
※サンプル生成の場合一つもマッチされない
GuardDutyRule: Type: AWS::Events::Rule Properties: Name: dmm-sec-GuardDuty-Finding-To-Slack Description: "This Rule was created by Security Team." EventPattern: !Sub | { "source": ["aws.guardduty"], "detail-type": ["GuardDuty Finding"], "detail": { "resource": { "instanceDetails": { "instanceId":[ {"anything-but": "i-99999999"} ] } }, "severity": [ {"numeric": [">=", ${SeverityThreshold}]} ] } } State: 'ENABLED' Targets: - Arn: !Ref GuardDutyTopic Id: GuardDutySNSTopic
OR パターンしかできない?
「UnauthorizedAccess:EC2/RDPBruteForce」かつ「i-99999999」の場合のみマッチしない、というパターンを作りたい。
しかし EventBridge で AND パターンを定義できないかも。。
GuardDuty の抑制ルールの代替としては使えない。。
参考
Creating custom responses to GuardDuty findings with Amazon CloudWatch Events
ディスカッション
コメント一覧
まだ、コメントがありません