NSFOCUS Security Advisory(SA2000-07) Topic: Microsoft IIS 4.0/5.0 CGI File Name Inspection Vulnerability Release Date£º Nov 7th, 2000 Update Date£º Nov 23rd, 2000 CVE Candidate Numbers: CAN-2000-0886 BUGTRAQ ID : 1912 Affected system: ================ - Microsoft IIS 4.0 - Microsoft IIS 5.0 Impact: ========= NSFOCUS security team has found a security flaw in Microsoft IIS 4.0/ 5.0 when handling a CGI file name. Exploitation of it, attacker can read system file and run arbitrary system command. Description£º ============ In CGI application (.exe, .pl, .php etc.) handling, Microsoft IIS 4.0/ 5.0 do not present an integrated security inspection of CGI file name, which may cause IIS to mistakenly open or run a file if a special character is contained in the file name. 1. Providing a malformed HTTP request that calls IIS to run a ".exe" or ".com" program under executable directory, IIS will try to load the program and check file existence and file type first. Attacker can trap the loading program to check a non-requested file by inserting a special character in the file name. If fulfilling these terms: (1) Target file exists (2) Target file is a batch file or ".cmd" file (3) Target file is a plain text file longer than zero byte IIS will automatically call "cmd.exe" to interpret it. Other part of file name requested is pass to "cmd.exe" as parameters of the batch file. Thus, an attacker can run arbitrary command by inserting some characters like "&". 2. If some script interpreter(php.exe, perl.exe etc.) and relevant mapping are installed, IIS will call them to interpret the file name submitted by user to run the corresponding CGI script. Inserting some special characters, attacker can trap the interpreter to open some file outside of WEB directory. Depending on the execution method of the interpreter, attacker may read part or even the full file content. Exploit: ========== 1. Run arbitrary command Create a batch file "test.bat" with arbitrary content like "abc" under an executable directory(e.g. /scripts ). Submit the following URL: http://site/scripts/test.bat"+&+dir+c:/+.exe (for IIS 5.0) or http://site/scripts/test.bat"+&+dir+c:/+.com You get file list under C:\ Double quotation marks will be attached on the executable file name by IIS. That's why the of request is turned into the following format when it is passed to "CMD.exe". CMD.exe "D:\interpub\scripts\test.bat" & dir C:/ .exe" So, an attacker can run arbitrary command with IUSER_machinename privilege, while the executable virtual directory is unnecessary to be on the same driver of "WINNT\system32\CMD.exe". For IIS 4.0 NSFOCUS INFORMATION TECHNOLOGY CO.,LTD (http://www.nsfocus.com)