2. Vulnerability Information

3. Vulnerability Description

When a file is created on a Windows system, a DOS-compatible 8.3 short file name (hereafter referred to as '8.3 alias') is generated for backwards compatibility reasons. Both names can be used to refer to the same file. Applications which allow users to specify file names on Windows systems should be aware of these aliases and handle them appropriately.

Often, by using 8.3 aliases for files, one can bypass IDS/IPS detection, and evade filters and file restrictions. This can be a result of the fact that only the long versions of file and folder names will be restricted and the alias will not match the long filename.

Referencing files using their 8.3 aliases can even change how the files are handled, due to truncation of the file extension in the event that the file extension is longer than three characters. This problem is exacerbated by the fact that intermediary systems used for things like load balancing and caching do not have access to the actual file system being accessed and need to convert any filenames and pathnames with restrictions to their 8.3 alias before comparing to user data, which, given the presence of other files or folders on the system with similar names, may not be possible.

This advisory describes multiples vulnerabilities based on quirks in how Windows handles file names. The affected software is the Windows version of the following web servers:

Nginx Web Server [1]. The way Nginx handles files may differ when they are requested using their 8.3 alias, and short file or path names are not correctly handled when applying file handling rules or access restrictions. By abusing of these flaws an attacker can bypass security options implemented in the web server. For instance, file.shtml will become FILE~1.SHT. This will cause the file to be handled as a .sht file, not a .shtml file. The result of this is that instead of processing SSI directives as would normally be the case with a .shtml file, the file would be served unprocessed. Additionally, Nginx does not correctly handle extraneous spaces after file extensions when applying preprocessing rules or access restrictions.

Cherokee Web Server [2]. On Cherokee Web Server for Windows, short file and folder names are not correctly handled when applying file handling rules, IP access restrictions or authentication rules. Extraneous trailing spaces in file names are not correctly handled when applying file handling rules or access restrictions. By abusing of these flaws, Cherokee configuration folders can be accessed from any IP, without authentication bypassing the web server security protection mechanisms.

Mongoose Web Server [3]. Mongoose does not correctly handle Windows short file names (and folder names) when applying preprocessing rules or access restrictions. As a result, an attacker can bypass the web server security protection mechanisms, and protected files can be accessed unprocessed without authentication.

LightTPD Web Server. The WLMP build of LightTPD for Windows [4] does not correctly handle Windows short file or path names when applying preprocessing rules, file extension restrictions or access restrictions. It also does not correctly handle extraneous trailing periods when applying file extension restrictions, but does properly apply preprocessing rules.

5. Non-vulnerable packages

6. Vendor Information, Solutions and Workarounds

Attacks using 8.3 aliases can be mitigated by turning off 8.3 alias generation, by setting the value of NtfsDisable8dot3NameCreation to 1 in HKLM\System\CurrentControlSet\Control\FileSystem.

7. Credits

These vulnerabilities were discovered and researched by Dan Crowley from Core Security Technologies.

8. Technical Description / Proof of Concept Code

8.1. Nginx Web Server

The following configuration snippet for Nginx Web Server will process any file with an extension of .phtml or .php by passing it to another service running locally on port 8080 for processing. It will deny requests for files beginning with .ht and the directory longfoldername.

Nginx Web Server will serve the unprocessed source code for files normally intended to be preprocessed when using URIs similar to the following (these examples assume the presence of the files file.phtml and file.php:

Similarly, if a file can be uploaded whose extension, when truncated to three characters, matches an extension which Nginx is set to process as code, it can be run as code by referring to it with an 8.3 alias. For instance, if a file named file.phpx is uploaded to the webroot, it can be executed as PHP code with the following URI:

8.2. Cherokee Web Server

The following configuration snippet for Cherokee Web Server will allow only requests from 1.2.3.4 to reach the directory longfoldername and additionally, requires a password defined in /Program Files/Octality/Cherokee/etc/passwd in order to gain access.

Similarly, if a file can be uploaded whose extension, when truncated to three characters, matches an extension which Cherokee is set to process as code, it can be run as code by referring to it with an 8.3 alias. For instance, if a file named file.phpx is uploaded to the webroot, it can be executed as PHP code with the following URI:

8.3. Mongoose Web Server

The following configuration snippet will cause Mongoose to process files with extensions of .php or .phtml as PHP code, and files with extensions of .shtml will be processed for SSI directives. It will also require a password (stored in C:\passwords.txt) when attempting to access the folder /longfoldername.

Similarly, if a file can be uploaded whose extension, when truncated to three characters, matches an extension which Mongoose is set to process as code, it can be run as code by referring to it with an 8.3 alias. For instance, if a file named file.phpx is uploaded to the webroot, it can be executed as PHP code with the following URI:

8.4. LightTPD Web Server (WLMP package)

The following configuration snippet for WLMP will forbid any file with the extensions .inc or .exte, attempt to process files with a .phtml or .php extension for PHP code, and authenticate users attempting to access the directory /longfoldername.

The unprocessed contents of a .inc, .phtml, or .exte file under this configuration could be accessed using URIs like the following (these URIs assume files named file.inc, longfilename.exte and file.phtml exist:

Similarly, if a file can be uploaded whose extension, when truncated to three characters, matches an extension which LightTPD is set to process as code, it can be run as code by referring to it with an 8.3 alias. For instance, if a file named file.phpx is uploaded to the webroot, it can be executed as PHP code with the following URI:

9. Report Timeline

2010-01-12: Core Security Technologies notifies the Cherokee, Nginx and Mongoose teams of the vulnerability. Core also informs that Dan Crowley will be giving a presentation explaining these flaws at the security conference Shmoocon 2010 [5].

2010-01-12: The Cherokee and Mongoose teams ask Core for a technical description of the vulnerability.

2010-01-12: Technical details sent to Cherokee and Mongoose teams by Core.

2010-01-12: Cherokee team notifies Core that the issues have been evaluated and considered security vulnerabilities. Cherokee team also informs us that they are not currently shipping Windows binaries because they are aware of all this sort of issues. The Windows port has not received much attention for the last few years and it is far from being ready for production. Cherokee team also states that they will link Core advisory from their bug-tracker as soon as it is published. Currently the Windows port is still low-priority for Cherokee project.

2010-01-13: The Nginx team asks Core for a technical description of the vulnerability.

2010-01-13: Technical details sent to Nginx team by Core.

2010-01-15: Nginx team informs us that the investigation about the reported issues has finished, the issues have been evaluated and Nginx team agrees that they are security vulnerabilities. The Nginx team also notifies us that they will fix it in next versions that will be released on Jan 18 or 25.

2010-02-01: Nginx team releases a new version of the web server (nginx-0.8.33) [6].

2010-02-05: The flaws are disclosed by Dan Crowley at the security conference Shmoocon 2010 [5].

11. About CoreLabs

CoreLabs, the research center of Core Security Technologies, is charged with anticipating the future needs and requirements for information security technologies. We conduct our research in several important areas of computer security including system vulnerabilities, cyber attack planning and simulation, source code auditing, and cryptography. Our results include problem formalization, identification of vulnerabilities, novel solutions and prototypes for new technologies. CoreLabs regularly publishes security advisories, technical papers, project information and shared software tools for public use at: http://www.coresecurity.com/corelabs.

12. About Core Security Technologies

Core Security Technologies develops strategic solutions that help security-conscious organizations worldwide develop and maintain a proactive process for securing their networks. The company's flagship product, CORE IMPACT, is the most comprehensive product for performing enterprise security assurance testing. CORE IMPACT evaluates network, endpoint and end-user vulnerabilities and identifies what resources are exposed. It enables organizations to determine if current security investments are detecting and preventing attacks. Core Security Technologies augments its leading technology solution with world-class security consulting services, including penetration testing and software security auditing. Based in Boston, MA and Buenos Aires, Argentina, Core Security Technologies can be reached at 617-399-6980 or on the Web at http://www.coresecurity.com.

13. Disclaimer

The contents of this advisory are copyright (c) 2010 Core Security Technologies and (c) 2010 CoreLabs, and may be distributed freely provided that no fee is charged for this distribution and proper credit is given.