---
title: "CWE-363: Race Condition Enabling Link Following"
url: https://radicalnotion.ai/cwe/cwe-363
type: cwe
description: "The product checks the status of a file or directory before accessing it, which produces a race condition in which the file can be replaced with a link before the access is performed, causing the product to access the wrong file."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-363: Race Condition Enabling Link Following

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 12
- **Of those, in CISA KEV:** 0
- **New in 2026:** 7
- **CWE catalog version:** 4.21

## Description

The product checks the status of a file or directory before accessing it, which produces a race condition in which the file can be replaced with a link before the access is performed, causing the product to access the wrong file.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | Developers might assume that there is a very narrow time window between the time of check and time of use, but there is still a race condition. |
| Implementation | - |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality, Integrity | Read Files or Directories, Modify Files or Directories | An attacker could cause the product to slow down (e.g. with memory consumption), causing the time window to become larger. Alternately, in some situations, the attacker could win the race by performing a large number of attacks. |

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

This code prints the contents of a file if a user has permission.

Bad code:

```php
function readFile($filename){
    $user = getCurrentUser();

    //resolve file if its a symbolic link
    if(is_link($filename)){
        $filename = readlink($filename);
    }

    if(fileowner($filename) == $user){
        echo file_get_contents($realFile);
        return;
    }
    else{
        echo 'Access denied';
        return false;
    }
}
```

This code attempts to resolve symbolic links before checking the file and printing its contents. However, an attacker may be able to change the file from a real file to a symbolic link between the calls to is\_link() and file\_get\_contents(), allowing the reading of arbitrary files. Note that this code fails to log the attempted access (CWE-778).

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2025-62161 | youki container escape via "masked path" abuse due to mount race conditions | high | 7.3 | - | No | 2025-11-05 |
| CVE-2022-21658 | Race condition in std::fs::remove\_dir\_all in rustlang | high | 7.3 | - | No | 2022-01-20 |
| CVE-2026-112940 | filelock ReadWriteLock: SQLite reopens the lock database by name, so a planted symlink or journal file makes the lock user's process overwrite or unlink its own files | high | 7.1 | - | No | 2026-10-20 |
| CVE-2026-71125 | Oracle VM VirtualBox: Core - denial of service and unauthorized data modification | medium | 6.1 | - | No | 2026-08-18 |
| CVE-2026-91203 | Cockpit-files: cockpit-files: arbitrary file ownership and permission modification via symlink race condition | medium | 6.0 | - | No | 2026-09-18 |
| CVE-2026-91205 | Cockpit-files: cockpit-files: local attacker can hijack file ownership via symlink race | medium | 6.0 | - | No | 2026-09-18 |
| CVE-2026-112938 | filelock: StrictSoftFileLock follows a symbolic link swapped in at .filelock and creates claim files in a directory another local user chooses | medium | 5.8 | - | No | 2026-11-05 |
| CVE-2025-13492 | HP Image Assistant - Potential Escalation of Privilege | medium | 5.4 | - | No | 2025-12-03 |
| CVE-2026-112914 | filelock: SoftFileLock stale-break restore follows a swapped-in symbolic link and hard-links a file of the user running the lock into the lock directory | medium | 5.3 | - | No | 2026-10-20 |
| CVE-2018-6693 | Endpoint Security for Linux Threat Prevention (ENSLTP) privilege escalation vulnerability | medium | 5.3 | - | No | 2018-09-18 |
| CVE-2024-45310 | runc can be confused to create empty files/directories on the host | medium | 4.8 | - | No | 2024-09-03 |
| CVE-2026-27139 | FileInfo can escape from a Root in os | low | 2.5 | - | No | 2026-03-06 |

## Related attack patterns (CAPEC)

- [CAPEC-26](https://radicalnotion.ai/capec/capec-26): Leveraging Race Conditions

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-367](https://radicalnotion.ai/cwe/cwe-367) | Time-of-check Time-of-use (TOCTOU) Race Condition |
| Can precede | [CWE-59](https://radicalnotion.ai/cwe/cwe-59) | Improper Link Resolution Before File Access |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Race condition enabling link following | - | - |
| CERT C Secure Coding | Avoid race conditions while checking for the existence of a symbolic link | POS35-C | Exact |
| Software Fault Patterns | Race Condition Window | SFP20 | - |

## Frequently asked questions

### What is CWE-363?

The product checks the status of a file or directory before accessing it, which produces a race condition in which the file can be replaced with a link before the access is performed, causing the product to access the wrong file.

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

12 recorded CVEs are attributed to CWE-363, including CVE-2025-62161, CVE-2022-21658 and CVE-2026-112940.

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

Exploiting CWE-363 can lead to: Read Files or Directories, Modify Files or Directories.

### Is CWE-363 actively exploited?

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

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

---

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