Inspectorとは
Amazon Inspectorは自動化されたセキュリティ評価サービスで、AWS上にデプロイされた アプリケーションに脆弱性やベストプラクティスからの逸脱などがないかを自動的に評価 し、重大性の順に項目を並べた結果リストの作成を行う。このサービスを利用することで、EC2への意図しないネットワークアクセスや脆弱性をチェックすることができ、アプリケーションのセキュリティとコンプライアンスを向上することができる Inspectorを使用することで、システムの脆弱性診断を自動化できる。
エージェント
Inspectorを使用する前に、サポートしているOS, リージョン等を確認する。また、対象のEC2インスタンスにInspectorエージェントをインストールする。インストールの際にはroot権限が必要で、System Managersの AmazonInspector-ManageAWSAgent ドキュメントを実行することで、リモートからエージェントをインストールすることも可能である。また、エージェントをインストールしたインスタンスは、テレメトリデータのやりとりのために、Inspectorのエンドポイントと通信できるようにする必要がある。なお、エージェントプログラムに更新が発生する場合は、自動的に適用されるため、手動による管理は不要 。
Inspectorが評価を行う対象のインスタンスは、評価ターゲット で規定する。タグベースで指定 することも、 全てのインスタンスを指定 することもできる。
評価とルールパッケージ
Amazon Inspectorは、指定されたターゲット内のリソースから動作や設定データを収集し、これらの情報と指定されたルールパッケージとの比較を行う。ターゲットのEC2にエージェントをインストールすることで、これらの動作を実行することが可能となる。また、ネットワーク到達可能性ルールパッケージに関しては、エージェントレスで評価を実行することができる。
指定したルールには重要度が規定されており、重要度の大きな順から、 High , Medium , Low , Informational の4つのレベルが定められている。ルールパッケージは、
- ネットワーク到達可能性
- 共通脆弱性識別子
- Center for Internet Security (CIS) ベンチマーク
- Amazon Inspector のセキュリティのベストプラクティス
の4つのルールパッケージに分類されており、どのパッケージを適用するか指定することができる。これらのルールは、 CloudWatch Eventsなどから指定した時刻に起動 することも、手動で評価を開始することもできる。
結果とモニタリング
評価後の結果には、奨励される対応策 も記述される。何らかの理由で対処できない問題については、結果から除外することもできる。
Amazon Inspector のセットアップ
CloudRrailはCloudFormationに対応しているため、CloudFormation経由でAmazon Inspectorをセットアップすることができる。
サービスにリンクされたロール と IAMロールの作成
Amazon Inspector
で使用する Service-Linked Role
と IAM Role
を作成する。
Resources: ServiceLinkedRoleForInspector: Type: AWS::IAM::ServiceLinkedRole DeletionPolicy: Retain Properties: AWSServiceName: inspector.amazonaws.com Description: A service-linked role required for Amazon Inspector to access your resources. IAMRoleForInspectorEvents: Type: 'AWS::IAM::Role' Properties: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: events.amazonaws.com Action: 'sts:AssumeRole' Description: A role required for CloudWatch Events to access Inspector. Policies: - PolicyName: !Sub 'DefaultSecuritySettings-AWSEventsInspectorPolicy-${AWS::Region}' PolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Action: - 'inspector:StartAssessmentRun' Resource: '*' RoleName: !Sub 'DefaultSecuritySettings-InspectorEvents-${AWS::Region}'
Amazon Inspectorの有効化
Amazon Inspector
の Assessment Target
と Assessment Template
を作成する。
- Network Reachability
- Common Vulnerabilities and Exposures
- Center for Internet Security (CIS) Benchmarks
- Security Best Practices for Amazon Inspector
本テンプレートは、上記の4つのルールパッケージに対応する。なお、AWSが公開しているルールパッケージのURLがリージョンごとに異なることから、本テンプレートは、Amazon Inspector
に対応しているリージョンのうち、一部のリージョンのみに対応していることに留意する。
Resources: InspectorAssessmentTarget: DependsOn: - ServiceLinkedRoleForInspector Type: AWS::Inspector::AssessmentTarget Properties: AssessmentTargetName: DefaultSecuritySettings-Assessment-Target-All-Instances-All-Rules InspectorAssessmentTemplate: Type: AWS::Inspector::AssessmentTemplate Properties: AssessmentTargetArn: !GetAtt InspectorAssessmentTarget.Arn DurationInSeconds: 3600 AssessmentTemplateName: DefaultSecuritySettings-Assessment-Template-Default-All-Rules RulesPackageArns: # Asia Pacific (Tokyo)リージョンの場合 - arn:aws:inspector:ap-northeast-1:406045910587:rulespackage/0-gHP9oWNT - arn:aws:inspector:ap-northeast-1:406045910587:rulespackage/0-7WNjqgGu - arn:aws:inspector:ap-northeast-1:406045910587:rulespackage/0-YI95DVd7 - arn:aws:inspector:ap-northeast-1:406045910587:rulespackage/0-bBUQnxMq
CloudWatch Events を設定
Amazon Inspector
は、CloudWatch Events
を用いてAssessment Template
を定期実行することができる。本テンプレートでは毎週月曜日午前9時になると、CloudWatch Events
がAmazon Inspector
を定期実行する。
Resources: CloudWatchEventsForInspector: Type: AWS::Events::Rule Properties: Description: !Join - '' - - Scheduled Inspector Assessment for - !GetAtt InspectorAssessmentTemplate.Arn - running every 7 day(s) Name: Amazon_Inspector_Assessment # Every Monday 9AM ScheduleExpression: cron(0 9 ? * 1 *) State: ENABLED Targets: - Arn: !GetAtt InspectorAssessmentTemplate.Arn Id: CloudWatchEventsForInspector RoleArn: !GetAtt IAMRoleForInspectorEvents.Arn
CloudFormation Launch Stack URL
以下のボタンから上のCloudFormationテンプレートを実行することが可能である。ソースコードは、aws-cloudformation-templates/security – GitHub にて公開。
作成されるAWSサービス | CloudFormationテンプレート |
---|---|
セキュリティサービス全般 | ![]() |
Inspector のみ | ![]() |