---
title: "CWE-378: Creation of Temporary File With Insecure Permissions"
url: https://radicalnotion.ai/cwe/cwe-378
type: cwe
description: "Opening temporary files without appropriate measures or controls can leave the file, its contents and any function that it impacts vulnerable to attack."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-378: Creation of Temporary File With Insecure Permissions

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **Likelihood of exploit:** High
- **CVEs with this as primary weakness:** 44
- **Of those, in CISA KEV:** 0
- **New in 2026:** 9
- **CWE catalog version:** 4.21

## Description

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

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| 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. |

## Potential mitigations

### 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.

## Detection methods

### 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.)

## Demonstrative examples

### Example 1

In the following code examples a temporary file is created and written to. After using the temporary file, the file is closed and deleted from the file system.

Bad code:

```c
FILE *stream;
if( (stream = tmpfile()) == NULL ) {

    perror("Could not open new temporary file\n");
    return (-1);
}
// write data to tmp file
...
// remove tmp file
rmtmp();
```

Bad code:

```java
try {
    File temp = File.createTempFile("pattern", ".suffix");
    temp.deleteOnExit();
    BufferedWriter out = new BufferedWriter(new FileWriter(temp));
    out.write("aString");
    out.close();
}
catch (IOException e) {
}
```

## Observed examples

| CVE | Description |
| --- | --- |
| 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 |
| CVE-2022-41954 | A library uses the Java File.createTempFile() method which creates a file with "-rw-r--r--" default permissions on Unix-like operating systems |

## Real CVEs with this weakness (sample of 12 of 44)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2024-39872 | Creation of Temporary File With Insecure Permissions in Siemens Remote Connect Server | critical | 9.3 | - | No | 2024-07-09 |
| CVE-2026-25265 | Creation of Temporary File with Insecure Permissions in Qualcomm Software Center | high | 8.8 | - | No | 2026-09-22 |
| CVE-2025-32438 | Local privilege escalation in make-initrd-ng | high | 8.8 | - | No | 2025-04-15 |
| CVE-2025-27148 | Gradle vulnerable to local privilege escalation through system temporary directory | high | 8.8 | - | No | 2025-02-25 |
| CVE-2025-34352 | JumpCloud Remote Assist \< 0.317.0 Arbitrary File Write/Delete via Insecure Temp Directory | high | 8.5 | - | No | 2025-12-02 |
| CVE-2024-7358 | Point B Ltd Getscreen Agent MSI Installer getscreen.msi temp file | high | 8.5 | - | No | 2024-08-01 |
| CVE-2026-4137 | Incomplete Fix for CVE-2025-10279: Insecure Temporary Directory Permissions in mlflow/mlflow | high | 7.8 | - | No | 2026-05-18 |
| CVE-2025-46685 | - | high | 7.8 | - | No | 2026-01-13 |
| CVE-2025-38747 | - | high | 7.8 | - | No | 2025-08-06 |
| CVE-2024-42052 | - | high | 7.8 | - | No | 2024-07-28 |
| CVE-2022-24411 | - | high | 7.8 | - | No | 2022-04-12 |
| CVE-2021-25654 | Avaya Aura Device Services Arbitrary Code Execution Vulnerability | high | 7.8 | - | No | 2021-06-25 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-377](https://radicalnotion.ai/cwe/cwe-377) | DEPRECATED: Insecure Temporary File |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CLASP | Improper temp file opening | - | - |

## Frequently asked questions

### What is CWE-378?

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

### What CVEs are caused by CWE-378?

44 recorded CVEs are attributed to CWE-378, including CVE-2024-39872, CVE-2026-25265 and CVE-2025-32438.

### How do you prevent CWE-378?

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

### How is CWE-378 detected?

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.)

### What are the consequences of CWE-378?

Exploiting CWE-378 can lead to: Read Application Data, Other.

### Is CWE-378 actively exploited?

44 recorded CVEs are caused by CWE-378; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/378.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-378). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
