Study guide
8.2 Amazon Cognito User Pools & Identity Pools
AWS Certified Security – Specialty SCS-C03
Track your progress as you read
Finished sections get a check mark.
1 Chapter 0: Getting Started with the SCS-C03 Exam
0.1 SCS-C03 Exam Format, Domains & Study Strategy
2 Chapter 1: Security Monitoring, Alerting & Threat Detection Services
1.1 Workload Monitoring & Health Check Strategies 1.2 Amazon GuardDuty Architecture & Finding Types 1.3 AWS Security Hub & Automated Conformance Assessment 1.4 Amazon Macie & Automated Data Classification
3 Chapter 2: Enterprise Logging Architecture & Analysis
2.1 Multi-Account CloudTrail & Organization Trails 2.2 Amazon Security Lake & OCSF Log Normalization 2.3 Network Telemetry: VPC Flow Logs & Route 53 Resolver Logs 2.4 Troubleshooting Security Telemetry & Log Ingestion 2.5 Analyzing, Normalizing & Correlating Security Logs
4 Chapter 3: Incident Readiness, Response Planning & Automated Runbooks
3.1 Incident Response Planning & Blast Radius Mitigation 3.2 Testing & Validating Incident Response Plans 3.3 Automated Incident Remediation with EventBridge & Step Functions 3.4 Systems Manager OpsCenter & Incident Manager Runbooks
5 Chapter 4: Digital Forensics, Evidence Preservation & Root Cause Analysis
4.1 Forensic Artifact Capture & Chain of Custody 4.2 Threat Containment & Network Quarantine Techniques 4.3 Correlating Events & Root Cause Analysis with Amazon Detective
6 Chapter 5: Edge Protection, WAF & DDoS Mitigation
5.1 CloudFront Security Headers & Origin Access Control 5.2 AWS WAF Architecture & Advanced Rule Sets 5.3 AWS Shield Advanced & DDoS Defense Architectures 5.4 Edge Integrations: Managed Rule Groups, OCSF Ingestion, IoT Policies & CORS
7 Chapter 6: Compute Workload Hardening, Vulnerability Management & GenAI Security
6.1 Golden AMIs & Container Image Hardening Pipelines 6.2 Amazon Inspector Vulnerability Management & Patch Automation 6.3 Generative AI Security: Amazon Bedrock Guardrails & Model Protection 6.4 Instance Profiles, Service Roles & Execution Roles for Compute 6.5 Secure Administrative Access: Session Manager & EC2 Instance Connect
8 Chapter 7: Network Security, Segmentation, Private Connectivity & Encryption in Transit
7.1 Layered Traffic Filtering: SGs, NACLs & AWS Network Firewall 7.2 Hybrid Connectivity Security: VPN, Direct Connect & MACsec 7.3 Zero-Trust Access & Network Access Analysis 7.4 Enforcing Encryption in Transit: ELB Security Policies, TLS & HTTPS-Only Access 7.5 Private Access: VPC Endpoints, PrivateLink, Client VPN & Verified Access 7.6 Inter-Resource Encryption in Transit: Nitro, EMR, EKS & SageMaker AI
9 Chapter 8: Enterprise Authentication, Federation & Directory Services
8.1 AWS IAM Identity Center & Enterprise IdP Integration 8.2 Amazon Cognito User Pools & Identity Pools 8.3 AWS Security Token Service (STS) & Temporary Credential Workflows 8.4 Troubleshooting Identity & Authentication Failures
10 Chapter 9: Advanced Authorization Architecture & Policy Evaluation
9.1 Complete AWS Policy Evaluation Logic & Decision Flow 9.2 Permission Boundaries & Safe Admin Delegation 9.3 Attribute-Based Access Control (ABAC) with IAM Tags
11 Chapter 10: Least Privilege, Policy Validation & External Access Auditing
10.1 IAM Roles Anywhere & Amazon Verified Permissions 10.2 Auditing External & Unused Access with IAM Access Analyzer 10.3 Analyzing Authorization Failures & Policy Simulation
12 Chapter 11: Cryptographic Services: KMS Architecture & Key Governance
11.1 AWS KMS Architecture, Key Policies & Key Types 11.2 KMS Grants, Encryption Context & Multi-Region Keys 11.3 Imported Key Material (BYOK) & CloudHSM Key Stores
13 Chapter 12: Secrets Management, Sensitive Data Masking & PKI
12.1 AWS Secrets Manager & Systems Manager Parameter Store 12.2 Sensitive Data Masking in Telemetry & Messaging 12.3 AWS Certificate Manager (ACM) & Private CA Architecture
14 Chapter 13: Storage Encryption, Integrity, Lifecycle & Backup Protection
13.1 S3 Encryption Modes & S3 Bucket Keys 13.2 Data Integrity Protection: Object Lock, Vault Lock & Code Signing 13.3 Secure Data Lifecycle, Cross-Account Replication & Backup Vault Lock 13.4 Lifecycle, Backup & Secure Replication Beyond S3: EFS, FSx, DLM, DataSync & Air-Gapped Vaults
15 Chapter 14: Multi-Account Architecture, Organizations & Control Tower Governance
14.1 AWS Organizations Structure, Hierarchy & Resource Control 14.2 AWS Control Tower Landing Zone & Guardrail Framework 14.3 Delegated Administrator Architecture & Root User Governance 14.4 Centralized Resource Sharing with RAM & Service Catalog
16 Chapter 15: Compliance Automation, Infrastructure as Code Security & Auditing
15.1 Infrastructure as Code Security & Multi-Account Deployment 15.2 AWS Config, Conformance Packs & Automated Remediation 15.3 Audit Evidence Collection & Well-Architected Security Reviews
8.2 Amazon Cognito User Pools & Identity Pools
Key Takeaways Explain This Topic AI
Amazon Cognito User Pools act as an identity provider and user directory handling registration, authentication, and directory management, outputting OIDC-compliant JWT tokens (ID, Access, and Refresh tokens).
Amazon Cognito Identity Pools (Federated Identities) act as an authorization broker, exchanging external identity tokens from User Pools, social providers, SAML, or OIDC for temporary AWS STS credentials.
User pool threat protection (formerly advanced security features, in the Plus plan) defends against credential stuffing and account takeover with compromised-credential detection and adaptive, risk-based authentication.
Cognito Lambda triggers inject serverless logic across authentication lifecycle stages, enabling token enrichment, dynamic claim insertion, custom challenge workflows, and third-party risk verification.
Identity Pools resolve IAM roles for authenticated and unauthenticated guest users through default mappings, rules-based claim matching, or token-based group associations.
Last updated: September 2026
8.2 Amazon Cognito User Pools & Identity Pools
Modern cloud-native and mobile applications require scalable identity architectures that can support millions of users, social logins, multi-factor authentication, and secure access to backend AWS services without embedding long-term credentials in client applications. Amazon Cognito addresses these requirements through two distinct architectural primitives: Cognito User Pools and Cognito Identity Pools (Federated Identities).
A mastery of the separation of responsibilities between User Pools (authentication) and Identity Pools (authorization), token validation mechanics, threat protection, Lambda trigger customization, and fine-grained STS credential vending is critical for the AWS Certified Security – Specialty exam.
Architectural Separation: User Pools vs. Identity Pools
The fundamental architectural distinction between User Pools and Identity Pools frequently appears on the exam: User Pools = Authentication ("Who you are") --> Outputs OIDC JSON Web Tokens (JWTs)
Identity Pools = Authorization ("What you can do") --> Vends Temporary AWS IAM Credentials (STS)
Architectural Dimension Amazon Cognito User Pools Amazon Cognito Identity Pools
Primary Function Identity Provider (IdP) & user directory service. Identity broker & authorization credential vending service.
Core Capabilities User sign-up, sign-in, password reset, hosted UI, MFA, adaptive risk profiling. Exchanges external identity tokens for temporary AWS IAM credentials via AWS STS.
Supported Identity Sources Built-in directory, social providers (Google, Apple, Facebook), SAML 2.0 IdPs, OIDC IdPs. Cognito User Pools, OpenID Connect (OIDC) providers, SAML 2.0 IdPs, Public Social IdPs, Unauthenticated Guests.
Output Artifacts Standard OIDC JSON Web Tokens ( ID Token , Access Token , Refresh Token ). Temporary AWS credentials ( AccessKeyId , SecretAccessKey , SessionToken , Expiration ).
Target Consumption Application frontends, API Gateway Cognito Authorizers, ALB OIDC listeners. Direct client SDK access to AWS services (e.g., Amazon S3, Amazon DynamoDB, Amazon AppSync).
Loading diagram...
Amazon Cognito User Pools: Directory & JWT Architecture
A User Pool is an enterprise-scale user directory that handles user registration, attribute storage, credential verification, and session management. It can be integrated using the AWS-managed Cognito Hosted UI (an out-of-box OAuth 2.0 / OIDC login interface) or via custom application interfaces using the AWS Amplify SDK or AWS SDKs.
OIDC JSON Web Tokens (JWT) Deep Dive
Upon successful authentication, a Cognito User Pool issues three standard JSON Web Tokens. Each token serves a specialized architectural purpose:
ID Token (Identity Proof) :
Purpose : Proves the identity of the authenticated user to the client application and Identity Pools.
Key Claims : Contains identity attributes such as sub (unique user UUID), email , cognito:groups , aud (app client ID), iss (User Pool issuer URL), and custom user attributes.
Format : Signed using RS256 (RSA Signature with SHA-256). Can be exchanged with Cognito Identity Pools to obtain AWS credentials.
Access Token (API Authorization) :
Purpose : Authorizes calls to protected API endpoints, such as Amazon API Gateway REST/HTTP APIs or custom microservices.
Key Claims : Contains authorization scopes ( scope ), client_id , username , and cognito:groups . It does not contain sensitive user identity claims (like email or phone number).
Target : Validated by API Gateway Cognito Authorizers to authorize or deny API requests based on OAuth scopes.
Refresh Token (Session Maintenance) :
Purpose : Obtains fresh ID and Access tokens without requiring the user to re-enter their password.
Expiration : Configurable from 60 minutes to 10 years (default is 30 days).
Refresh Token Rotation : When enabled on the app client, each refresh returns a new refresh token and invalidates the original (after an optional grace period of up to 60 seconds), limiting replay of an intercepted token. Rotation requires the GetTokensFromRefreshToken API; the REFRESH_TOKEN_AUTH flow must be disabled.
Validating Cognito JWT Tokens
When a backend service receives a JWT from a client, it must validate the token offline without calling the Cognito API for every request:
Verify Signature : Fetch the public JSON Web Key Set (JWKS) from https://cognito-idp.<region>.amazonaws.com/<userPoolId>/.well-known/jwks.json . Match the kid (Key ID) header in the JWT with the corresponding public key in the JWKS and verify the cryptographic signature.
Verify Issuer ( iss ) : Confirm the iss claim exactly matches https://cognito-idp.<region>.amazonaws.com/<userPoolId> .
Verify Audience ( aud ) : For ID tokens, confirm the aud claim matches the application's Cognito App Client ID. For Access tokens, verify the client_id .
Verify Expiration ( exp ) : Confirm the token has not expired ( exp > current epoch time).
Threat Protection & Adaptive Authentication
For threat mitigation, Cognito user pools provide threat protection (called advanced security features before the November 2024 feature plans; now part of the Plus plan). It evaluates sign-in risk and checks passwords against leaked-credential data to detect and prevent account takeover.
Operating Modes
Audit Only : Logs suspicious activities, credential stuffing attempts, and risk evaluations to Amazon CloudWatch without interfering with user login attempts. Used to baseline application traffic.
Enforce : Automatically initiates defensive challenges or blocks sign-in based on calculated risk scores.
Core Security Defenses
Compromised Credential Checks (Leaked Credential Detection) :
Cognito compares submitted passwords with credentials from public data breaches and with commonly guessed passwords. Detection works for username-and-password flows, not for SRP or custom authentication flows.
If a user attempts to sign up, sign in, or reset their password using compromised credentials, Cognito can automatically prompt the user to change their password or block the request.
Adaptive Authentication (Risk-Based Step-Up) :
Cognito calculates a dynamic risk level ( Low , Medium , or High ) for each authentication attempt by evaluating contextual signals: source IP address, geolocation, device fingerprint, operating system, and time of day.
Action Configuration : Administrators configure responses based on risk severity:
Low Risk : Allow sign-in without additional friction.
Medium Risk : Prompt for second-factor authentication (SMS or TOTP MFA).
High Risk : Block the sign-in attempt entirely or require step-up MFA and send an automated notification to the user's verified email.
Loading diagram...
Cognito Lambda Triggers: Intercepting the Auth Lifecycle
Cognito allows security teams to inject custom serverless logic into the authentication flow via AWS Lambda triggers . Lambda triggers execute synchronously or asynchronously at predefined extension points:
Loading diagram...
Critical Security Triggers for the Exam
Pre Sign-Up : Validates user attributes before account creation. Used to enforce corporate domain restrictions (e.g., rejecting any sign-up where the email does not end in @example.com ) or automatically verifying trusted attributes.
Pre Authentication : Executes before credential validation. Used to enforce custom IP CIDR allowlists, geo-blocking, or rate-limiting fraud attempts before Cognito checks the user's password.
Pre Token Generation (Crucial for Authorization) :
Executes immediately before Cognito signs and issues the ID token.
Capability : Allows the Lambda function to dynamically add, modify, or suppress claims in the ID token. For example, the function can query an internal database and inject custom authorization claims, such as "tenant_id": "corp-102" or dynamic group roles, which downstream microservices and Identity Pools use for access control.
Custom Authentication Challenges (SRP / Passwordless) :
Combines three triggers: Define Auth Challenge , Create Auth Challenge , and Verify Auth Challenge Response .
Used to implement passwordless authentication, CAPTCHA validation, or custom SMS/email one-time verification workflows.
Amazon Cognito Identity Pools: Federated Credential Vending
While User Pools issue JWTs, AWS APIs do not accept JWTs directly (with the exception of API Gateway). To interact with services like Amazon S3, Amazon DynamoDB, or AWS KMS, a client application requires AWS credentials signed with Signature Version 4 (SigV4).
Amazon Cognito Identity Pools act as an exchange broker, accepting authenticated identity tokens from diverse providers and vending temporary, short-lived AWS IAM credentials via AWS STS.
Supported Identity Providers in Identity Pools
Amazon Cognito User Pools (passing the User Pool ID token).
Public Social IdPs : Google, Apple, Facebook, Amazon.
OpenID Connect (OIDC) Providers : Any standard OIDC-compliant identity system (e.g., Salesforce, Auth0).
SAML 2.0 Identity Providers : Enterprise federations (e.g., Okta, PingFederate).
Developer Authenticated Identities : Custom backend systems vending tokens using the GetOpenIdTokenForDeveloperIdentity API.
Unauthenticated (Guest) Access : Issues temporary AWS credentials to anonymous users without requiring any sign-in (e.g., allowing guest users to download preview assets from an S3 bucket).
The Identity Pool Exchange Sequence
The client presents an identity token (e.g., a Cognito User Pool ID token) to the Identity Pool via the GetId API to obtain an IdentityId (a unique identifier for the user in the format <region>:<uuid> ).
The client calls GetCredentialsForIdentity , passing the token and IdentityId .
The Identity Pool validates the token signature, issuer, and expiration.
The Identity Pool invokes STS AssumeRoleWithWebIdentity on behalf of the user, passing the configured IAM role ARN.
STS returns temporary AWS credentials ( AccessKeyId , SecretAccessKey , SessionToken , Expiration ) to the Identity Pool, which returns them to the client application.
Role Resolution & Fine-Grained Authorization
Identity Pools determine which IAM role to assign to a user through three distinct role resolution mechanisms:
Default Authenticated / Unauthenticated Roles : A baseline IAM role assigned to all authenticated users, and a separate locked-down role assigned to guest users.
Rules-Based Role Mapping : Evaluates user claims within the incoming token using conditional logic. For example: If claim "department" equals "SecurityOperations", assign Role "arn:aws:iam::123456789012:role/SecOpsRole" .
Token-Based Group Mapping : Automatically maps the user's cognito:groups claim in their User Pool token directly to specific IAM role ARNs configured on the Cognito User Pool group.
Fine-Grained Resource Access Control (FGAC) with IAM Policy Variables
To prevent users from accessing other users' private data without creating individual IAM roles for every user, Identity Pools leverage IAM Policy Variables based on the Cognito identity ID ( ${cognito-identity.amazonaws.com:sub} ): {
- "Version": "2012-10-17",
- "Statement": [
- {
- "Sid": "AllowUserSpecificS3FolderAccess",
- "Effect": "Allow",
- "Action": [
- "s3:GetObject",
- "s3:PutObject",
- "s3:DeleteObject"
- ],
- "Resource": "arn:aws:s3:::enterprise-user-storage/${cognito-identity.amazonaws.com:sub}/*"
- },
- {
- "Sid": "AllowListOnlyUserFolder",
- "Effect": "Allow",
- "Action": "s3:ListBucket",
- "Resource": "arn:aws:s3:::enterprise-user-storage",
- "Condition": {
- "StringLike": {
- "s3:prefix": ["${cognito-identity.amazonaws.com:sub}/*"]
- }
- }
- }
- ]
- }
In this policy, whenever a user assumes the role, AWS STS dynamically evaluates ${cognito-identity.amazonaws.com:sub} to the user's actual Cognito Identity ID (e.g., us-east-1:1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d ). This guarantees strict user folder isolation in Amazon S3 using a single shared IAM role.
Specialty Exam Pitfalls & Architectural Traps
Direct AWS Access via User Pool Alone : A frequent architectural mistake is assuming that a client with a Cognito User Pool ID token or Access token can call Amazon S3 or DynamoDB directly. User Pools produce JWTs, not AWS credentials. Clients must exchange the JWT through a Cognito Identity Pool to obtain SigV4-compatible STS temporary credentials.
ID Token vs. Access Token Validation : When integrating with Amazon API Gateway, the Cognito Authorizer validates the token. If authorization is based on OAuth scopes, you must pass the Access Token . If the authorizer or downstream service expects identity claims (e.g., email , sub ), passing an Access token will result in missing claims because identity claims exist only in the ID Token .
Client Secrets in Public Applications : When creating a Cognito App Client for Single-Page Web Applications (SPAs) or mobile apps, never generate a client secret . Public clients cannot securely store cryptographic secrets. Including a client secret in a browser or mobile app exposes the secret to reverse engineering and causes API calls that lack the SECRET_HASH parameter to fail.
Offline Token Verification without JWKS : Backend microservices verifying Cognito JWTs must not make an HTTP request to Cognito on every incoming call. Doing so introduces severe latency and triggers API rate limits. Microservices must cache the public keys from the Cognito .well-known/jwks.json endpoint and perform local cryptographic signature verification.