亚姆琳斯
在您的 AWS 组织和账户中获取可见度 。 使用您实际的 AWS IAM 策略( 下载通过 收集地图)并评价有效权限.
目录
快速启动
# Install
npm install -g @actsecurity/iam-collect @actsecurity/iam-lens
# Download all IAM policies in your account using default credentials, run download once per account
iam-collect init
iam-collect download
# Simulate a request
iam-lens simulate --principal arn:aws:iam::123456789012:role/ExampleRole --resource arn:aws:s3:::example-bucket/secret-file.txt --action s3:GetObject
# Find out who can do something
iam-lens who-can --resource arn:aws:s3:::example-bucket --actions s3:ListBucket
# Find out who can do all actions on a resource
iam-lens who-can --resource arn:aws:s3:::example-bucket
什么是亚姆琳斯?
亚姆琳斯 让你 模拟 财务报告和审定财务报表 审计 对您从 AWS 账户中收集的 IAM 数据(通过 收集地图并了解适用于本金或资源的有效许可.
为什么用它?
- 明白了吗 实际权限.
- 校验 在所有政策实施之后,允许和拒绝结果.
- 发现 每一个可以访问给定资源的主 .
- 审计 在所有 AWS 账户和 Org 中组合复杂的政策 .
- 调试 没有部署或网络呼叫的当地复杂条件.
开始
- 下载您的策略 与 收集地图 从您的 AWS 账户获取所有政策。 iam-collection是高度可塑的,可以定制来收集所需的政策. 它只下载信息到您的文件系统或一个S3桶,所以你完全控制了自己的数据.
npm install -g @actsecurity/iam-collect
iam-collect init
iam-collect download
要看到 SCP 和 RCP 的效果,您应该从您的管理账户下载数据;或者允许下载组织信息的账户. 为您要分析的成员账户下载数据 . iam-lens 如果有数据,将分析交叉账户和跨组织的请求.
您可下载您喜欢的账户、组织和地区的信息。 数据越多 答案就越准确.
- 安装 iam- lens
npm install -g @actsecurity/iam-lens
- 执行命令 与
iam-lens模拟请求,发现权限,并审计您的 IAM 政策.
模拟请求 :
iam-lens simulate \
--principal arn:aws:iam::123456789012:role/ExampleRole \
--resource arn:aws:s3:::example-bucket/secret-file.txt \
--action s3:GetObject
或者说
发现可以在资源上执行动作的人 :
iam-lens who-can \
--resource arn:aws:iam::111111111111:role/ImportantRole \
--actions sts:AssumeRole iam:PassRole
图标
simulate - 模拟请求
评价本金是否能够在资源上执行指定的动作(或只记通配符动作). 返回决定 : Allowed, (中文(简体) ), ImplicitlyDenied,或 ExplicitlyDenied全部数据 条件密钥 得到支持,并 许多上下文密钥自动设定。 。 。 .
# Simple simulate: can this role list objects in the bucket?
iam-lens simulate \
--principal arn:aws:iam::111111111111:role/MyRole \
--resource arn:aws:s3:::my-bucket \
--action s3:ListBucket
# Simulate a wildcard action (ListAllMyBuckets) – normal simulation uses the principal's account
iam-lens simulate \
--principal arn:aws:iam::222222222222:user/Alice \
--action s3:ListAllMyBuckets
# Include custom context keys
iam-lens simulate \
--principal arn:aws:iam::333333333333:role/DevRole \
--resource arn:aws:sqs:us-east-1:333333333333:my-queue \
--action sqs:SendMessage \
--context aws:SourceVpc vpc-1234567890abcdef0 \
--verbose
# Assert the result must be “Allowed”; exit code will be nonzero if not
iam-lens simulate \
--principal arn:aws:iam::444444444444:role/ReadOnly \
--resource arn:aws:dynamodb:us-east-1:444444444444:table/Books \
--action dynamodb:Query \
--expect Allowed
# Simulate unsigned access to a concrete resource ARN
iam-lens simulate \
--anonymous \
--resource arn:aws:s3:::public-bucket/report.txt \
--action s3:GetObject
# Simulate an administrator principal outside the dataset, without SCPs
iam-lens simulate \
--external-principal \
--principal arn:aws:iam::999999999999:role/ExternalRole \
--resource arn:aws:s3:::example-bucket/report.txt \
--action s3:GetObject
# Simulate access to a resource outside the dataset
iam-lens simulate \
--external-resource \
--principal arn:aws:iam::444444444444:role/ReadOnly \
--resource arn:aws:s3:::external-bucket/report.txt \
--resource-account 999999999999 \
--action s3:GetObject
这些变体明确了它们的假设:
- 无名 请求没有身份政策、会话政策、许可边界或SCP。 需要资源 ARN( 支持 wildcard 资源模式), 但不需要收集资源; 指定
--resource-account当它不能被推断的时候, 无法提供主上下文密钥 。 现有的资源政策,RCP,VPC端点政策以及收集的S3控制仍然适用. - 外部主笔 请求从未收账的账户中创建一个本金模型,其中包含一个合成的允许所有身份政策,没有权限边界或SCP。 届会政策和收集的资源方控制仍然适用,因此交叉账户访问仍然需要适用的资源方赠款。 在发现模式下,主标记等未知主属性作为条件返回.
- 外部资源 请求需要具体资源ARN,并保留所收集的主体身份政策、许可界限、会话政策、SCP和VPC端点政策。 它们不实行区域协商进程,而是采用供应或合成资源/信托政策。 S3 ABAC 和 Block Public Access 默认禁用未收集的资源;ABAC 可用
--s3-abac-override enabled。 。 。 .
匿名,外主,外主资源模拟不支持通配符只操作. 政策凌驾和其他细节的完整文件.
who-can - 找到谁可以在资源上执行动作
iam-lens who-can [options]
列出您 IAM 数据中允许在一个资源上执行一个或多个指定动作(或只记通配符动作)的所有主符 。 如果适用,它将检查资源政策,以找到交叉账户权限和AWS服务主机。 还模拟了潜在的公共资源政策,用于未签名的访问,返回为 "principal": "anonymous",包括通配符资源模式.
实例:
# Who can get this object?
iam-lens who-can \
--resource arn:aws:s3:::my-bucket/secret-file.txt \
--actions s3:GetObject
# Who can list all IAM roles in this account? (wildcard action – no resource)
iam-lens who-can \
--resource-account 555555555555 \
--actions iam:ListRoles
# Check multiple actions at once
iam-lens who-can \
--resource arn:aws:dynamodb:us-east-1:555555555555:table/Books \
--actions dynamodb:Query dynamodb:UpdateItem
# Check a wildcard resource prefix and inspect allowed patterns
iam-lens who-can \
--resource arn:aws:s3:::my-bucket/reports/* \
--actions s3:GetObject
# Check all actions for a bucket
iam-lens who-can \
--resource arn:aws:s3:::my-bucket
principal-can - 获得校长所有许可的综合政策
iam-lens principal-can --principal <arn> [--shrink-action-lists]
创建一个合并的政策文件,显示一个主机能够根据其身份政策、权限界限、SCP、RCP和资源政策执行的所有权限。 产出是综合的IAM政策,代表所有政策评价之后的有效授权.
实例:
# Get all permissions for a user or role
iam-lens principal-can \
--principal arn:aws:iam::123456789012:user/Alice
# Get permissions for a role with shrunk action lists
iam-lens principal-can \
--principal arn:aws:iam::123456789012:role/MyRole \
--shrink-action-lists
贡献支持( S)
最好的支持方法是 打开一个问题 并告诉我们任何错误, 特性请求, 或问题。 我们总是想方设法改进工程,使工程对大家更加有用.
鸣谢
特别感谢 齐亚德·阿尔姆巴舍 用于测试,验证,提供反馈,以及作者认为"这很好"时不放.