AWS - API Gateway Unauthenticated Enum

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

API Invoke bypass

उक्त टॉक Attack Vectors for APIs Using AWS API Gateway Lambda Authorizers - Alexandre & Leonardo के अनुसार, Lambda Authorizers को using IAM syntax का उपयोग करके API endpoints को invoke करने की permissions देने के लिए configure किया जा सकता है। यह from the docs से लिया गया है:

json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Permission",
"Action": ["execute-api:Execution-operation"],
"Resource": [
"arn:aws:execute-api:region:account-id:api-id/stage/METHOD_HTTP_VERB/Resource-path"
]
}
]
}

The problem with this way to give permissions to invoke endpoints is that the "*" implies "anything" and there is no more regex syntax supported.

कुछ उदाहरण:

  • A rule such as arn:aws:execute-apis:sa-east-1:accid:api-id/prod/*/dashboard/* in order to give each user access to /dashboard/user/{username} will give them access to other routes such as /admin/dashboard/createAdmin for example.

warning

Note that "*" doesn't stop expanding with slashes, therefore, if you use "*" in api-id for example, it could also indicate "any stage" or "any method" as long as the final regex is still valid.
So arn:aws:execute-apis:sa-east-1:accid:*/prod/GET/dashboard/*
Can validate a post request to test stage to the path /prod/GET/dashboard/admin for example.

आपको हमेशा स्पष्ट होना चाहिए कि आप किन चीज़ों को access की अनुमति देना चाहते हैं और फिर यह जांचना चाहिए कि दिए गए permissions के साथ अन्य परिदृश्य संभव हैं या नहीं।

For more info, apart of the docs, you can find code to implement authorizers in this official aws github.

IAM Policy Injection

In the same talk it's exposed the fact that if the code is using user input to generate the IAM policies, wildcards (and others such as "." or specific strings) can be included in there with the goal of bypassing restrictions.

Public URL टेम्पलेट

https://{random_id}.execute-api.{region}.amazonaws.com/{user_provided}

सार्वजनिक API Gateway URL से खाता ID प्राप्त करें

S3 buckets, Data Exchange और Lambda URLs gateways की तरह, सार्वजनिक API Gateway URL से aws:ResourceAccount Policy Condition Key का दुरुपयोग करके किसी खाते का खाता ID पता करना संभव है.
यह नीति के aws:ResourceAccount सेक्शन में wildcards का दुरुपयोग करके खाता ID को एक-एक कर के खोज कर किया जाता है.

यह तकनीक टैग कुंजी ज्ञात होने पर टैग के मान (values) भी प्राप्त करने की अनुमति देती है (कुछ डिफ़ॉल्ट रोचक टैग होते हैं).

आप अधिक जानकारी original research और शोषण को स्वचालित करने के लिए टूल conditional-love में पा सकते हैं.

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