AWS - Cognito 未经认证枚举

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

未经认证的 Cognito

Cognito 是一项 AWS 服务,允许开发者 授予其应用用户对 AWS 服务的访问权限。开发者会在其应用中向 IAM roles to authenticated users 授权(用户可能只需注册即可),也可以向 IAM role to unauthenticated users 授权。

有关 Cognito 的基本信息请查看:

AWS - Cognito Enum

Identity Pool ID

Identity Pools 可以向仅仅知道 Identity Pool ID 的用户授予 IAM roles to unauthenticated users(Identity Pool ID 通常比较容易发现),攻击者获得此信息后可能尝试 access that IAM role 并利用它。
此外,IAM roles 也可能分配给访问该 Identity Pool 的 authenticated users。如果攻击者能够 register a user 或者已经能 access to the identity provider(该身份提供者被 Identity Pool 使用),就可能获取到授予 authenticated 用户的 IAM role being given to authenticated 并滥用其权限。

Check how to do that here.

User Pool ID

默认情况下 Cognito 允许 register new user。能够注册用户可能会让你获得对underlaying applicationaccess,或者获得作为身份提供者接受 Cognito User Pool 的 Identity Pool 的 authenticated IAM access role of an Identity PoolCheck how to do that here.

Pacu modules for pentesting and enumeration

Pacu,这个 AWS exploitation framework,现在包含了 “cognito__enum” 和 “cognito__attack” 模块,用于自动枚举账户中的所有 Cognito 资产并标记弱配置、用于访问控制的用户属性等;同时也能自动创建用户(包括 MFA 支持)并基于可修改的自定义属性、可用的 identity pool 凭证、id tokens 中可被假定的角色等进行权限升级。

关于这些模块功能的描述请参见该 blog post 的第 2 部分。关于安装说明请参见 Pacu 主页面。

Usage

Sample cognito__attack usage to attempt user creation and all privesc vectors against a given identity pool and user pool client:

Pacu (new:test) > run cognito__attack --username randomuser --email XX+sdfs2@gmail.com --identity_pools
us-east-2:a06XXXXX-c9XX-4aXX-9a33-9ceXXXXXXXXX --user_pool_clients
59f6tuhfXXXXXXXXXXXXXXXXXX@us-east-2_0aXXXXXXX

示例 cognito__enum 用法,用于收集当前 AWS 帐户中可见的所有用户池、用户池客户端、身份池、用户等:

Pacu (new:test) > run cognito__enum

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