AWS - API Gateway Unauthenticated Enum
Tip
Apprenez & pratiquez AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Apprenez & pratiquez GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Apprenez & pratiquez Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Soutenez HackTricks
- Consultez les subscription plans!
- Rejoignez le 💬 Discord group ou le telegram group ou suivez-nous sur Twitter 🐦 @hacktricks_live.
- Partagez des hacking tricks en soumettant des PRs aux HackTricks et HackTricks Cloud github repos.
API Invoke bypass
Selon la présentation Attack Vectors for APIs Using AWS API Gateway Lambda Authorizers - Alexandre & Leonardo, les Lambda Authorizers peuvent être configurés en utilisant la syntaxe IAM pour accorder l’autorisation d’invoquer des endpoints API. Ceci est tiré 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"
]
}
]
}
Le problème avec cette manière d’accorder des permissions pour invoquer des endpoints est que le “*” implique “tout” et qu’il n’y a plus de prise en charge de la syntaxe regex.
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.
Vous devez toujours savoir exactement ce que vous voulez autoriser et ensuite vérifier si d’autres scénarios sont possibles avec les permissions accordées.
Pour plus d’infos, 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 entrées utilisateur to générer les IAM policies, wildcards (and others such as “.” or specific strings) can be included in there with the goal of contourner les restrictions.
Modèle d’URL publique
https://{random_id}.execute-api.{region}.amazonaws.com/{user_provided}
Get Account ID from public API Gateway URL
Tout comme pour les buckets S3, Data Exchange et les URL Lambda gateways, il est possible de trouver l’ID de compte d’un compte en abusant de la aws:ResourceAccount Policy Condition Key à partir d’une URL publique API Gateway. Cela se fait en découvrant l’ID caractère par caractère en abusant des jokers dans la section aws:ResourceAccount de la policy.
Cette technique permet également d’obtenir les valeurs des tags si vous connaissez la clé du tag (il y en a quelques-unes par défaut intéressantes).
Vous pouvez trouver plus d’informations dans la original research et l’outil conditional-love pour automatiser cette exploitation.
Tip
Apprenez & pratiquez AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Apprenez & pratiquez GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Apprenez & pratiquez Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Soutenez HackTricks
- Consultez les subscription plans!
- Rejoignez le 💬 Discord group ou le telegram group ou suivez-nous sur Twitter 🐦 @hacktricks_live.
- Partagez des hacking tricks en soumettant des PRs aux HackTricks et HackTricks Cloud github repos.
HackTricks Cloud

