CWE-526: Cleartext Storage of Sensitive Information in an Environment Variable

Variant Incomplete Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

The product uses an environment variable to store unencrypted sensitive information.

扩展描述

Information stored in an environment variable can be accessible by other processes with the execution context, including child processes that dependencies are executed in, or serverless functions in cloud environments. An environment variable's contents can also be inserted into messages, headers, log files, or other outputs. Often these other dependencies have no need to use the environment variable in question. A weakness that discloses environment variables could expose this information.

常见后果

影响范围: Confidentiality

技术影响: Read Application Data

潜在缓解措施

阶段: Architecture and Design

描述: Encrypt information stored in the environment variable to protect it from being exposed to an unauthorized user. If encryption is not feasible or is considered too expensive for the business use of the application, then consider using a properly protected configuration file instead of an environment variable. It should be understood that unencrypted information in a config file is also not guaranteed to be protected, but it is still a better choice, because it reduces attack surface related to weaknesses such as CWE-214. In some settings, vaults might be a feasible option for safer data transfer. Users should be notified of the business choice made to not protect the sensitive information through encryption.

阶段: Implementation

描述: If the environment variable is not necessary for the desired behavior, then remove it entirely, or clear it to an empty value.

检测方法

方法: Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

有效性: High

观察示例

参考: CVE-2022-43691

CMS shows sensitive server-side information from environment variables when run in Debug mode.

参考: CVE-2022-27195

Plugin for an automation server inserts environment variable contents into build XML files.

参考: CVE-2022-25264

CI/CD tool logs environment variables related to passwords add Contribution to content history.

引入模式

阶段 说明
Architecture and Design -
Implementation -
Operation -

分类映射

分类名称 条目ID 条目名称 映射适配度
Software Fault Patterns SFP23 Exposed Data -
关键信息

CWE ID: CWE-526

抽象级别: Variant

结构: Simple

状态: Incomplete

相关弱点