CVE-2022-39382: CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') in keystonejs keystone
Keystone is a headless CMS for Node.js — built with GraphQL and React.`@keystone-6/core@3.0.0 || 3.0.1` users that use `NODE_ENV` to trigger security-sensitive functionality in their production builds are vulnerable to `NODE_ENV` being inlined to `"development"` for user code, irrespective of what your environment variables. If you do not use `NODE_ENV` in your user code to trigger security-sensitive functionality, you are not impacted by this vulnerability. Any dependencies that use `NODE_ENV` to trigger particular behaviors (optimizations, security or otherwise) should still respect your environment's configured `NODE_ENV` variable. The application's dependencies, as found in `node_modules` (including `@keystone-6/core`), are typically not compiled as part of this process, and thus should be unaffected. We have tested this assumption by verifying that `NODE_ENV=production yarn keystone start` still uses secure cookies when using `statelessSessions`. This vulnerability has been fixed in @keystone-6/core@3.0.2, regression tests have been added for this vulnerability in #8063.
AI Analysis
Technical Summary
CVE-2022-39382 is a medium-severity vulnerability affecting KeystoneJS, a popular headless CMS built on Node.js that leverages GraphQL and React. The vulnerability arises from improper handling of the NODE_ENV environment variable in versions @keystone-6/core 3.0.0 and 3.0.1. Specifically, user code that relies on NODE_ENV to trigger security-sensitive functionality can be misled because NODE_ENV is inlined as "development" during production builds, regardless of the actual environment variable setting. This improper neutralization of special elements in output used by a downstream component constitutes an injection flaw classified under CWE-74. The issue does not affect dependencies in node_modules, which are typically not compiled during the build process, and secure cookie usage in statelessSessions remains intact when NODE_ENV is set to production. The vulnerability was addressed in version 3.0.2 of @keystone-6/core, with regression tests added to prevent recurrence. No known exploits have been reported in the wild. The root cause is the build-time inlining of NODE_ENV to "development," which can cause security-sensitive code paths to execute in production environments, potentially exposing sensitive functionality or weakening security controls. This can lead to unauthorized access or data leakage if developers use NODE_ENV as a security gate in their custom code.
Potential Impact
For European organizations using KeystoneJS versions 3.0.0 or 3.0.1, this vulnerability could lead to inadvertent exposure of security-sensitive functionality in production environments. Since KeystoneJS is often used to manage content and data for web applications, exploitation could compromise confidentiality and integrity of managed content or user data. The injection flaw could allow attackers to bypass security controls that rely on NODE_ENV checks, potentially enabling unauthorized data access or modification. Although no exploits are known in the wild, the risk is heightened for organizations that embed security logic dependent on NODE_ENV in their custom code. This could impact sectors with sensitive data such as finance, healthcare, and government services. The availability impact is likely limited, as the vulnerability primarily affects logic execution rather than causing denial of service. However, compromised data integrity or confidentiality could have significant regulatory and reputational consequences under GDPR and other European data protection laws.
Mitigation Recommendations
European organizations should immediately upgrade all KeystoneJS instances to version 3.0.2 or later to remediate this vulnerability. Additionally, developers should audit their codebases to identify any security-sensitive logic conditioned on NODE_ENV and refactor it to avoid relying on environment variables for security decisions. Implement runtime environment validation to ensure NODE_ENV is not overridden or inlined incorrectly during builds. Employ strict input validation and output encoding to mitigate injection risks. Use secure session management practices, such as statelessSessions with secure cookies, and verify these configurations post-upgrade. Incorporate automated regression testing for environment-dependent logic to detect similar issues early. Finally, monitor application logs for anomalous behavior that could indicate exploitation attempts and maintain up-to-date threat intelligence feeds to stay informed of any emerging exploits.
Affected Countries
Germany, France, United Kingdom, Netherlands, Sweden, Italy, Spain
CVE-2022-39382: CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') in keystonejs keystone
Description
Keystone is a headless CMS for Node.js — built with GraphQL and React.`@keystone-6/core@3.0.0 || 3.0.1` users that use `NODE_ENV` to trigger security-sensitive functionality in their production builds are vulnerable to `NODE_ENV` being inlined to `"development"` for user code, irrespective of what your environment variables. If you do not use `NODE_ENV` in your user code to trigger security-sensitive functionality, you are not impacted by this vulnerability. Any dependencies that use `NODE_ENV` to trigger particular behaviors (optimizations, security or otherwise) should still respect your environment's configured `NODE_ENV` variable. The application's dependencies, as found in `node_modules` (including `@keystone-6/core`), are typically not compiled as part of this process, and thus should be unaffected. We have tested this assumption by verifying that `NODE_ENV=production yarn keystone start` still uses secure cookies when using `statelessSessions`. This vulnerability has been fixed in @keystone-6/core@3.0.2, regression tests have been added for this vulnerability in #8063.
AI-Powered Analysis
Technical Analysis
CVE-2022-39382 is a medium-severity vulnerability affecting KeystoneJS, a popular headless CMS built on Node.js that leverages GraphQL and React. The vulnerability arises from improper handling of the NODE_ENV environment variable in versions @keystone-6/core 3.0.0 and 3.0.1. Specifically, user code that relies on NODE_ENV to trigger security-sensitive functionality can be misled because NODE_ENV is inlined as "development" during production builds, regardless of the actual environment variable setting. This improper neutralization of special elements in output used by a downstream component constitutes an injection flaw classified under CWE-74. The issue does not affect dependencies in node_modules, which are typically not compiled during the build process, and secure cookie usage in statelessSessions remains intact when NODE_ENV is set to production. The vulnerability was addressed in version 3.0.2 of @keystone-6/core, with regression tests added to prevent recurrence. No known exploits have been reported in the wild. The root cause is the build-time inlining of NODE_ENV to "development," which can cause security-sensitive code paths to execute in production environments, potentially exposing sensitive functionality or weakening security controls. This can lead to unauthorized access or data leakage if developers use NODE_ENV as a security gate in their custom code.
Potential Impact
For European organizations using KeystoneJS versions 3.0.0 or 3.0.1, this vulnerability could lead to inadvertent exposure of security-sensitive functionality in production environments. Since KeystoneJS is often used to manage content and data for web applications, exploitation could compromise confidentiality and integrity of managed content or user data. The injection flaw could allow attackers to bypass security controls that rely on NODE_ENV checks, potentially enabling unauthorized data access or modification. Although no exploits are known in the wild, the risk is heightened for organizations that embed security logic dependent on NODE_ENV in their custom code. This could impact sectors with sensitive data such as finance, healthcare, and government services. The availability impact is likely limited, as the vulnerability primarily affects logic execution rather than causing denial of service. However, compromised data integrity or confidentiality could have significant regulatory and reputational consequences under GDPR and other European data protection laws.
Mitigation Recommendations
European organizations should immediately upgrade all KeystoneJS instances to version 3.0.2 or later to remediate this vulnerability. Additionally, developers should audit their codebases to identify any security-sensitive logic conditioned on NODE_ENV and refactor it to avoid relying on environment variables for security decisions. Implement runtime environment validation to ensure NODE_ENV is not overridden or inlined incorrectly during builds. Employ strict input validation and output encoding to mitigate injection risks. Use secure session management practices, such as statelessSessions with secure cookies, and verify these configurations post-upgrade. Incorporate automated regression testing for environment-dependent logic to detect similar issues early. Finally, monitor application logs for anomalous behavior that could indicate exploitation attempts and maintain up-to-date threat intelligence feeds to stay informed of any emerging exploits.
Affected Countries
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2022-09-02T00:00:00.000Z
- Cisa Enriched
- true
Threat ID: 682d9849c4522896dcbf6c8a
Added to database: 5/21/2025, 9:09:29 AM
Last enriched: 6/21/2025, 9:23:34 PM
Last updated: 7/30/2025, 11:02:50 PM
Views: 10
Related Threats
CVE-2025-8293: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in Theerawat Patthawee Intl DateTime Calendar
MediumCVE-2025-7686: CWE-352 Cross-Site Request Forgery (CSRF) in lmyoaoa weichuncai(WP伪春菜)
MediumCVE-2025-7684: CWE-352 Cross-Site Request Forgery (CSRF) in remysharp Last.fm Recent Album Artwork
MediumCVE-2025-7683: CWE-352 Cross-Site Request Forgery (CSRF) in janyksteenbeek LatestCheckins
MediumCVE-2025-7668: CWE-352 Cross-Site Request Forgery (CSRF) in timothyja Linux Promotional Plugin
MediumActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
External Links
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.