Variant · Low-Medium

CWE-646: Reliance on File Name or Extension of Externally-Supplied File

The product allows a file to be uploaded, but it relies on the file name or extension of the file to determine the appropriate behaviors. This could be used by attackers to cause the file to be miscla...

CWE-646 · Variant Level ·1 Mitigations

Description

The product allows a file to be uploaded, but it relies on the file name or extension of the file to determine the appropriate behaviors. This could be used by attackers to cause the file to be misclassified and processed in a dangerous fashion.

An application might use the file name or extension of a user-supplied file to determine the proper course of action, such as selecting the correct process to which control should be passed, deciding what data should be made available, or what resources should be allocated. If the attacker can cause the code to misclassify the supplied file, then the wrong action could occur. For example, an attacker could supply a file that ends in a ".php.gif" extension that appears to be a GIF image, but would be processed as PHP code. In extreme cases, code execution is possible, but the attacker could also cause exhaustion of resources, denial of service, exposure of debug or system data (including application source code), or being bound to a particular server side process. This weakness may be due to a vulnerability in any of the technologies used by the web and application servers, due to misconfiguration, or resultant from another flaw in the application itself.

Potential Impact

Confidentiality

Read Application Data

Availability

DoS: Crash, Exit, or Restart

Access Control

Gain Privileges or Assume Identity

Mitigations & Prevention

Architecture and Design

Make decisions on the server side based on file content and not on file name or extension.

Frequently Asked Questions

What is CWE-646?

CWE-646 (Reliance on File Name or Extension of Externally-Supplied File) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Variant-level weakness. The product allows a file to be uploaded, but it relies on the file name or extension of the file to determine the appropriate behaviors. This could be used by attackers to cause the file to be miscla...

How can CWE-646 be exploited?

Attackers can exploit CWE-646 (Reliance on File Name or Extension of Externally-Supplied File) to read application data. This weakness is typically introduced during the Architecture and Design, Implementation, Operation phase of software development.

How do I prevent CWE-646?

Key mitigations include: Make decisions on the server side based on file content and not on file name or extension.

What is the severity of CWE-646?

CWE-646 is classified as a Variant-level weakness (Low-Medium abstraction). Its actual severity depends on the specific context and how the weakness manifests in your application.