Insertion of Sensitive Information into Log File in aws-cdk-lib when using Cognito UserPoolClient Construct
Medium6.5Published Mar 31, 2025
### Summary The [AWS Cloud Development Kit (CDK)](https://aws.amazon.com/cdk/) is an open-source framework for defining cloud infrastructure using code. Customers use it to create their own applications which are converted to AWS CloudFormation templates during deployment to a customer’s AWS account. CDK contains pre-built components called "[constructs](https://docs.aws.amazon.com/cdk/v2/guide/constructs.html)" that are higher-level abstractions providing defaults and best practices. This approach enables developers to use familiar programming languages to define complex cloud infrastructure more efficiently than writing raw CloudFormation templates. The CDK [Cognito UserPool](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.UserPool.html) construct deploys an AWS cognito user pool. An [Amazon Cognito user pool](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools.html) is a user directory for web and mobile app authentication and authorization. Customers can deploy a client under this user pool through construct ‘[UserPoolClient](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.UserPoolClient.html)’ or through helper ...
Affected versions
| Package | Affected | Fixed in |
|---|---|---|
| aws-cdk-lib npm | >= 2.37.0, < 2.187.0 | 2.187.0 |
Details and references
### Summary The [AWS Cloud Development Kit (CDK)](https://aws.amazon.com/cdk/) is an open-source framework for defining cloud infrastructure using code. Customers use it to create their own applications which are converted to AWS CloudFormation templates during deployment to a customer’s AWS account. CDK contains pre-built components called "[constructs](https://docs.aws.amazon.com/cdk/v2/guide/constructs.html)" that are higher-level abstractions providing defaults and best practices. This approach enables developers to use familiar programming languages to define complex cloud infrastructure more efficiently than writing raw CloudFormation templates. The CDK [Cognito UserPool](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.UserPool.html) construct deploys an AWS cognito user pool. An [Amazon Cognito user pool](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools.html) is a user directory for web and mobile app authentication and authorization. Customers can deploy a client under this user pool through construct ‘[UserPoolClient](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.UserPoolClient.html)’ or through helper method '[addClient](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.UserPool.html#addwbrclientid-options)'. A user pool client resource represents an Amazon [Cognito user pool client](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-client-apps.html) which is a configuration within a user pool that interacts with one mobile or web application authenticating with Amazon Cognito. When users of the 'cognito.UserPoolClient' construct generate a secret value for the application client in AWS CDK, they can then reference the generated secrets in their stack. The CDK had an issue where, when the custom resource performed an SDK API call to 'DescribeCognitoUserPoolClient' to retrieve the generated secret, the full response was logged in the associated lambda function's log group. Any user authenticated in the account where logs of the custom resource are accessible and who has read-only permission could view the secret written to those logs. This issue does not affect customers who are generating the secret value outside of the CDK as the secret is not referenced or logged. ### Impact To leverage this issue, an actor has to be authenticated in the account where logs of the custom resource Custom::DescribeCognitoUserPoolClient are accessible and have read-only permission for lambda function logs. Users can review access to their log group through AWS CloudTrail logs to detect any unexpected access to read the logs. **Impacted versions: >2.37.0 and <=2.187.0** ### Patches The patches are included in the AWS CDK Library release v2.187.0. We recommend upgrading to the latest version and ensuring any forked or derivative code is patched to incorporate the new fixes. To fully address this issue, users should rotate the secret by generating a new secret stored in AWS Secrets Manager. References to the secret will use the new secret on update. When new CDK applications using the latest version are initialized, they will use the new behavior with updated logging. Existing applications must upgrade to the latest version, change the [feature flag](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md) (@aws-cdk/cognito:logUserPoolClientSecretValue) to false, redeploy the application to apply this fix and use the new implementation with updated logging behavior. ### Workarounds Users can override the implementation changing Logging to be Logging.withDataHidden(). For example define class CustomUserPoolClient extends UserPoolClient and in the new class define get userPoolClientSecret() to use Logging.withDataHidden(). Example export class CustomUserPoolClient extends UserPoolClient { private readonly customUserPool : UserPool;
- CVSS 3.1
- CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
- Severity from
- GitHub (reviewed advisory)
- Weakness
- CWE-532
More AWS advisories
All AWS| Date | Advisory | Severity | Fixed in |
|---|---|---|---|
| Apr 152025 | Aspect order change causes different Permissions Boundary assigned to Role | Low2.2 | 2.189.1 |
| Mar 312025 | Path Traversal in AWS SAM CLI allows file copy to local cache | Medium6.5 | 1.134.0 |
| Mar 312025 | Path Traversal in AWS SAM CLI allows file copy to build container | Medium6.5 | 1.133.0 |
| Mar 222025 | AWS CDK CodePipeline: trusted entities are too broad | Low3.8 | 2.189.0 |
| Mar 212025 | AWS CDK CLI prints AWS credentials retrieved by custom credential plugins | Medium5.7 | 2.178.2+1 more |
| Jan 172025 | IAM OIDC custom resource allows connection to unauthorized OIDC provider | Low | 2.177.0 |