CWE-377 不安全的临时文件

Insecure Temporary File

结构: Simple

Abstraction: Base

状态: Incomplete

被利用可能性: unkown

基本描述

Creating and using insecure temporary files can leave application and system data vulnerable to attack.

相关缺陷

  • cwe_Nature: ChildOf cwe_CWE_ID: 668 cwe_View_ID: 1000 cwe_Ordinal: Primary

适用平台

Language: {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}

常见的影响

范围 影响 注释
['Confidentiality', 'Integrity'] ['Read Files or Directories', 'Modify Files or Directories']

示例代码

The following code uses a temporary file for storing intermediate data gathered from the network before it is processed.

bad C

if (tmpnam_r(filename)) {

FILE* tmp = fopen(filename,"wb+");
while((recv(sock,recvbuf,DATA_SIZE, 0) > 0)&(amt!=0)) amt = fwrite(recvbuf,1,DATA_SIZE,tmp);
}
...

This otherwise unremarkable code is vulnerable to a number of different attacks because it relies on an insecure method for creating temporary files. The vulnerabilities introduced by this function and others are described in the following sections. The most egregious security problems related to temporary file creation have occurred on Unix-based operating systems, but Windows applications have parallel risks. This section includes a discussion of temporary file creation on both Unix and Windows systems. Methods and behaviors can vary between systems, but the fundamental risks introduced by each are reasonably constant.

Notes

分类映射

映射的分类名 ImNode ID Fit Mapped Node Name
7 Pernicious Kingdoms Insecure Temporary File
CERT C Secure Coding CON33-C Imprecise Avoid race conditions when using library functions
The CERT Oracle Secure Coding Standard for Java (2011) FIO00-J Do not operate on files in shared directories

相关攻击模式

  • CAPEC-155

引用