---
title: "CWE-379: Creation of Temporary File in Directory with Insecure Permissions"
url: https://radicalnotion.ai/cwe/cwe-379
type: cwe
description: "The product creates a temporary file in a directory whose permissions allow unintended actors to determine the file's existence or otherwise access that file."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-379: Creation of Temporary File in Directory with Insecure Permissions

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Incomplete
- **Likelihood of exploit:** Low
- **CVEs with this as primary weakness:** 64
- **Of those, in CISA KEV:** 0
- **New in 2026:** 20
- **CWE catalog version:** 4.21

## Description

The product creates a temporary file in a directory whose permissions allow unintended actors to determine the file's existence or otherwise access that file.

## Modes of introduction

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality | Read Application Data | On some operating systems, the fact that the temporary file exists may be apparent to any user with sufficient privileges to access that directory. Since the file is visible, the application that is using the temporary file could be known. If one has access to list the processes on the system, the attacker has gained information about what the user is doing at that time. By correlating this with the applications the user is running, an attacker could potentially discover what a user's actions are. From this, higher levels of security could be breached. |

## Potential mitigations

### Requirements

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

### Implementation

Try to store sensitive tempfiles in a directory which is not world readable -- i.e., per-user directories.

### Implementation

Avoid using vulnerable temp file functions.

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

Effectiveness: High

## 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-27818 | A hotkey daemon written in Rust creates a domain socket file underneath /tmp, which is accessible by any user. |
| CVE-2021-41989 | analytic platform's repair functionality uses the %TEMP% folder of a user while running with higher privileges |
| CVE-2021-21290 | A Java-based application for a rapid-development framework uses File.createTempFile() to create a random temporary file with insecure default permissions. |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2021-21363 | Generator Web Application: Local Privilege Escalation Vulnerability via System Temp Directory | critical | 9.3 | - | No | 2021-03-11 |
| CVE-2026-14551 | Local Privilege Escalation in servereye client (sensorhub) | high | 8.8 | - | No | 2026-07-22 |
| CVE-2024-36821 | - | high | 8.8 | - | No | 2024-06-11 |
| CVE-2023-49797 | Local Privilege Escalation in pyinstaller on Windows | high | 8.8 | - | No | 2023-12-09 |
| CVE-2021-29428 | Local privilege escalation through system temporary directory | high | 8.8 | - | No | 2021-04-13 |
| CVE-2024-9950 | Abuse of Unauthenticated Compliance Recheck in SecureConnector | high | 8.5 | - | No | 2025-01-02 |
| CVE-2026-86836 | - | high | 8.4 | - | No | 2026-09-14 |
| CVE-2026-123974 | pytorch/serve: Local privilege escalation through insecure temporary path | high | 7.8 | - | No | 2026-11-06 |
| CVE-2026-42191 | OpenTelemetry.Exporter.OpenTelemetryProtocol: Disk retry default temp path enables local blob injection for OTLP Exporter | high | 7.8 | - | No | 2026-05-12 |
| CVE-2024-9500 | Autodesk ADP Desktop SDK Privilege Escalation Vulnerability | high | 7.8 | - | No | 2024-11-15 |
| CVE-2023-6080 | Privilege Escalation to SYSTEM in Lakeside Software Installer | high | 7.8 | - | No | 2024-10-18 |
| CVE-2023-3181 | Insecure Permissions in Splashtop Software Updater | high | 7.8 | - | No | 2024-01-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 | Guessed or visible temporary file | - | - |
| CERT C Secure Coding | Ensure that file operations are performed in a secure directory | FIO15-C | - |

## Frequently asked questions

### What is CWE-379?

The product creates a temporary file in a directory whose permissions allow unintended actors to determine the file's existence or otherwise access that file.

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

64 recorded CVEs are attributed to CWE-379, including CVE-2021-21363, CVE-2026-14551 and CVE-2024-36821.

### How do you prevent CWE-379?

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

### How is CWE-379 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-379?

Exploiting CWE-379 can lead to: Read Application Data.

### Is CWE-379 actively exploited?

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

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

---

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