EmmanuelAdesina/aws-iam-attack-paths

GitHub: EmmanuelAdesina/aws-iam-attack-paths

该项目将 AWS IAM 建模为信任图,系统分析和可视化身份配置缺陷如何导致权限提升和账户沦陷的攻击路径。

Stars: 0 | Forks: 0

``` █████╗ ██╗ ██╗███████╗ ██╗ █████╗ ███╗ ███╗ ██╔══██╗██║ ██║██╔════╝ ██║██╔══██╗████╗ ████║ ███████║██║ █╗ ██║███████╗ ██║███████║██╔████╔██║ ██╔══██║██║███╗██║╚════██║ ██║██╔══██║██║╚██╔╝██║ ██║ ██║╚███╔███╔╝███████║ ██║██║ ██║██║ ╚═╝ ██║ ╚═╝ ╚═╝ ╚══╝╚══╝ ╚══════╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ``` # AWS IAM 攻击路径 ### 云安全威胁建模实践 **将 AWS 身份建模为有向信任图 —— 而不是权限列表。** [![Security Research](https://img.shields.io/badge/type-security%20research-red?style=flat-square)](.) [![AWS](https://img.shields.io/badge/platform-AWS-232F3E?style=flat-square&logo=amazonaws)](.) [![IAM](https://img.shields.io/badge/focus-IAM%20%2F%20STS-FF9900?style=flat-square)](.) [![Threat Modeling](https://img.shields.io/badge/method-threat%20modeling-8B5CF6?style=flat-square)](.) [![Educational](https://img.shields.io/badge/use-educational-22C55E?style=flat-square)](.)
## 核心前提 大多数云安全指南会问:**“谁拥有权限?”** 这是一个错误的问题。 正确的问题是:**“谁能*成为*拥有权限的身份?”** 这种区分将普通云用户与云安全工程师区分开来。AWS IAM 不是一个扁平的访问控制列表 —— 它是一个分布式的授权图,其中信任关系定义了可达性,而可达性定义了风险。 该仓库对该图进行建模,追踪攻击者如何遍历它,并展示了当身份被视为主要攻击面时,安全设计的样貌。 ## 攻击链 — 概览 ``` Leaked Credentials ← The starting condition, not the exploit ↓ Identity Enumeration ← Low-noise. Frequently undetected. ↓ Trust Graph Traversal ← The actual attack surface ↓ Privilege Escalation ← AssumeRole chains, PassRole injection ↓ Lateral Movement ← Cross-service, cross-account ↓ Persistence ← Lives in the control plane, not the workload ↓ Production Compromise ← The outcome that was preventable ``` ## 仓库结构 ``` aws-iam-attack-paths/ │ ├── README.md ← You are here ├── SECURITY-INSIGHTS.md ← Core thesis and mental model │ ├── article/ │ └── aws-iam-attack-paths.md ← Full technical write-up │ ├── diagrams/ │ ├── attack-paths.md ← Complete attack chain (Mermaid) │ └── iam-trust-graph.md ← Trust relationship topology │ ├── examples/ │ ├── trust-policy-examples.md ← Vulnerable vs. hardened trust policies │ ├── vulnerable-s3-policy.json ← Annotated misconfiguration │ └── secure-s3-policy.json ← Hardened equivalent │ ├── docs/ │ └── index.html ← Visual portfolio page │ └── references/ └── aws-documentation-links.md ← Full AWS doc mapping with attack context ``` ## 四大攻击面 — 为什么它们很重要 ### `sts:AssumeRole` — Role Chain 攻击 主要的提权机制。一个拥有宽松 role 的 `sts:AssumeRole` 权限的低权限身份,会悄无声息地继承其权限 —— 包括访问原始身份本不应触及的资源。 攻击者不需要管理员权限。他们只需要向其*跃升一跳*。 ### `iam:PassRole` — 向计算资源注入特权 允许将 role 附加到 EC2 或 Lambda 等服务上。一旦配置错误,这与直接交给攻击者 `AdministratorAccess` 毫无区别。注入的 role 在工作负载内部运行;而将其放置在那里的 API 调用只留下一行日志。 ### S3 资源策略 — 通过资源层绕过 IAM S3、KMS 和 Lambda 的基于资源的策略独立于 IAM 身份策略进行评估。单个存储桶策略上的通配符 principal 會暴露数据,无论 IAM role 的权限范围限制得有多严格。 ### 跨账户信任 — 组织内的横向移动 允许外部账户 principal 的 role 信任策略,使得跨越账户边界进行渗透成为可能。源账户的 CloudTrail 毫无察觉。而爆炸半径则扩展到整个 AWS Organization。 ## 防御态势 — 每个团队都应回答的八个问题 如果任何一个回答是“我不知道”,那么这个空白点就是活跃的攻击面: | # | 问题 | |---|---| | 1 | 哪些身份拥有特权 role 的 `sts:AssumeRole` 权限? | | 2 | 任何低权限身份能否通过 role chaining 获得管理员权限? | | 3 | `iam:PassRole` 存在于何处,以及针对哪些目标 role? | | 4 | 哪些资源策略允许使用通配符或外部 principal? | | 5 | 是否所有跨账户信任关系都已记录在案并经过审查? | | 6 | 你能在凌晨 2 点检测到信任策略的修改吗? | | 7 | 你能检测到为现有 role 添加的第二个访问密钥吗? | | 8 | 你的 SCP 是否强制执行了 IAM 策略的意图? | ## 核心洞察 ## 内容概览 | 文件 | 涵盖内容 | |---|---| | [`SECURITY-INSIGHTS.md`](./SECURITY-INSIGHTS.md) | 心智模型:将 IAM 作为信任图 | | [`article/aws-iam-attack-paths.md`](./article/aws-iam-attack-paths.md) | 完整的技术拆解,逐一剖析攻击 | | [`diagrams/attack-paths.md`](./diagrams/attack-paths.md) | 包含六个阶段的可视化攻击链 | | [`diagrams/iam-trust-graph.md`](./diagrams/iam-trust-graph.md) | 跨 role、账户、SCP 的信任拓扑 | | [`examples/trust-policy-examples.md`](./examples/trust-policy-examples.md) | 四种策略模式:从易受攻击到已加固 | | [`examples/vulnerable-s3-policy.json`](./examples/vulnerable-s3-policy.json) | 带有注释的 S3 错误配置 | | [`examples/secure-s3-policy.json`](./examples/secure-s3-policy.json) | 等效的已加固 S3 策略 | | [`references/aws-documentation-links.md`](./references/aws-documentation-links.md) | 映射到攻击上下文的 AWS 官方文档 | ## 关于本项目 本仓库是我们持续关注云安全工程的一部分 —— 特别是 AWS 环境中身份架构、威胁建模和真实世界攻击路径分析的交叉领域。 我们的目标不是成为一份核对清单。而是建立一种心智模型,使得核对清单变得不再必要。 *仅用于教育和安全研究目的。*
标签:AWS, DPI, Homebrew安装, IAM, Modbus, 云计算, 协议分析, 图分析, 威胁建模, 权限提升, 规则引擎, 防御加固