---
title: "CWE-641: Improper Restriction of Names for Files and Other Resources"
url: https://radicalnotion.ai/cwe/cwe-641
type: cwe
description: "The product constructs the name of a file or other resource using input from an upstream component, but it does not restrict or incorrectly restricts the resulting name."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-641: Improper Restriction of Names for Files and Other Resources

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

## Description

The product constructs the name of a file or other resource using input from an upstream component, but it does not restrict or incorrectly restricts the resulting name.

This may produce resultant weaknesses. For instance, if the names of these resources contain scripting characters, it is possible that a script may get executed in the client's browser if the application ever displays the name of the resource on a dynamically generated web page. Alternately, if the resources are consumed by some application parser, a specially crafted name can exploit some vulnerability internal to the parser, potentially resulting in execution of arbitrary code on the server machine. The problems will vary based on the context of usage of such malformed resource names and whether vulnerabilities are present in or assumptions are made by the targeted technology that would make code execution possible.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Architecture and Design | - |
| Implementation | REALIZATION: This weakness is caused during implementation of an architectural security tactic. |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity, Confidentiality, Availability | Execute Unauthorized Code or Commands | Execution of arbitrary code in the context of usage of the resources with dangerous names. |
| Confidentiality, Availability | Read Application Data, DoS: Crash, Exit, or Restart | Crash of the consumer code of these resources resulting in information leakage or denial of service. |

## Potential mitigations

### Architecture and Design

Do not allow users to control names of resources used on the server side.

### Architecture and Design

Perform allowlist input validation at entry points and also before consuming the resources. Reject bad file names rather than trying to cleanse them.

### Architecture and Design

Make sure that technologies consuming the resources are not vulnerable (e.g. buffer overflow, format string, etc.) in a way that would allow code execution if the name of the resource is malformed.

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

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-50023 | yt-dlp: Dangerous file type creation via insufficient filename sanitization (Bypass of CVE-2024-38519) | critical | 9.6 | - | No | 2026-06-23 |
| CVE-2026-25177 | Active Directory Domain Services Elevation of Privilege Vulnerability | high | 8.8 | - | No | 2026-03-10 |
| CVE-2022-36302 | - | high | 8.8 | - | No | 2022-08-01 |
| CVE-2025-47953 | Microsoft Office Remote Code Execution Vulnerability | high | 8.4 | - | No | 2025-06-10 |
| CVE-2026-85864 | Python Elevation of Privilege Vulnerability | high | 7.8 | - | No | 2026-10-13 |
| CVE-2026-50510 | GitHub Copilot Remote Code Execution Vulnerability | high | 7.8 | - | No | 2026-07-14 |
| CVE-2025-47173 | Microsoft Office Remote Code Execution Vulnerability | high | 7.8 | - | No | 2025-06-10 |
| CVE-2025-21402 | Microsoft Office OneNote Remote Code Execution Vulnerability | high | 7.8 | - | No | 2025-01-14 |
| CVE-2025-21361 | Microsoft Outlook Remote Code Execution Vulnerability | high | 7.8 | - | No | 2025-01-14 |
| CVE-2023-0046 | Improper Restriction of Names for Files and Other Resources in lirantal/daloradius | high | 7.2 | - | No | 2023-01-04 |
| CVE-2019-25623 | Luminance Studio 2.17 Denial of Service via Malformed Input | medium | 6.9 | - | No | 2026-03-23 |
| CVE-2024-30063 | Windows Distributed File System (DFS) Remote Code Execution Vulnerability | medium | 6.7 | - | No | 2024-06-11 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-99](https://radicalnotion.ai/cwe/cwe-99) | Improper Control of Resource Identifiers |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| Software Fault Patterns | Tainted input to command | SFP24 | - |

## Frequently asked questions

### What is CWE-641?

The product constructs the name of a file or other resource using input from an upstream component, but it does not restrict or incorrectly restricts the resulting name.

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

15 recorded CVEs are attributed to CWE-641, including CVE-2026-50023, CVE-2026-25177 and CVE-2022-36302.

### How do you prevent CWE-641?

Do not allow users to control names of resources used on the server side.

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

Exploiting CWE-641 can lead to: Execute Unauthorized Code or Commands, Read Application Data, DoS: Crash, Exit, or Restart.

### Is CWE-641 actively exploited?

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

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

---

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