CWEweakness

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

Low Official page ↗
Abstraction
Base
Structure
Simple
Status
Incomplete
Likelihood of exploit
Low
Languages
Not Language-Specific
CWE version
5.0

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.

Extended description

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.

Common consequences

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

Related

Child of · CWE (1)

  • CWE-99 Improper Control of Resource Identifiers weakness

Referenced by CVE · weakness (19)

  • CVE-2026-85864 Improper privilege management in Python allows an authorized attacker to elevate privileges locally. vulnerability
  • CVE-2026-20282 A vulnerability in Cisco ISE could allow an authenticated, remote attacker to obtain write access on the underlying operating system of an… vulnerability
  • CVE-2026-46581 In Eclipse Mojarra versions 2.3 and following, URL handing in `DefaultFaceletFactory` does not properly sanitize and/or block remote URLs,… vulnerability
  • CVE-2026-50510 Improper restriction of names for files and other resources in Github Copilot allows an unauthorized attacker to execute code locally. vulnerability
  • CVE-2026-50023 yt-dlp is a command-line audio/video downloader. vulnerability
  • CVE-2026-27140 SWIG file names containing 'cgo' and well-crafted payloads could lead to code smuggling and arbitrary code execution at build time due to… vulnerability
  • CVE-2019-25623 Luminance Studio 2.17 contains a denial of service vulnerability that allows local attackers to crash the application by providing… vulnerability
  • CVE-2026-25177 Improper restriction of names for files and other resources in Active Directory Domain Services allows an authorized attacker to elevate… vulnerability
  • CVE-2025-47173 Improper input validation in Microsoft Office allows an unauthorized attacker to execute code locally. vulnerability
  • CVE-2025-47953 Use after free in Microsoft Office allows an unauthorized attacker to execute code locally. vulnerability
  • CVE-2024-47260 51l3nc3, member of the AXIS OS Bug Bounty Program, has found that the VAPIX API mediaclip.cgi did not have a sufficient input validation… vulnerability
  • CVE-2025-21361 Microsoft Outlook Remote Code Execution Vulnerability vulnerability
  • CVE-2025-21402 Microsoft Office OneNote Remote Code Execution Vulnerability vulnerability
  • CVE-2024-45312 Overleaf is a web-based collaborative LaTeX editor. vulnerability
  • CVE-2024-30063 Windows Distributed File System (DFS) Remote Code Execution Vulnerability vulnerability
  • CVE-2023-0046 Improper Restriction of Names for Files and Other Resources in GitHub repository lirantal/daloradius prior to master-branch. vulnerability
  • CVE-2022-23536 Cortex provides multi-tenant, long term storage for Prometheus. vulnerability
  • CVE-2022-36302 File path manipulation vulnerability in BF-OS version 3.00 up to and including 3.83 allows an attacker to modify the file path to access… vulnerability
  • CVE-2021-41146 qutebrowser is an open source keyboard-focused browser with a minimal GUI. vulnerability