AWS - Cognito Unauthenticated Enum

Reading time: 3 minutes

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도 부여할 수 있습니다.

For basic info about Cognito check:

AWS - Cognito Enum

Identity Pool ID

Identity Pools는 Identity Pool ID만 알고 있는 unauthenticated users에게 IAM roles을 부여할 수 있습니다(Identity Pool ID를 찾는 것은 꽤 흔합니다). 공격자가 이 정보를 알면 해당 IAM role에 접근하려 시도하고 이를 악용할 수 있습니다.
또한, IAM roles는 Identity Pool에 접근하는 authenticated users에게 할당될 수도 있습니다. 공격자가 register a user를 할 수 있거나 이미 Identity Pool에서 사용하는 identity provider에 access 권한이 있다면, 인증된 사용자에게 부여되는 IAM role에 접근하여 권한을 남용할 수 있습니다.

Check how to do that here.

User Pool ID

By default Cognito allows to register new user. 사용자가 가입할 수 있다는 것은 underlaying application에 대한 access 권한을 얻거나, Cognito User Pool을 identity provider로 사용하는 Identity Pool의 authenticated IAM access role of an Identity Pool에 접근할 수 있음을 의미할 수 있습니다. Check how to do that here.

Pacu modules for pentesting and enumeration

Pacu, the AWS exploitation framework,에는 이제 모든 Cognito 자산을 계정에서 열거하고 잘못된 구성, 접근 제어에 사용되는 사용자 속성 등을 식별하는 "cognito__enum"과 "cognito__attack" 모듈이 포함되어 있으며, 사용자 생성(예: MFA 지원 포함)과 수정 가능한 custom attributes, 사용 가능한 identity pool 자격 증명, id 토큰에서의 assumable roles 등을 기반으로 한 권한 상승을 자동화합니다.

For a description of the modules' functions see part 2 of the blog post. For installation instructions see the main Pacu page.

Usage

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

bash
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

현재 AWS 계정에서 볼 수 있는 모든 user pools, user pool clients, identity pools, users 등을 수집하기 위한 cognito__enum 사용 예시:

bash
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 지원하기