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

What is CWE-646?

CWE-646 is Reliance on File Name or Extension of Externally-Supplied File. The flaw arises when 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. The database currently holds 3 vulnerabilities mapped to CWE-646 and none of them are in the CISA Known Exploited Vulnerabilities catalog.

OWASP Top 10 (2025) rank6 — A06:2025 — Insecure Design
Related CVES (365 days)3
AbstractionBase
Likelihood of exploitHigh

Vulnerabilities mapped to CWE-646

3 vulnerabilities

No data

No vulnerability data in CISA KEV for CWE-646

Official definition

ByMitre CWE

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, causing the wrong action to occur.

Characteristics

Modes of introduction

  • Architecture and Design: 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. (All Phases: Architecture and Design, Implementation, Operation)

Common consequences

ImpactScopeExplanation
Execute Unauthorized Code or CommandsIntegrityIf an attacker can provide a file that is treated as executable, then code execution might be possible. For example, in a web application, 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 by the server.
Read Application DataConfidentialityAn attacker may be able to read sensitive data, e.g., exposure of debug or system data (including application source code)
DoS: Crash, Exit, or Restart, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory), DoS: Resource Consumption (Other)AvailabilityAn attacker may be able to cause a denial of service.
Gain Privileges or Assume IdentityAccess ControlAn attacker may be able to gain privileges.

Risk mitigations

  1. Architecture and DesignMake decisions on the server side based on file content and not on file name or extension.
Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.