CWE-378: Creation of Temporary File With Insecure Permissions

Base Draft Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

Opening temporary files without appropriate measures or controls can leave the file, its contents and any function that it impacts vulnerable to attack.

常见后果

影响范围: Confidentiality

技术影响: Read Application Data

说明: If the temporary file can be read by the attacker, sensitive information may be in that file which could be revealed.

影响范围: Authorization Other

技术影响: Other

说明: If that file can be written to by the attacker, the file might be moved into a place to which the attacker does not have access. This will allow the attacker to gain selective resource access-control privileges.

影响范围: Integrity Other

技术影响: Other

说明: Depending on the data stored in the temporary file, there is the potential for an attacker to gain an additional input vector which is trusted as non-malicious. It may be possible to make arbitrary changes to data structures, user information, or even process ownership.

潜在缓解措施

阶段: Requirements

描述: Many contemporary languages have functions which properly handle this condition. Older C temp file functions are especially susceptible.

阶段: Implementation

描述: Ensure that you use proper file permissions. This can be achieved by using a safe temp file function. Temporary files should be writable and readable only by the process that owns the file.

阶段: Implementation

描述: Randomize temporary file names. This can also be achieved by using a safe temp-file function. This will ensure that temporary files will not be created in predictable places.

观察示例

参考: CVE-2022-24823

A network application framework uses the Java function createTempFile(), which will create a file that is readable by other local users of the system

引入模式

阶段 说明
Implementation -

适用平台

编程语言
Not Language-Specific (Undetermined)

分类映射

分类名称 条目ID 条目名称 映射适配度
CLASP - Improper temp file opening -
关键信息

CWE ID: CWE-378

抽象级别: Base

结构: Simple

状态: Draft

利用可能性: High

相关弱点