CVE-2025-2598 — aws-cdk
CVE-2025-2598 is a CWE-497 vulnerability in aws-cdk. A fix is available for aws-cdk — see the affected versions and patch details below.
AWS CDK CLI prints AWS credentials retrieved by custom credential plugins
Exploitation Status
No confirmed exploitation observed yet
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for CVE-2025-2598.
EPSS Exploitation Probability
EPSS (Exploit Prediction Scoring System) is a daily probability model maintained by FIRST.org. It estimates the likelihood a CVE will be exploited in production environments within the next 30 days, derived from real-world threat intelligence signals.
Real-World Exposure
How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.
aws-cdknpmcdknpmDescription
Summary
The AWS Cloud Development Kit (AWS CDK) [1] is an open-source software development framework for defining cloud infrastructure in code and provisioning it through AWS CloudFormation. The AWS CDK CLI [2] is a command line tool for interacting with CDK applications. Customers can use the CDK CLI to create, manage, and deploy their AWS CDK projects.
An issue exists in the AWS CDK CLI where, under certain conditions, AWS credentials may be returned in the console output. Plugins that return an expiration property in the credentials object are affected by this issue. Plugins that omit the expiration property are not affected.
Impact
When customers run AWS CDK CLI commands with credential plugins and configure those plugins to return temporary credentials by including an expiration property, the AWS credentials retrieved by the plugin may be returned in the console output. Any user with access where the CDK CLI was ran would have access to this output.
The following are examples of configuring a custom credential plugin:
Via command line option:
cdk deploy --plugin /path/to/plugin
Via configuration file [3]:
{
"plugin": "/path/to/plugin"
}
Plugins that return an expiration property in the credentials object, such as the following example, are affected:
return {
accessKeyId: '<access-key>',
secretAccessKey: '<secret-access-key>',
sessionToken: '<session-token>',
expiration: <date>,
};
The expiration property indicates that the provided credentials are temporary.
Please refer to our "AWS CDK CLI Library" guide for more information about custom credential plugins [4].
Impacted versions: >=2.172.0 and <2.178.2
Patches
The issue has been addressed in version 2.178.2 [5]. We recommend upgrading to the latest version and ensuring any forked or derivative code is patched to incorporate the new fixes.
Workarounds
If you are unable to upgrade to version 2.178.2 or later, you can downgrade to version 2.171.1. If you are unable to downgrade, but have access to the code of the credential plugin you use, you can remove the expiration property from the object returned by the plugin.
For example, change the code from returning this:
return {
accessKeyId: assumeRoleOutput.Credentials.AccessKeyId,
secretAccessKey: assumeRoleOutput.Credentials.SecretAccessKey,
sessionToken: assumeRoleOutput.Credentials.SessionToken,
// Expiration indicates to the CLI that this is temporary
expiration: assumeRoleOutput.Credentials.Expiration,
};
To return this:
return {
accessKeyId: assumeRoleOutput.Credentials.AccessKeyId,
secretAccessKey: assumeRoleOutput.Credentials.SecretAccessKey,
sessionToken: assumeRoleOutput.Credentials.SessionToken,
};
Note that this will prevent the CDK CLI from refreshing the credentials when needed, and may cause your workflow to fail on an expired credentials error.
References
[1] https://docs.aws.amazon.com/cdk/v2/guide/home.html
[2] https://docs.aws.amazon.com/cdk/v2/guide/cli.html
[3] https://docs.aws.amazon.com/cdk/v2/guide/cli.html#cli-config
[4] https://www.npmjs.com/package/@aws-cdk/cli-plugin-contract
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | aws-cdk | ≥ 2.172.0&&< 2.178.2 | 2.178.2npm install aws-cdk@2.178.2 |
| 📦npm | cdk | ≥ 2.172.0&&< 2.178.2 | 2.178.2npm install cdk@2.178.2 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for aws-cdk, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update aws-cdk to 2.178.2 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2025-2598 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 Security's impact-aware SCA analyses which vulnerable code paths your application actually calls, so a match like CVE-2025-2598 can be triaged on real exposure rather than presence alone.
Tailored to CVE-2025-2598. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is CVE-2025-2598 in your dependencies?
O3 Security finds CVE-2025-2598 across npm dependencies, including transitive ones, and its impact-aware SCA ranks findings by whether your code actually calls the vulnerable path.