AWS - API Gateway Unauthenticated Enum
Tip
Ucz się & ćwicz AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Ucz się & ćwicz GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Ucz się & ćwicz Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Wspieraj HackTricks
- Sprawdź subscription plans!
- Dołącz do 💬 Discord group lub telegram group lub śledź nas na Twitterze 🐦 @hacktricks_live.
- Podziel się hacking tricks, zgłaszając PRy do HackTricks i HackTricks Cloud github repos.
API Invoke bypass
Zgodnie z wykładem Attack Vectors for APIs Using AWS API Gateway Lambda Authorizers - Alexandre & Leonardo, Lambda Authorizers mogą być skonfigurowane using IAM syntax, aby nadawać uprawnienia do wywoływania API endpoints. Powyższe pochodzi from the docs:
{
"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.
Some examples:
- 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/createAdminfor 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.
Soarn:aws:execute-apis:sa-east-1:accid:*/prod/GET/dashboard/*
Can validate a post request to test stage to the path/prod/GET/dashboard/adminfor example.
Zawsze powinieneś mieć jasno określone, do czego chcesz przyznać dostęp, a następnie sprawdzić, czy z przyznanymi uprawnieniami możliwe są inne scenariusze.
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 danych wejściowych od użytkownika to generowania polityk IAM, wildcards (and others such as “.” or specific strings) can be included in there with the goal of obejścia ograniczeń.
Szablon publicznego URL
https://{random_id}.execute-api.{region}.amazonaws.com/{user_provided}
Pobierz ID konta z publicznego API Gateway URL
Podobnie jak w przypadku S3 buckets, Data Exchange i Lambda URLs gateways, możliwe jest znalezienie ID konta, nadużywając aws:ResourceAccount Policy Condition Key z publicznego API Gateway URL.
Odbywa się to przez znajdowanie ID konta znak po znaku, nadużywając wildcardów w sekcji aws:ResourceAccount polityki.
Technika ta pozwala również uzyskać wartości tagów, jeśli znasz klucz taga (istnieją pewne domyślne, interesujące klucze).
You can find more information in the original research and the tool conditional-love to automate this exploitation.
Tip
Ucz się & ćwicz AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Ucz się & ćwicz GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Ucz się & ćwicz Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Wspieraj HackTricks
- Sprawdź subscription plans!
- Dołącz do 💬 Discord group lub telegram group lub śledź nas na Twitterze 🐦 @hacktricks_live.
- Podziel się hacking tricks, zgłaszając PRy do HackTricks i HackTricks Cloud github repos.
HackTricks Cloud

