<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
  <channel>
    <title><![CDATA[[SecurityRatty] tag: libtiff]]></title>
    <link>http://securityratty.com/tag/libtiff</link>
    <description></description>
    <pubDate>Mon, 08 Oct 2007 12:13:00 +0000</pubDate>
    <generator>iRatty Engine</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <item>
      <title><![CDATA[Auditing open source software]]></title>
      <link>http://securityratty.com/article/59467548fd840375c0d60473f6181fe5</link>
      <guid>http://securityratty.com/article/59467548fd840375c0d60473f6181fe5</guid>
      <description><![CDATA[Written by Chris Evans, Security Team

Google encourages its employees to contribute back to the open source community, and there is no exception in Google's Security Team. Let's look at some...]]></description>
      <content:encoded><![CDATA[<span class="byline-author">Written by Chris Evans, Security Team</span><br /><br />Google encourages its employees to contribute back to the open source community, and there is no exception in Google's Security Team. Let's look at some interesting open source vulnerabilities that were located and fixed by members of Google's Security team. It is interesting to classify and aggregate the code flaws leading to the vulnerabilities, to see if any particular type of flaw is more prevalent.<br /><ol><li><b>JDK</b>. In May 2007, I <a title="released details" href="http://scary.beasts.org/security/CESA-2006-004.html" id="ro-g">released details</a> on an interesting bug in the ICC profile parser in Sun's JDK. The bug is particularly interesting because it could be exploited by an evil image. Most previous JDK bugs involve a user having to run a whole evil applet. The key parts of code which demonstrate the bug are as follows:<br /><blockquote><code style="font-size: 120%"><br />TagOffset = SpGetUInt32 (&Ptr);<br />if (ProfileSize &lt TagOffset)<br />&nbsp;&nbsp;return SpStatBadProfileDir;<br />...<br />TagSize = SpGetUInt32 (&Ptr);<br />if (ProfileSize &lt TagOffset + TagSize)<br />&nbsp;&nbsp;return SpStatBadProfileDir;<br />...<br />Ptr = (KpInt32_t *) malloc ((unsigned int)numBytes+HEADER);<br /></code></blockquote><br />Both TagSize and TagOffset are untrusted unsigned 32-bit values pulled out of images being parsed. They are added together, causing a classic integer overflow condition and the bypass of the size check. A subsequent additional integer overflow in the allocation of a buffer leads to a heap-based buffer overflow. </li><br /><li><b>gunzip</b>. In September 2006, my colleague Tavis Ormandy <a title="reported some interesting vulnerabilities" href="http://www.scary.beasts.org/security/tavis_gzip.txt" id="qbd9">reported some interesting vulnerabilities</a> in the gunzip decompressor. They were triggered when an evil compressed archive is decompressed. A lot of programs will automatically pass compressed data through gunzip, making it an interesting attack. The key parts of the code which demonstrate one of the bugs are as follows:<br /><blockquote><code style="font-size: 120%"><br />ush count[17], weight[17], start[18], *p;<br />...<br />for (i = 0; i &lt (unsigned)nchar; i++) count[bitlen[i]]++;<br /></code></blockquote><br />Here, the stack-based array "count" is indexed by values in the "bitlen" array. These values are under the control of data in the incoming untrusted compressed data, and were not checked for being within the bounds of the "count" array. This led to corruption of data on the stack.</li><br /><br /><li><b>libtiff</b>. In August 2006, Tavis <a title="reported a range of security vulnerabilities" href="http://www.scary.beasts.org/security/tavis_libtiff.txt" id="lkkz">reported a range of security vulnerabilities</a> in the libtiff image parsing library. A lot of image manipulation programs and services will be using libtiff if they handle TIFF format files. So, an evil TIFF file could compromise a lot of desktops or even servers. The key parts of the code which demonstrate one of the bugs are as follows:<br /><blockquote><code style="font-size: 120%"><br />if (sp-&gt;cinfo.d.image_width != segment_width ||<br />&nbsp;&nbsp;&nbsp;&nbsp;sp-&gt;cinfo.d.image_height != segment_height) {<br />&nbsp;&nbsp;TIFFWarningExt(tif-&gt;tif_clientdata, module,<br />&nbsp;&nbsp;&nbsp;&nbsp;"Improper JPEG strip/tile size, expected %dx%d, got %dx%d",<br /></code></blockquote><br />Here, a TIFF file containing a JPEG image is being processed. In this case, both the TIFF header and the embedded JPEG image contain their own copies of the width and height of the image in pixels. This check above notices when these values differ, issues a warning, and continues. The destination buffer for the pixels is allocated based on the TIFF header values, and it is filled based on the JPEG values. This leads to a buffer overflow if a malicious image file contains a JPEG with larger dimensions than those in the TIFF header. Presumably the intent here was to support broken files where the embedded JPEG had smaller dimensions than those in the TIFF header. However, the consequences of larger dimensions that those in the TIFF header had not been considered.</li></ol><br />We can draw some interesting conclusions from these bugs. The specific vulnerabilities are integer overflows, out-of-bounds array accesses and buffer overflows. However, the general theme is using an integer from an untrusted source without adequately sanity checking it. Integer abuse issues are still very common in code, particular code which is decoding untrusted binary data or protocols. We recommend being careful using any such code until it has been vetted for security (by extensive code auditing, fuzz testing, or preferably both). It is also important to watch for security updates for any decoding software you use, and keep patching up to date.<img src="http://feeds.feedburner.com/~r/GoogleOnlineSecurityBlog/~4/167194174" height="1" width="1"/>]]></content:encoded>
      <pubDate>Mon, 08 Oct 2007 12:13:00 +0000</pubDate>
      <category domain="http://securityratty.com/tag/image">image</category>
      <category domain="http://securityratty.com/tag/malicious image file">malicious image file</category>
      <category domain="http://securityratty.com/tag/libtiff image">libtiff image</category>
      <category domain="http://securityratty.com/tag/values">values</category>
      <category domain="http://securityratty.com/tag/jpeg image">jpeg image</category>
      <category domain="http://securityratty.com/tag/tiff header values">tiff header values</category>
      <category domain="http://securityratty.com/tag/source">source</category>
      <category domain="http://securityratty.com/tag/evil tiff file">evil tiff file</category>
      <category domain="http://securityratty.com/tag/evil">evil</category>
      <source url="http://feeds.feedburner.com/~r/GoogleOnlineSecurityBlog/~3/167194174/auditing-open-source-software.html">Auditing open source software</source>
    </item>
    <item>
      <title><![CDATA[Auditing open source software]]></title>
      <link>http://securityratty.com/article/5472ee463a7eb3b6badfe43bc9f960bb</link>
      <guid>http://securityratty.com/article/5472ee463a7eb3b6badfe43bc9f960bb</guid>
      <description><![CDATA[Written by Chris Evans, Security Team

Google encourages its employees to contribute back to the open source community, and there is no exception in Google's Security Team. Let's look at some...]]></description>
      <content:encoded><![CDATA[<span class="byline-author">Written by Chris Evans, Security Team</span><br /><br />Google encourages its employees to contribute back to the open source community, and there is no exception in Google's Security Team. Let's look at some interesting open source vulnerabilities that were located and fixed by members of Google's Security team. It is interesting to classify and aggregate the code flaws leading to the vulnerabilities, to see if any particular type of flaw is more prevalent.<br /><ol><li><b>JDK</b>. In May 2007, I <a title="released details" href="http://scary.beasts.org/security/CESA-2006-004.html" id="ro-g">released details</a> on an interesting bug in the ICC profile parser in Sun's JDK. The bug is particularly interesting because it could be exploited by an evil image. Most previous JDK bugs involve a user having to run a whole evil applet. The key parts of code which demonstrate the bug are as follows:<br /><blockquote><code style="font-size: 120%"><br />TagOffset = SpGetUInt32 (&Ptr);<br />if (ProfileSize &lt TagOffset)<br />&nbsp;&nbsp;return SpStatBadProfileDir;<br />...<br />TagSize = SpGetUInt32 (&Ptr);<br />if (ProfileSize &lt TagOffset + TagSize)<br />&nbsp;&nbsp;return SpStatBadProfileDir;<br />...<br />Ptr = (KpInt32_t *) malloc ((unsigned int)numBytes+HEADER);<br /></code></blockquote><br />Both TagSize and TagOffset are untrusted unsigned 32-bit values pulled out of images being parsed. They are added together, causing a classic integer overflow condition and the bypass of the size check. A subsequent additional integer overflow in the allocation of a buffer leads to a heap-based buffer overflow. </li><br /><li><b>gunzip</b>. In September 2006, my colleague Tavis Ormandy <a title="reported some interesting vulnerabilities" href="http://www.scary.beasts.org/security/tavis_gzip.txt" id="qbd9">reported some interesting vulnerabilities</a> in the gunzip decompressor. They were triggered when an evil compressed archive is decompressed. A lot of programs will automatically pass compressed data through gunzip, making it an interesting attack. The key parts of the code which demonstrate one of the bugs are as follows:<br /><blockquote><code style="font-size: 120%"><br />ush count[17], weight[17], start[18], *p;<br />...<br />for (i = 0; i &lt (unsigned)nchar; i++) count[bitlen[i]]++;<br /></code></blockquote><br />Here, the stack-based array "count" is indexed by values in the "bitlen" array. These values are under the control of data in the incoming untrusted compressed data, and were not checked for being within the bounds of the "count" array. This led to corruption of data on the stack.</li><br /><br /><li><b>libtiff</b>. In August 2006, Tavis <a title="reported a range of security vulnerabilities" href="http://www.scary.beasts.org/security/tavis_libtiff.txt" id="lkkz">reported a range of security vulnerabilities</a> in the libtiff image parsing library. A lot of image manipulation programs and services will be using libtiff if they handle TIFF format files. So, an evil TIFF file could compromise a lot of desktops or even servers. The key parts of the code which demonstrate one of the bugs are as follows:<br /><blockquote><code style="font-size: 120%"><br />if (sp-&gt;cinfo.d.image_width != segment_width ||<br />&nbsp;&nbsp;&nbsp;&nbsp;sp-&gt;cinfo.d.image_height != segment_height) {<br />&nbsp;&nbsp;TIFFWarningExt(tif-&gt;tif_clientdata, module,<br />&nbsp;&nbsp;&nbsp;&nbsp;"Improper JPEG strip/tile size, expected %dx%d, got %dx%d",<br /></code></blockquote><br />Here, a TIFF file containing a JPEG image is being processed. In this case, both the TIFF header and the embedded JPEG image contain their own copies of the width and height of the image in pixels. This check above notices when these values differ, issues a warning, and continues. The destination buffer for the pixels is allocated based on the TIFF header values, and it is filled based on the JPEG values. This leads to a buffer overflow if a malicious image file contains a JPEG with larger dimensions than those in the TIFF header. Presumably the intent here was to support broken files where the embedded JPEG had smaller dimensions than those in the TIFF header. However, the consequences of larger dimensions that those in the TIFF header had not been considered.</li></ol><br />We can draw some interesting conclusions from these bugs. The specific vulnerabilities are integer overflows, out-of-bounds array accesses and buffer overflows. However, the general theme is using an integer from an untrusted source without adequately sanity checking it. Integer abuse issues are still very common in code, particular code which is decoding untrusted binary data or protocols. We recommend being careful using any such code until it has been vetted for security (by extensive code auditing, fuzz testing, or preferably both). It is also important to watch for security updates for any decoding software you use, and keep patching up to date.<div class="feedflare">
<a href="http://feedproxy.google.com/~f/GoogleOnlineSecurityBlog?a=AIMgd86f"><img src="http://feedproxy.google.com/~f/GoogleOnlineSecurityBlog?d=41" border="0"></img></a> <a href="http://feedproxy.google.com/~f/GoogleOnlineSecurityBlog?a=oa3ZHDNZ"><img src="http://feedproxy.google.com/~f/GoogleOnlineSecurityBlog?i=oa3ZHDNZ" border="0"></img></a>
</div><img src="http://feedproxy.google.com/~r/GoogleOnlineSecurityBlog/~4/i5ZqGf1D0A4" height="1" width="1"/>]]></content:encoded>
      <pubDate>Mon, 08 Oct 2007 12:13:00 +0000</pubDate>
      <category domain="http://securityratty.com/tag/image">image</category>
      <category domain="http://securityratty.com/tag/evil tiff file">evil tiff file</category>
      <category domain="http://securityratty.com/tag/evil">evil</category>
      <category domain="http://securityratty.com/tag/malicious image file">malicious image file</category>
      <category domain="http://securityratty.com/tag/image height">image height</category>
      <category domain="http://securityratty.com/tag/evil image">evil image</category>
      <category domain="http://securityratty.com/tag/libtiff image">libtiff image</category>
      <category domain="http://securityratty.com/tag/tiff header values">tiff header values</category>
      <category domain="http://securityratty.com/tag/values">values</category>
      <source url="http://feedproxy.google.com/~r/GoogleOnlineSecurityBlog/~3/i5ZqGf1D0A4/auditing-open-source-software.html">Auditing open source software</source>
    </item>
  </channel>
</rss>
