Files
hacktricks-cloud/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-codestar-privesc

AWS - Codestar Privesc

{{#include ../../../../banners/hacktricks-training.md}}

Codestar

Codestarに関する詳細情報は以下で確認できます

{{#ref}} codestar-createproject-codestar-associateteammember.md {{#endref}}

iam:PassRole, codestar:CreateProject

これらの権限を使用すると、cloudformationテンプレートを介して任意のアクションを実行するためにcodestar IAMロールを悪用できます。次のページを確認してください:

{{#ref}} iam-passrole-codestar-createproject.md {{#endref}}

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

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

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

{{#ref}} codestar-createproject-codestar-associateteammember.md {{#endref}}

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ロールへのプライベートエスカレーション。

{{#include ../../../../banners/hacktricks-training.md}}