Reliance on File Name or Extension of Externally-Supplied File

Incomplete Variant
Structure: Simple
Description

This vulnerability occurs when an application uses the name or extension of an uploaded file to decide how to handle it. Attackers can manipulate this by uploading files with deceptive names, causing the application to process them incorrectly and potentially dangerously.

Extended Description

Applications often inspect a file's name or extension to determine the next steps—like which interpreter to use, what data to display, or which resources to allocate. If an attacker uploads a file with a misleading name (e.g., 'malicious.php.gif'), the system might misclassify it and execute it as code instead of treating it as a simple image. This misclassification can lead directly to severe consequences, including remote code execution, denial of service, or unauthorized exposure of sensitive system or application data. This security flaw can stem from multiple sources: a weakness in the web server software itself, an insecure application configuration, or a separate bug in the application's logic. The core issue is trusting unvalidated, user-controlled input (the filename) to make critical security decisions. To prevent this, applications must never rely solely on file names or extensions; instead, they should use positive server-side validation of the file's actual content and type.

Common Consequences 3
Scope: Confidentiality

Impact: Read Application Data

An attacker may be able to read sensitive data.

Scope: Availability

Impact: DoS: Crash, Exit, or Restart

An attacker may be able to cause a denial of service.

Scope: Access Control

Impact: Gain Privileges or Assume Identity

An attacker may be able to gain privileges.

Potential Mitigations 1
Phase: Architecture and Design
Make decisions on the server side based on file content and not on file name or extension.
Likelihood of Exploit

High

Applicable Platforms
Languages:
Not Language-Specific : Undetermined
Technologies:
Web Server : Undetermined
Modes of Introduction
Architecture and Design
Implementation
Operation