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

