<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Veracode Blog &#187; Binary Analysis</title>
	<atom:link href="http://www.veracode.com/blog/category/binary-analysis/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.veracode.com/blog</link>
	<description>Application security testing, analysis, and metrics</description>
	<lastBuildDate>Thu, 09 Feb 2012 13:18:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Top Ten Java Frameworks Observed in Customer Applications</title>
		<link>http://www.veracode.com/blog/2012/01/top-ten-java-frameworks-observed-in-customer-applications/</link>
		<comments>http://www.veracode.com/blog/2012/01/top-ten-java-frameworks-observed-in-customer-applications/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 16:40:48 +0000</pubDate>
		<dc:creator>Tim Jarrett</dc:creator>
				<category><![CDATA[ALL THINGS SECURITY]]></category>
		<category><![CDATA[Application Security]]></category>
		<category><![CDATA[Binary Analysis]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.veracode.com/blog/?p=3051</guid>
		<description><![CDATA[One of the great things about the Veracode platform is the insight we get from examining our anonymized customer data &#8211; not only information about the vulnerability landscape (as published in the State of Software Security report) but insight into the composition of the applications that we scan. As I alluded in my last post, [...]]]></description>
			<content:encoded><![CDATA[<p>One of the great things about the <a href="http://info.veracode.com/VeracodePlatformDemoVideoLandingPage.html" target="_blank">Veracode platform</a> is the insight we get from examining our anonymized customer data &#8211; not only information about the vulnerability landscape (as published in the <a href="http://info.veracode.com/state-of-software-security-report-volume4.html" target="_blank">State of Software Security report</a>) but insight into the composition of the applications that we scan. As I alluded in my <a title="About Veracode’s December platform release" href="http://www.veracode.com/blog/2011/12/about-veracodes-december-platform-release/" target="_blank">last post</a>, one of the things we record when scanning applications is the presence of frameworks and other supporting technologies, and we&#8217;ve been at work mining that data to understand what <a href="http://www.veracode.com/services/developers.html" target="_blank">developers</a> use to build their applications. We&#8217;d like to share some of that research with you today.</p>
<p>How does <a href="http://www.veracode.com/products/products-overview" target="_blank">Veracode</a> look for the presence of frameworks in Java code? Because our <a href="http://www.veracode.com/customers" target="_blank">customers</a> upload the application packages that they deploy or distribute (as EARs, WARs, or JARs), we can observe the presence of <a href="https://en.wikipedia.org/wiki/Web_application_framework"target="_blank">framework</a> classes, configuration files, and other artifacts in the application. We record the prevalence of the framework so that we can mine the anonymized data later. We resample the data every few months to get an idea of relative framework prevalence and to see if any trends can be observed.</p>
<p>Below is our most current Top 10 list for Java frameworks. This list is based on a sample of over 5400 customer applications and was sampled on December 7, 2011. Note that we have decomposed one of the larger framework families, Spring, into its component frameworks to get a better idea of the usage of its individual parts. The percentages reflect the number of Java applications (not individual scans) in which the framework was observed, so an application that was scanned multiple times only counts once in the rankings.</p>
<ol>
<li>Spring MVC (23%)</li>
<li>Struts 1.x (15%)</li>
<li>Apache Axis (15%)</li>
<li>Apache Xerces (14%)</li>
<li>Hibernate (12%)</li>
<li>JDOM (12%)</li>
<li>Java Applet (8.1%)</li>
<li>Apache Velocity (7.9%)</li>
<li>Apache ORO (7.0%)</li>
<li>JAX-WS (6.5%)</li>
</ol>
<p>A couple of interesting findings here. First, the relative prevalence of <a href="https://en.wikipedia.org/wiki/Spring_MVC"target="_blank">Spring MVC</a> and <a href="https://en.wikipedia.org/wiki/Struts"target="_blank">Struts</a> is unsurprising, but the fact that Struts 1.x is #2 on the list and Struts 2 is not even in the Top 10 is a little surprising. (It came in 24th in the overall rankings, in fact, showing up in just 1.8% of the Java applications scanned).</p>
<p>Second, it&#8217;s interesting to note that there are multiple frameworks for web services in the top ten, and that <a href="https://en.wikipedia.org/wiki/Apache_Axis"target="_blank">Axis</a> appears to have an edge on popularity over <a href="https://en.wikipedia.org/wiki/JAX-WS"target="_blank">JAX-WS</a>.</p>
<p>Third, the relatively high number of applications scanned that contained Java applets was interesting. It&#8217;s hard to imagine that 8% of all Java applications have a customer facing applet. One is tempted to speculate that in many cases these applets are administrative interfaces to framework or server <a href="http://www.veracode.com/security/code-security"target="_blank">code</a> that are left in the application distribution inadvertently or unknowingly, and thus that these represent potentially forgotten attack surfaces for the application.</p>
<p>We&#8217;re just starting to mine the data that we&#8217;re seeing regarding frameworks. I think that this data should be interesting to <a href="http://www.veracode.com/services/developers.html" target="_blank">development</a> teams looking to choose frameworks that are more widely used. From a security perspective, too, this is a useful reminder that applications rely on <a href="http://www.veracode.com/services/3rd-party-analysis.html" target="_blank">third party</a> frameworks, and that some of these may come with their own attack surface (e.g. applets) that shouldn&#8217;t be forgotten when planning secure deployments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.veracode.com/blog/2012/01/top-ten-java-frameworks-observed-in-customer-applications/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Musings on Custer&#8217;s Last Stand</title>
		<link>http://www.veracode.com/blog/2011/08/musings-on-custers-last-stand/</link>
		<comments>http://www.veracode.com/blog/2011/08/musings-on-custers-last-stand/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 15:00:53 +0000</pubDate>
		<dc:creator>Chris Wysopal</dc:creator>
				<category><![CDATA[Application Security]]></category>
		<category><![CDATA[Binary Analysis]]></category>
		<category><![CDATA[RESEARCH]]></category>
		<category><![CDATA[SDLC]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Vulnerabilities]]></category>

		<guid isPermaLink="false">http://www.veracode.com/blog/?p=1999</guid>
		<description><![CDATA[Let’s not mince words: this rambling diatribe from Oracle’s CSO is aimed directly at Veracode. No need for a cutesy acronym; we&#8217;re the only company with true static binary analysis technology, delivered as a service. Now that we’ve got that out of the way, let’s try to cut through the rhetoric (in just over a [...]]]></description>
			<content:encoded><![CDATA[<p>Let’s not mince words: this <a href="http://blogs.oracle.com/maryanndavidson/entry/those_who_can_t_do">rambling diatribe</a> from Oracle’s CSO is aimed directly at Veracode.  No need for a cutesy acronym; we&#8217;re the only company with true static binary analysis technology, delivered as a service.  Now that we’ve got that out of the way, let’s try to cut through the rhetoric (in just over a thousand words, to boot).</p>
<p>The recurring theme in her manifesto is the notion that certain software suppliers are &#8220;too big to test&#8221;.  It’s fine for the little guys, but not the 800-pound gorillas. Instead, software purchasers should blindly trust companies with security teams and assurance processes to produce secure code.  If only it were that simple.  In fact, according to our semi-annual <a href="http://info.veracode.com/state-of-software-security-report-volume3.html">State of Software Security Report</a>, there&#8217;s negligible variation in security quality across software suppliers regardless of company size.</p>
<p><center><img src="http://www.veracode.com/blog/wp-content/uploads/2011/08/sossfig26-smaller.png" alt="" title="sossfig26-smaller" width="492" height="357" class="aligncenter size-full wp-image-2035" style="padding-right:20px" /></center></p>
<p>We’re both flattered and amused that Ms. Davidson believes our company alone &#8220;created a market&#8221; for testing the software supply chain.  On the contrary, the market has created itself.  Take a look through the noteworthy breaches from the past 12-24 months; software vulnerabilities have been the culprit in nearly every case.  CISOs are waking up to the stark realization that all software &#8212; internally or externally produced &#8212; introduces risk into their organizations.  In this day and age, wise companies harbor a healthy suspicion of their software vendors.  Oracle can choose to do security testing in-house, but a company that&#8217;s &#8220;running their entire business&#8221; on Oracle’s software has a right to request unbiased evidence that the testing process is working.  </p>
<p>That being said, Oracle is hardly the poster child for security process.  Within the security community, they are notorious for shipping insecure products.  Their laughable &#8220;Unbreakable&#8221; marketing campaign was <a href="http://www.securityfocus.com/news/309">famously debunked</a> by security expert David Litchfield, who uncovered several critical (and easily avoidable) vulnerabilities within a matter of weeks.  They’ve also earned a reputation for <a href="http://seclists.org/bugtraq/2005/Oct/56">glacial response times and sloppy patches</a>.  No company can be expected to build perfectly secure software, but it’s pretty obvious why external validation is needed to complement in-house process &#8212; one need look no further than <a href="http://www.zerodayinitiative.com/advisories/published/">ZDI</a> for evidence.  Even Ms. Davidson&#8217;s own example illustrates how an outsourced service provider &#8220;HuiMaika&#8217;i&#8221; detected multiple vulnerabilities that weren’t discovered by Oracle’s internal team.</p>
<p>Perhaps the most shocking admission about Oracle&#8217;s security program is their interpretation of the &#8220;need to know&#8221; principle. Ms. Davidson asserts that she doesn&#8217;t need access to bug databases. This is a classic liability avoidance move and one that we&#8217;ve witnessed in other organizations as well.  Creating barriers to vulnerability information facilitates a culture in which the executive has plausible deniability of critical bugs and can simply look the other way if a ship deadline is looming or if the auditors pay a visit. CISOs should be clamoring for as much data as they can get their hands on, not eschewing it.</p>
<p>Finally, Ms. Davidson seemed offended that a tenured university professor would suggest licensing software developers to create a system of accountability.  Ironically, only a few years ago, she sent a letter to top universities pressuring them to incorporate secure coding guidelines such as the SANS coding certification into their curriculums.  She told them, &#8220;<a href="http://www.cert.org/podcast/show/20080930davidson.html">We will start making our purchasing decisions</a>, if you will, based on that.&#8221;  Apparently, it’s OK for Oracle to flex their muscle when &#8220;buying&#8221; (i.e. hiring) from universities, but it’s not OK for Oracle’s customers to hold them to similar standards?  It certainly sounds like Oracle has been feeling the pressure lately. </p>
<div style="float:right; margin-left:20px; margin-bottom:10px"><a href="http://www.veracode.com/blog/wp-content/uploads/2011/08/consumer-reports.jpg"><img src="http://www.veracode.com/blog/wp-content/uploads/2011/08/consumer-reports-224x300.jpg" alt="" title="consumer-reports" width="224" height="300" class="alignright size-medium wp-image-2027" /></a></div>
<p>There are third-party tests and assessments for perhaps every important purchase in business or in our personal lives. Companies hire law firms and specialists when they make acquisitions. People look to safety and quality tests from trusted sources before they buy everything from baby strollers to cars. You wouldn&#8217;t think of buying a home without a home inspection.  In each case, the cost of the independent test must be commensurate with the purchase price and the risk. Look at the typical due dilligence around home purchase. It doesn&#8217;t always make sense to pay an engineering firm thousands of dollars for a structural analysis, but it does make sense to hire a home inspector for a few hundred dollars, who in a few hours can uncover termites or a leaking roof. These are problems that must be fixed, and because the testing cost is so low it would be negligent not to do it.  Most of the major software vendors have participated in third-party testing either as part of their SDLC, to vet code they were acquiring or licensing, or as part of one of their customers&#8217; procurement process.</p>
<p>Veracode has never claimed that binary SAST provides complete software assurance.  From the beginning, we have recommended multiple testing methods to detect vulnerabilities that static automation can’t.  In fact, it’s impossible to receive our top ratings without a clean bill of health from a manual penetration test.  Each layer of testing, while imperfect on its own, uncovers problems that must be corrected.  </p>
<p>Outsourcing is not a dirty word.  Many companies outsource development for entire products or components of them.  Companies also outsource testing and training.  The multi-billion dollar IV&#038;V market grew out of this need &#8212; it&#8217;s simply good business. The goal is shipping secure code, not making a feel-good proclamation that your team can handle a modern development challenge with no outside help.  While Oracle can be proud that they have tamed a source code tool and lived to tell the tale, other companies are securing their code faster and cheaper with the help of outsourcing.  Even Veracode customers haven&#8217;t <em>fully outsourced</em> security; many of them have in-house security expertise and are just employing a service to make their security processes more robust.  They are still full participants in the process, making decisions around how/when to remediate, how much to invest, etc. Veracode acts as an application security partner, providing customers valuable intelligence gleaned from the software ecosystem. Just as Google gets smarter with every search that it does, Veracode gets smarter with every scan we do.</p>
<p>At least we can rest easy knowing that Oracle would never <a href="http://www.opensecrets.org/lobby/indusclient.php?id=B12&#038;year=2011">hire lobbyists</a> to <a href="http://www.itnews.com.au/News/268523,cable-us-pressured-eu-to-approve-oracle-sun-merger.aspx">promote an agenda</a>. That’s a relief!</p>
<h5>Veracode Security Solutions</h5>
<div style="margin-left:15px;">
<a href="http://www.veracode.com/security/dynamic-analysis">Dynamic Analysis</a><br />
<a href="http://www.veracode.com/security/internet-security">Internet Security</a><br />
<a href="http://www.veracode.com/security/malicious-code">Malicious Code</a><br />
<a href="http://www.veracode.com/security/vulnerability-assessment-software">Vulnerability Assessment</a><br />
<a href="http://www.veracode.com/security/web-security">Website Security</a><br />
<a href="http://www.veracode.com/security/application-testing-tool">Application Analysis</a></div>
<p></p>
<h5>Security Alternatives</h5>
<div style="margin-left:15px;">
<a href="http://www.veracode.com/security/hp-fortify-alternative">HP Fortify</a><br />
<a href="http://www.veracode.com/security/whitehat-security-alternative">Whitehat Security</a><br />
<a href="http://www.veracode.com/security/rational-appscan-alternative">IBM Rational AppScan</a>
</div>
<p></p>
<h5>Security Threat Guides</h5>
<div style="margin-left:15px;">
<a href="http://www.veracode.com/security/sql-injection">SQL Injection</a><br />
<a href="http://www.veracode.com/security/xss">XSS</a><br />
<a href="http://www.veracode.com/security/csrf">CSRF</a><br />
<a href="http://www.veracode.com/security/ldap-injection">LDAP Security</a><br />
<a href="http://www.veracode.com/security/mobile-code-security">Mobile Security</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.veracode.com/blog/2011/08/musings-on-custers-last-stand/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Mobile App Privacy Continued&#8230;</title>
		<link>http://www.veracode.com/blog/2011/04/mobile-app-privacy-continued/</link>
		<comments>http://www.veracode.com/blog/2011/04/mobile-app-privacy-continued/#comments</comments>
		<pubDate>Fri, 08 Apr 2011 18:47:31 +0000</pubDate>
		<dc:creator>Tyler Shields</dc:creator>
				<category><![CDATA[Application Security]]></category>
		<category><![CDATA[Binary Analysis]]></category>
		<category><![CDATA[Malware]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[RESEARCH]]></category>

		<guid isPermaLink="false">http://www.veracode.com/blog/?p=1625</guid>
		<description><![CDATA[[UPDATE! April 15: Pandora removes all advertising libraries from its Android and iPhone apps!] The blog post we made earlier this week entitled, Mobile Apps Invading Your Privacy, gives detail around the information being requested by the advertisement libraries embedded inside a popular online radio application. There have been a number of great posts and [...]]]></description>
			<content:encoded><![CDATA[<p><em>[UPDATE! April 15: Pandora <a href="http://www.rollingstone.com/culture/blogs/gear-up/pandora-responds-to-claims-that-its-online-service-violates-user-privacy-20110415">removes all advertising libraries</a> from its Android and iPhone apps!]</em></p>
<p>The blog post we made earlier this week entitled, <a href="http://www.veracode.com/blog/2011/04/mobile-apps-invading-your-privacy/">Mobile Apps Invading Your Privacy</a>, gives detail around the information being requested by the advertisement libraries embedded inside a popular online radio application. There have been a number of great posts and comments that got us thinking more about the issues and the types of data being requested. </p>
<p>First off we want to thank some people who commented about the Pandora application not having permission to actually access the GPS on the device. Below are the <a href="https://market.android.com/details?id=com.pandora.android&#038;feature=search_result">Manifest permissions</a> for the version of Pandora currently in the Google Application Marketplace:</p>
<ul>
<li>Full Internet Access</li>
<li>Create Bluetooth Connections</li>
<li>Read Contact Data</li>
<li>Add or Modify Calendar Data and Send Emails to Guests</li>
<li>Read Phone State and Identity</li>
<li>Modify Global System Settings</li>
<li>Prevent Device from Sleeping</li>
<li>Bluetooth Administration</li>
<li>Change Wifi State</li>
<li>Change Network Connectivity</li>
</ul>
<p>As you can see, GPS access is NOT included in that list. There was an error in the original post we made stating that some of the library code was requesting permissions from the Google system for GPS access, and as the commenter pointed out, that is incorrect. The code snippet we posted is only checking whether the parent application, Pandora in this case, has permission to access the GPS. If the parent does not have permission, the accessing of GPS data can&#8217;t occur.</p>
<p><strong>However, the overarching theme of the original post is still valid</strong>.  If Pandora had required GPS access for a legitimate reason, the embedded advertisement library would have been able to request the GPS data and send it off device.  As we mentioned in the original post, there is a chance that Pandora has no idea what the embedded advertising library actually does, simply taking it from the advertising partner and embedding it into their application.</p>
<p>To further illustrate this point, we downloaded a few more applications that use some of the same advertising libraries. In particular, we found AdMob (the code snippets we outlined on the previous post) embedded into the free <a href="https://market.android.com/details?id=com.treemolabs.apps.cbsnews&#038;feature=search_result">CBS News Android application</a> and the <a href="https://market.android.com/details?id=com.rhythmnewmedia.tvdotcom&#038;feature=search_result">TVDotCom application</a>. Both of these applications have GPS coarse and fine permissions allowed within their application manifest. They don&#8217;t have some of the other permissions required to send certain data, but in these cases the advertising code will fail silently.  Essentially, the advertising libraries use the parent application as an enabler, taking advantage of whichever permissions happen to be available.  It also seems revelant to note that AdMob was <a href="http://googleblog.blogspot.com/2010/05/weve-officially-acquired-admob.html">acquired by Google</a> in May 2010.</p>
<p>The current model where permissions are granted to applications combined with the way 3rd party libraries such as mobile ad network libraries request many different types of information sets up a situation where the ad network will get the information if the application needs it to operate. </p>
<h5>Veracode Security Solutions</h5>
<div style="margin-left:15px;">
<a href="http://www.veracode.com/security/code-analysis">Source Code Analysis</a><br />
<a href="http://www.veracode.com/security/software-testing-tools">Software Testing Tools</a><br />
<a href="http://www.veracode.com/security/static-analysis-tool">Static Analysis Tool</a><br />
<a href="http://www.veracode.com/security/web-application-security-testing">Web Application Security</a><br />
<a href="http://www.veracode.com/security/web-security">Web Security</a><br />
<a href="http://www.veracode.com/security/vulnerability-assessment-software">Vulnerability Assessment</a><br />
<a href="http://www.veracode.com/security/application-testing-tool">Application Analysis</a><br />
<a href="http://www.veracode.com/security/static-code-analysis">Static Code Analysis</a><br />
<a href="http://www.veracode.com/">Application Security</a></div>
<p></p>
<h5 style="margin-bottom: 10px">Security Threat Guides</h5>
<div style="margin-left:15px;">
<a href="http://www.veracode.com/security/sql-injection">SQL Injection</a><br />
<a href="http://www.veracode.com/security/xss">Cross Site Scripting</a><br />
<a href="http://www.veracode.com/security/csrf">CSRF</a><br />
<a href="http://www.veracode.com/security/ldap-injection">LDAP Security</a><br />
<a href="http://www.veracode.com/security/mobile-code-security">Mobile Security</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.veracode.com/blog/2011/04/mobile-app-privacy-continued/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Mobile Apps Invading Your Privacy</title>
		<link>http://www.veracode.com/blog/2011/04/mobile-apps-invading-your-privacy/</link>
		<comments>http://www.veracode.com/blog/2011/04/mobile-apps-invading-your-privacy/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 01:45:30 +0000</pubDate>
		<dc:creator>Tyler Shields</dc:creator>
				<category><![CDATA[Application Security]]></category>
		<category><![CDATA[Binary Analysis]]></category>
		<category><![CDATA[Malware]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[RESEARCH]]></category>

		<guid isPermaLink="false">http://www.veracode.com/blog/?p=1591</guid>
		<description><![CDATA[[April 8: We've added some more information in a follow-up post] Background An article in the Wall Street Journal, dated April 5, 2011, disclosed that Federal prosecutors in New Jersey are investigating numerous smart phone application manufacturers for allegedly, illegally obtaining and distributing personal private information to third party advertisement groups. The allegations state that [...]]]></description>
			<content:encoded><![CDATA[<p><em>[April 8: We've added some more information in a <a href="http://www.veracode.com/blog/2011/04/mobile-app-privacy-continued/">follow-up post</a>]</em></p>
<p><b>Background</b></p>
<p>An <a href="http://online.wsj.com/article/SB10001424052748703806304576242923804770968.html">article in the Wall Street Journal</a>, dated April 5, 2011, disclosed that Federal prosecutors in New Jersey are investigating numerous smart phone application manufacturers for allegedly, illegally obtaining and distributing personal private information to third party advertisement groups. The allegations state that mobile applications are gathering data such as GPS location, device identifiers, gender, and even user age without proper notice or authorization from the end user. The Journal tested 101 applications and found that 56 of them transmitted the device unique identifier off the device, while 47 transmitted the phone&#8217;s location. Five of the tested applications leaked personal information such as user gender and age.</p>
<p><b>Analysis</b></p>
<p>The folks at the Veracode research team decided to spend a bit of our time today breaking apart one of the accused applications to see what could be found within the code. Given what was written in the Journal article, we thought it would be most interesting to take an in-depth look through the Pandora application for the Android platform. A quote from the article states the following about the Pandora application:</p>
<blockquote><p>
In Pandora&#8217;s case, both the Android and iPhone versions of its app transmitted information about a user&#8217;s age, gender, and location, as well as unique identifiers for the phone, to various advertising networks. Pandora gathers the age and gender information when a user registers for the service.
</p></blockquote>
<p>Our first step was to analyze the application using the Veracode platform. We followed up the automated static analysis with a manual analysis of the compiled dex code. The results were fairly interesting. The Pandora for Android application appears to be integrated with a number of advertising libraries. Specifically we found FIVE (yes that&#8217;s FIVE!) advertisement libraries compiled into the application: <a href="http://www.admarvel.com/">AdMarvel</a>, <a href="http://www.admob.com/">AdMob</a>, <a href="http://www.comscore.com/">comScore (SecureStudies)</a>, <a href="http://www.google.com/mobileads/">Google.Ads</a>, and <a href="http://www.medialets.com/">Medialets</a>. Looking even closer, we analyzed each of the modules to determine the type of data they access.</p>
<p>The first library we decided to break apart was the AdMarvel and AdMob libraries. The AdMarvel library references the AdMob library fairly significantly. AdMob in particular accesses the GPS location, application package name, and application version information. Additionally there were variable references within the ad library that appear to transmit the user&#8217;s birthday, gender, and postal code information. The code snippets below are taken from a decompilation of the AdMob library where GPS locations are being gathered. As you can see in the code, the library requests permissions for both COARSE_LOCATION, and FINE_LOCATION data:</p>
<pre>
public static Location getCoordinates(Context unknown)
{
.... SNIP ....
        String str1 = "android.permission.ACCESS_COARSE_LOCATION";
        int m = unknown.checkCallingOrSelfPermission(str1);
.... SNIP ....
        String str2 = "android.permission.ACCESS_FINE_LOCATION";
        int n = unknown.checkCallingOrSelfPermission(str2);
</pre>
<p>We can also see where the library actually attempts to capture GPS location information on a continuous looping mechanism:</p>
<pre>
        int i4 = Log.d("AdMobSDK", "Trying to get locations from GPS.");
        localObject2 = (LocationManager)unknown.getSystemService("location");
        if (localObject2 == null) break label428;
        Criteria localCriteria = new Criteria();
        localCriteria.setAccuracy(1);
        localCriteria.setCostAllowed(0);
        localObject3 = ((LocationManager)localObject2).getBestProvider(localCriteria, 1);
.... SNIP ....
        int i5 = Log.d("AdMobSDK", "Cannot access user's location.  Permissions are not set.");
.... SNIP ....
        int i6 = Log.d("AdMobSDK", "No location providers are available.  Ads will not be geotargeted.");
.... SNIP ....
        if (Log.isLoggable("AdMobSDK", 3)) int i7 = Log.d("AdMobSDK", "Location provider setup successfully.");
        AdManager.1 local1 = new AdManager.1((LocationManager)localObject2);
        Looper localLooper = unknown.getMainLooper();
        ((LocationManager)localObject2).requestLocationUpdates((String)localObject3, 0L, 0.0F, local1, localLooper);
</pre>
<p>We also saw references to the user&#8217;s gender:</p>
<pre>
        Object localObject = k; Gender localGender1 = Gender.MALE;
        if (localObject == localGender1)
       {
            localObject = "m";
       } while (true) {
      return localObject;

      Gender localGender2 = k;
      Gender localGender3 = Gender.FEMALE;
      if (localGender2 == localGender3) { localObject = "f"; continue; }
      localObject = null;
</pre>
<p>And of course, access of the infamous Android ID value (android_id):</p>
<pre>
      if (f == null) { Object localObject1 = unknown.getContentResolver();
      localObject2 = localObject1;
      localObject1 = Settings.Secure.getString((ContentResolver)localObject2, "android_id");
</pre>
<p>The analysis into the remaining libraries resulted in even more of the same. The SecureStudies library accesses the android_id and directly sends a hash of the data to http://b.scorecardresearch.com while the Medialets library accesses the device&#8217;s GPS location, bearing, altitude, android_id, connection status, network information, device brand, model, release revision, and current IP address.</p>
<p><B>Conclusion</B></p>
<p>So what does this mean to the end user? It means your personal information is being transmitted to advertising agencies in mass quantities. As more and more &#8220;free&#8221; applications attempt to monetize their offerings, we will likely see more of your personal information being shuttled out to marketing and advertising data aggregation firms. The application developers may not even be aware of the privacy violations they are introducing by using third party advertising libraries. They may merely think they are getting $x per ad impression, not that the ad library is leaking significant information about the user.</p>
<p>In isolation some of this data is uninteresting, but when compiled into a single unifying picture, it can provide significant insight into a persons life. Consider for a moment that your current location is being tracked while you are at your home, office, or significant other&#8217;s house.  Couple that with your gender and age and then with your geolocated IP address. When all that is placed into a single basket, it&#8217;s pretty easy to determine who someone is, what they do for a living, who they associate with, and any number of other traits about them. I don&#8217;t know about you, but that feels a little Orwellian to me.</p>
<h5>Veracode Security Solutions</h5>
<div style="margin-left:15px;">
<a href="http://www.veracode.com/security/code-analysis">Source Code Analysis</a><br />
<a href="http://www.veracode.com/security/software-testing-tools">Software Testing Tools</a><br />
<a href="http://www.veracode.com/security/static-analysis-tool">Static Analysis Tool</a><br />
<a href="http://www.veracode.com/security/web-application-security-testing">Web Application Security</a><br />
<a href="http://www.veracode.com/security/web-security">Web Security</a><br />
<a href="http://www.veracode.com/security/vulnerability-assessment-software">Vulnerability Assessment</a><br />
<a href="http://www.veracode.com/security/application-testing-tool">Application Analysis</a><br />
<a href="http://www.veracode.com/security/static-code-analysis">Static Code Analysis</a><br />
<a href="http://www.veracode.com/">Application Security</a></div>
<p><br/></p>
<h5 style="margin-bottom: 10px">Security Threat Guides</h5>
<div style="margin-left:15px;">
<a href="http://www.veracode.com/security/sql-injection">SQL Injection</a><br />
<a href="http://www.veracode.com/security/xss">Cross Site Scripting</a><br />
<a href="http://www.veracode.com/security/csrf">CSRF</a><br />
<a href="http://www.veracode.com/security/ldap-injection">LDAP Security</a><br />
<a href="http://www.veracode.com/security/mobile-code-security">Mobile Security</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.veracode.com/blog/2011/04/mobile-apps-invading-your-privacy/feed/</wfw:commentRss>
		<slash:comments>97</slash:comments>
		</item>
		<item>
		<title>Anti-Debugging Series &#8211; Part IV</title>
		<link>http://www.veracode.com/blog/2009/02/anti-debugging-series-part-iv/</link>
		<comments>http://www.veracode.com/blog/2009/02/anti-debugging-series-part-iv/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 21:58:03 +0000</pubDate>
		<dc:creator>Tyler Shields</dc:creator>
				<category><![CDATA[Application Security]]></category>
		<category><![CDATA[Binary Analysis]]></category>
		<category><![CDATA[RESEARCH]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.veracode.com/blog/?p=682</guid>
		<description><![CDATA[In this final part of the anti-debugging series we&#8217;re going to discuss process and thread block based anti-debugging. Processes and threads must be maintained and tracked by the operating system. In user space, information about the processes and threads are held in memory in structures known as the process information block (PIB), process environment block [...]]]></description>
			<content:encoded><![CDATA[<p>In this final part of the anti-debugging series we&#8217;re going to discuss process and thread block based anti-debugging. Processes and threads must be maintained and tracked by the operating system. In user space, information about the processes and threads are held in memory in structures known as the <a href="http://msdn.microsoft.com/en-us/library/ms684280(VS.85).aspx">process information block (PIB)</a>, <a href="http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/NT%20Objects/Process/PEB.html">process environment block (PEB)</a> and the <a href="http://en.wikipedia.org/wiki/Win32_Thread_Information_Block">thread information block (TIB)</a>. These structures hold data pertinent to the operation of that particular process or thread which is read by many of the API based anti-debugging methods we discussed previously. </p>
<p>When a debugger or reverse engineer tries to get aggressive and hook calls to anti-debugging related APIs we can move lower than the API and directly access the process and thread information to detect the attached debugger. By side stepping the operating system provided methods for querying process and thread information, we can effectively bypass some API based hooking techniques used in anti-anti-debugging efforts. </p>
<p>For example, in <a href="http://www.veracode.com/blog/2008/12/anti-debugging-series-part-ii/">part II</a> of this anti-debugging series I demonstrated how to make a call to IsDebuggerPresent() to detect if the debugger present process flag is set.</p>
<pre>
Prototype: BOOL WINAPI IsDebuggerPresent(void); 

if (IsDebuggerPresent()) {
    //Debugger Detected - Do Something Here
} else {
    //No Debugger Detected - Continue
}
</pre>
<p>If we analyzed what this API call actually does we would notice that it reads a flag from the PEB which indicates the presence of a debugger. Instead of directly calling the API, it is possible to emulate what the IsDebuggerPresent() function does and directly query the PEB ourselves. </p>
<p>The first step in analyzing data within the PEB structure is to locate the PEB structure in memory. To do this we can use a number of different methods, some more direct and low level that others. The method that is easiest to grasp is to call the function NtQueryInformationProcess with a second parameter of ProcessBasicInformation. This returns a pointer to the process information block (PIB) for the requested process. Once we have access to this PIB structure we look at the PebBaseAddress member to determine the base address of the PEB. Finally, we look at the boolean member BeingDebugged to return the same result that would be returned had we called the function IsDebuggerPresent().</p>
<p>The following code demonstrates our example:</p>
<pre>
hmod = LoadLibrary(L"Ntdll.dll");
_NtQueryInformationProcess = GetProcAddress(hmod, "NtQueryInformationProcess");

hnd = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessId());
status = (_NtQueryInformationProcess) (hnd, ProcessBasicInformation, &amp;pPIB, sizeof(PROCESS_BASIC_INFORMATION), &amp;bytesWritten);

if (status == 0 ) {
  if (pPIB.PebBaseAddress-&gt;BeingDebugged == 1) {
    MessageBox(NULL, L"Debugger Detected Using PEB!IsDebugged", L"Debugger Detected", MB_OK);
  } else {
    MessageBox(NULL, L"No Debugger Detected", L"No Debugger Detected", MB_OK);
  }
}
</pre>
<p>There are a number of different ways that we can query the PEB and TIB blocks to detect the presence of a debugger. Let&#8217;s divert from the straight forward and instead look at a novel and interesting method of detecting a debugger specifically designed to operate under Windows Vista. In Vista, when a process is started without a debugger present, the main thread environment block contains a pointer to a Unicode string referencing a system DLL such as kernel32.dll. If the process is started under a debugger, that system DLL name is replaced with the Unicode string “HookSwitchHookEnabledEvent”. Thus if we know that the process we are trying to protect is running within a Windows Vista environment, we can use this technique to determine if the processes was launched from within a debugging environment. </p>
<p>To use this technique, the anti-debugging function should first check that it is running on the Windows Vista operating system. After confirming the operating system revision, the technique should locate the TIB. The TIB can be accessed as an offset of segment register FS as in the following code:</p>
<pre>
void* getTib()
{
  void *pTib;
  __asm {
    mov EAX, FS:[18h] //FS:[18h] is the location of the TIB
    mov [pTib], EAX
  }
  return pTib;
}
</pre>
<p>Once the location of the TIB is found, the offset 0xBFC from the start of the TIB is read and the pointer checked. If this value is 0&#120;00000C00 we then read the string at offset 0xC00 and compare this value to the Unicode string “HookSwitchHookEnabledEvent”. We check the pointer to ensure that we have a string located in the pointed to address and as a second level of assurance for the accuracy of this method. If we pass this final test we can be sure that our process running under Windows Vista was started from within a debugger.</p>
<pre>
wchar_t *hookStr = _TEXT("HookSwitchHookEnabledEvent");
strPtr = TIB+0xBFC;

delta = (int)(*strPtr) - (int)strPtr;
if (delta == 0x04) {
   if (wcscmp(*strPtr, hookStr)==0) {
      MessageBox(NULL, L"Debugger Detected Via Vista TEB System DLL PTR", L"Debugger Detected", MB_OK);
    } else {
      MessageBox(NULL, L"No Debugger Detected", L"No Debugger", MB_OK);
    }
} else {
   MessageBox(NULL, L"No Debugger Detected", L"No Debugger", MB_OK);
}
</pre>
<p>In the four parts of this series we have discussed classes of anti-debugging methods, a few basic API based anti-debugging techniques, some slightly more advanced API techniques, and finally two methods that directly access process and thread information to detect the presence of a debugger. </p>
<p>Instead of continuing this series in blog format, I&#8217;ve decided to release a paper outlining the details of nearly 35 different anti-debugging methods. I&#8217;ll be presenting the paper (and associated slides) at the <a href="http://www.sourceconference.com/">SOURCE Boston 2009</a> security conference which starts March 11th, 2009 and finishes up March 13, 2009. The paper and presentation are geared towards developers and software engineers who may not understand the assembly dump of some anti-debugging code but can understand what I&#8217;ve presented to you thus far.</p>
<p>The <a href="http://www.sourceconference.com/index.php/register">pre-registration rates</a> for SOURCE Boston end on February 28, 2009. So get your ticket at a discount while you still can! It&#8217;s going to be a fantastic conference with some of the best information security topics and presenters in the industry.</p>
<p>Additionally, as a speaker, I&#8217;ve been given one ticket at half price to do with as I choose. As of yet I haven&#8217;t given it away. If anyone would like a half off ticket to SOURCE Boston and can attend please let me know. I&#8217;ll get the discount code over to you ASAP. I look forward to seeing you all at the conference, please come up and say hello!</p>
<h5>Veracode Security Solutions</h5>
<div style="margin-left:15px;">
<a href="http://www.veracode.com/security/vulnerability-assessment-software">Vulnerability Assessment</a><br />
<a href="http://www.veracode.com/security/application-testing-tool">Application Analysis</a><br />
<a href="http://www.veracode.com/security/static-code-analysis">Static Code Analysis</a><br />
<a href="http://www.veracode.com/security/code-analysis">Source Code Analysis</a><br />
<a href="http://www.veracode.com/security/software-testing-tools">Software Testing Tools</a><br />
<a href="http://www.veracode.com/security/static-analysis-tool">Static Analysis</a><br />
<a href="http://www.veracode.com/security/web-application-security-testing">Web Application Security</a><br />
<a href="http://www.veracode.com/security/web-security">Website Security</a><br />
<a href="http://www.veracode.com/">Application Security</a></div>
<p></p>
<h5 style="margin-bottom: 10px">Security Threat Guides</h5>
<div style="margin-left:15px;">
<a href="http://www.veracode.com/security/mobile-code-security">Mobile Security</a><br />
<a href="http://www.veracode.com/security/sql-injection">SQL Injection</a><br />
<a href="http://www.veracode.com/security/xss">What is XSS</a>?<br />
<a href="http://www.veracode.com/security/csrf">CSRF</a><br />
<a href="http://www.veracode.com/security/ldap-injection">LDAP Security</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.veracode.com/blog/2009/02/anti-debugging-series-part-iv/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Anti-Debugging Series &#8211; Part III</title>
		<link>http://www.veracode.com/blog/2009/01/anti-debugging-series-part-iii/</link>
		<comments>http://www.veracode.com/blog/2009/01/anti-debugging-series-part-iii/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 20:54:48 +0000</pubDate>
		<dc:creator>Tyler Shields</dc:creator>
				<category><![CDATA[Application Security]]></category>
		<category><![CDATA[Binary Analysis]]></category>
		<category><![CDATA[RESEARCH]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.veracode.com/blog/?p=589</guid>
		<description><![CDATA[It&#8217;s time for part three in the Anti-Debugging Series. With this post we will stay in the realm of &#8220;API based&#8221; anti-debugging techniques but go a bit deeper into some techniques that are more complex and significantly more interesting. Today we will analyze one method of detecting an attached debugger, and a second method that [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s time for part three in the Anti-Debugging Series. With this post we will stay in the realm of &#8220;API based&#8221; anti-debugging techniques but go a bit deeper into some techniques that are more complex and significantly more interesting. Today we will analyze one method of detecting an attached debugger, and a second method that can be used to detach a debugger from our running process.</p>
<p><strong>Advanced API Based Anti-Debugging</strong></p>
<p>There are a number of functions and API calls within the Windows operating system that are considered internal to the operating system and thus not documented well for the average developer. Many of these functions have undergone extensive research and reverse engineering to be able to understand how they operate and what can be achieved using them. One such poorly documented API function is the NtQueryInformationProcess function which is used to retrieve information about a target process. The function prototype looks like the following:</p>
<pre>
NTSTATUS WINAPI NtQueryInformationProcess(
    __in HANDLE ProcessHandle,
    __in PROCESSINFOCLASS ProcessInformationClass,
    __out PVOID ProcessInformation,
    __in ULONG ProcessInformationLength,
    __out_opt PULONG ReturnLength
);
</pre>
<p>This function resides within the Ntdll.dll file and is not an exported function. Because of this, we must use run-time dynamic linking to gain access to the functionality. Run-time dynamic linking is the dynamic loading of a library and mapping of functions within the library to a function pointer allowing it to be called and executed. To load our function, &#8220;NtQueryInformationProcess&#8221;, we first call LoadLibrary(&#8220;ntdll.dll&#8221;) and then execute GetProcAddress(HMODULE, &#8220;NtQueryInformationProcess&#8221;) to receive a pointer to our required function. </p>
<pre>
HMODULE hmod;
FARPROC _NtQueryInformationProcess;
hmod = LoadLibrary(L"ntdll.dll");
_NtQueryInformationProcess = GetProcAddress(hmod, "NtQueryInformationProcess");
</pre>
<p>Note: The dynamic linking method is slightly different when using C++ due to declaration differences.</p>
<p>Once we have a function pointer to the NtQueryInformationProcess function, we can call the API. The function call takes five parameters, the first two of which are the most interesting to our anti-debugging efforts. The first parameter is a HANDLE to the target process that we wish to interrogate. Since we are trying to determine information about our own process, we will use a HANDLE that points to ourselves. By default, a HANDLE value of -1 will instruct the function to use the current process as the target. The second parameter is a value indicating what type of information is being requested from the target process. In the Microsoft MSDN documentation there are four documented values for this parameter ProcessBasicInformation (0), ProcessDebugPort (7), ProcessWow64Information (26), and ProcessImageFileName (27). There are other undocumented values that can be passed in, some of which allow for interesting anti-debugging techniques, however we will focus on the ProcessDebugPort (7) value. This value, when used as the second parameter in the NtQueryInformationProcess function will return a DWORD, returned in the address of the third parameter, indicating the DebugPort that is currently available for the process. If a non-zero value is returned, indicating that a DebugPort exists, we can be sure that a debugger is attached and act accordingly.</p>
<pre>
status = (_NtQueryInformationProcess) (-1, 0x07, &amp;retVal, 4, NULL);

if (retVal != 0) {
    //Debugger Detected - Do Something Here
} else {
   //No Debugger Detected - Continue
}
</pre>
<p>The second anti-debugging method we will look at today also uses run-time dynamic linking of the Ntdll.dll library along with GetProcAddress() to gain access to the NtSetInformationThread function. This function&#8217;s primary purpose is to modify thread specific data for a targeted thread. </p>
<pre>
NTSTATUS NTAPI NtSetInformationThread(
    __in HANDLE ThreadHandle,
    __ in THREAD_INFORMATION_CLASS ThreadInformationClass,
    __in PVOID ThreadInformation
    __in ULONG ThreadInformationLength
)
</pre>
<p>For the anti-debugging use of this function we are again only interested in two particular parameters. The first parameter is an identifier to the thread we wish to target and the second parameter is the particular information we wish to modify on the target thread. To get a pointer to our current thread we will use a call to GetCurrentThread(). We will submit that as the first parameter and the enum value for ThreadHideFromDebugger, 0&#x78;11, as the second parameter. If a debugger is attached and we pass in 0&#x78;11 to NtSetInformationProcess, our process will immediately detach any attached debugger and terminate the process.</p>
<pre>
lib = LoadLibrary(L"ntdll.dll");
_NtSetInformationThread = GetProcAddress(lib, "NtSetInformationThread");

(_NtSetInformationThread) (GetCurrentThread(), 0x11, 0, 0);

MessageBox(NULL, L"Debugger Detached", L"Debugger Detached", MB_OK);
</pre>
<p>Many of the Microsoft API calls are intentionally not well documented to discourage their use/abuse. In this case we can make calls to two non-exported functions within the Ntdll.dll library to achieve our goals of detecting or detaching a debugger from our process. There are a number of other methods of API based anti-debugging, feel free to comment about them below. </p>
<p>Stay tuned for our next installment as we touch on process and thread block anti-debugging.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.veracode.com/blog/2009/01/anti-debugging-series-part-iii/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Anti-Debugging Series &#8211; Part II</title>
		<link>http://www.veracode.com/blog/2008/12/anti-debugging-series-part-ii/</link>
		<comments>http://www.veracode.com/blog/2008/12/anti-debugging-series-part-ii/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 17:14:55 +0000</pubDate>
		<dc:creator>Tyler Shields</dc:creator>
				<category><![CDATA[Application Security]]></category>
		<category><![CDATA[Binary Analysis]]></category>
		<category><![CDATA[RESEARCH]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[anti-debugging]]></category>
		<category><![CDATA[reverse engineering]]></category>

		<guid isPermaLink="false">http://www.veracode.com/blog/?p=530</guid>
		<description><![CDATA[Welcome back to the series on anti-debugging. Hopefully you have your debugger and development environment handy as we are about to dive into the first round of anti-debugging code. In the first post to this series we discussed six different types of anti-debugging techniques that are in common use today. To refresh, the classifications buckets [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome back to the series on anti-debugging. Hopefully you have your debugger and development environment handy as we are about to dive into the first round of anti-debugging code. In the first post to this series we discussed six different types of anti-debugging techniques that are in common use today. To refresh, the classifications buckets that we chose to use are:</p>
<ul>
<li>API Based Anti-Debugging</li>
<li>Exception Based Anti-Debugging</li>
<li>Process and Thread Block Anti-Debugging</li>
<li>Modified Code Anti-Debugging</li>
<li>Hardware and Register Based Anti-Debugging</li>
<li>Timing and Latency Anti-Debugging</li>
</ul>
<p><strong>Basic API Anti-Debugging</strong></p>
<p>We&#8217;ll continue this series of posts by going into a bit more depth on the easiest of API based anti-debugging techniques. An application programming interface (API) is used to support requests made from other applications for resources or functionality within a target service or library. In our case we will be primarily focused on the Microsoft Windows operating system API. There are a number of calls built directly into the operating system API that make detection of a debugger possible. Minor differences in thread and process meta-data is present when processes are run within a debugger. These calls typically facilitate a process or thread examination technique in order to determine if the target thread has a debugger attached. </p>
<p>When learning about anti-debugging, a developer will typically first be introduced to the IsDebuggerPresent() function. This function analyzes the process block of a target process to determine if the processes is running under the context of a debugging session. We&#8217;ll save the details of how this actually works for a later article, however suffice it to say that the target process has a flag that will contain a non-zero value if the process is being debugged. This flag is queried and returned when IsDebuggerPresent() is called. A very basic debugging detection routine would be to call this function and execute different code paths based on the response.</p>
<pre>
Prototype: BOOL WINAPI IsDebuggerPresent(void); 

if (IsDebuggerPresent()) {
    //Debugger Detected - Do Something Here
} else {
    //No Debugger Detected - Continue
}
</pre>
<p>We could also use the API function CheckRemoteDebuggerPresent(). Contrary to first thought, this function does not target a process on a remote machine, nor does it even require that it target a process remote to itself. The call can use a parameter pointing to itself to determine if it is running inside of a debugger. In the example below we pass in a handle to our current process by calling the GetCurrentProcess() function along with a variable to hold the return value from the CheckRemoteDebuggerPresent() call.</p>
<pre>
Prototype: BOOL WINAPI CheckRemoteDebuggerPresent(__in HANDLE hProcess,
           __inout PBOOL pbDebuggerPresent);

BOOL pbIsPresent = FALSE;
CheckRemoteDebuggerPresent(GetCurrentProcess(), &amp;pbIsPresent);
if (pbIsPresent) {
    //Debugger Detected - Do Something Here
} else {
    //No Debugger Detected - Continue
}
</pre>
<p>While these two methods are probably the easiest and most straightforward methods of anti-debugging, they are also the most likely to be understood by a person wishing to bypass them. We can mix it up a bit and use a call to OutputDebugString() instead. OutputDebugString() is typically used to output a string value to the debugging data stream. This string is then displayed in the debugger. Due to this fact, the function OutputDebugString() acts differently based on the existence of a debugger on the running process. If a debugger is attached to the process, the function will execute normally and no error state will be registered; however if there is no debugger attached, LastError will be set by the process letting us know that we are debugger free. To execute this method we set LastError to an arbitrary value of our choosing and then call OutputDebugString(). We then check GetLastError() and if our error code remains, we know we are debugger free.</p>
<pre>
Prototype: void WINAPI OutputDebugString(__in_opt  LPCTSTR lpOutputString);

DWORD Val = 123;
SetLastError(Val);
OutputDebugString(L"random");
if(GetLastError() == Val) {
    //Debugger Detected - Do Something Here
} else {
    //No Debugger Detected - Continue
}
</pre>
<p>These three methods are the basic starting point for a developer wishing to implement anti-debugging into their code base. The methods are so simple they could even be implemented as macros making a call quick and easy. Numerous other API based detection methods exist with a vast array of complexity. In the next post in this series we will discuss slightly more advanced API anti-debugging techniques that will make reverse engineering and debugging even more difficult.</p>
<h5>Veracode Security Solutions</h5>
<div style="margin-left:15px;">
<a href="http://www.veracode.com/security/vulnerability-assessment-software">Vulnerability Assessment</a><br />
<a href="http://www.veracode.com/security/application-testing-tool">Application Analysis</a><br />
<a href="http://www.veracode.com/security/static-code-analysis">Static Code Analysis</a><br />
<a href="http://www.veracode.com/security/code-analysis">Source Code Analysis</a><br />
<a href="http://www.veracode.com/security/software-testing-tools">Software Testing Tools</a><br />
<a href="http://www.veracode.com/security/static-analysis-tool">Static Analysis</a><br />
<a href="http://www.veracode.com/security/web-application-security-testing">Web Application Security</a><br />
<a href="http://www.veracode.com/security/web-security">Website Security</a><br />
<a href="http://www.veracode.com/">Application Security</a></div>
<p></p>
<h5 style="margin-bottom: 10px">Security Threat Guides</h5>
<div style="margin-left:15px;">
<a href="http://www.veracode.com/security/mobile-code-security">Mobile Security</a><br />
<a href="http://www.veracode.com/security/sql-injection">SQL Injection</a><br />
<a href="http://www.veracode.com/security/xss">What is XSS</a>?<br />
<a href="http://www.veracode.com/security/csrf">CSRF</a><br />
<a href="http://www.veracode.com/security/ldap-injection">LDAP Security</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.veracode.com/blog/2008/12/anti-debugging-series-part-ii/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Anti-Debugging Series &#8211; Part I</title>
		<link>http://www.veracode.com/blog/2008/12/anti-debugging-series-part-i/</link>
		<comments>http://www.veracode.com/blog/2008/12/anti-debugging-series-part-i/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 20:56:25 +0000</pubDate>
		<dc:creator>Tyler Shields</dc:creator>
				<category><![CDATA[Binary Analysis]]></category>
		<category><![CDATA[RESEARCH]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.veracode.com/blog/?p=495</guid>
		<description><![CDATA[For those that don&#8217;t know, anti-debugging is the implementation of one or more techniques within computer code that hinders attempts at reverse engineering or debugging a target process. Typically this is achieved by detecting minute differences in memory, operating system, process information, latency, etc. that occur when a process is started in or attached to [...]]]></description>
			<content:encoded><![CDATA[<p>For those that don&#8217;t know, anti-debugging is the implementation of one or more techniques within computer code that hinders attempts at reverse engineering or debugging a target process. Typically this is achieved by detecting minute differences in memory, operating system, process information, latency, etc. that occur when a process is started in or attached to by a debugger compared to when it is not. Most research into anti-debugging has been conducted from the vantage point of a reverse engineer attempting to bypass the techniques that have been implemented. Limited data has been presented that demonstrates anti-debugging methods in a high level language that the average developer can understand. It is with this in mind that I hope to begin a series of posts that present some of the methods of anti-debugging in a clear, concise, and well documented fashion. The end goal of this series is to arm developers with the techniques and knowledge that will allow them to add a layer of protection to their software while simultaneous educating reverse engineers in some of the anti-debugging methods used by malware authors today.</p>
<p>Before we delve into the intricacies of individual methods of anti-debugging let&#8217;s use this post to define the classes of anti-debugging that we will be discussing. While other classes may exist, the definition of these classes is an attempt to include the majority of anti-debugging methods in use today. There is some overlap between classifications and we may have left out some methods due to limited exposure or effectiveness.</p>
<p><strong>API Based Anti-Debugging</strong><br />
API based anti-debugging is the most straightforward and possibly the easiest to understand for a typical developer. Using both documented and undocumented API calls, these methods query process and system information to determine the existence or operation of a debugger. From single line calls such as IsDebuggerPresent() and CheckRemoteDebugger() to slightly more complex methods including debugger detaching and CloseHandle() checks. These methods are generally trivial to add to an existing code base and many can even be implemented in as few as two or three lines.</p>
<p><strong>Exception Based Anti-Debugging</strong><br />
Exception based anti-debugging is slightly different than your basic API based techniques. Many times when a debugger is attached to a process, exceptions are trapped and handled by the debugger without regard to passing the exception back to the application for continued execution. Occasionally these exceptions can even crash or terminate a process when run under a debugger and be handled gracefully when running clean. It is these discrepancies that makes exception based anti-debugging techniques possible.</p>
<p><strong>Process and Thread Block Anti-Debugging</strong><br />
Some of the API based anti-debugging methods use published functions to query information from within the process and thread blocks for our running code. Many API based detections can be subverted within a debugger by hooking the API call and returning values that indicate a clean process. One way around this subversion is to directly query the process and thread blocks, bypassing the API calls. Direct analysis of the process and thread blocks, while more complex, can lead to a more accurate and high assurance result.</p>
<p><strong>Modified Code Anti-Debugging</strong><br />
One of the methods that a debugger uses to signal a breakpoint is to insert a break byte into the running code at the location that it wishes to stop execution. The process execution breaks when this value is seen, giving control to the debugger. When the program is resumed, the breakpoint value is removed and replaced with the original byte, the execution backed up one byte, and the program is resumed. Detection of software based breakpoints can be achieved by analyzing the process for modifications from the expected norm.</p>
<p><strong>Hardware and Register Based Anti-Debugging</strong><br />
A second way that a debugger can break the execution of a process is by using a hardware breakpoint. A hardware breakpoint relies upon CPU registers to store the pertinent information and to detect when the target break addresses are seen on the bus. A break interrupt is triggered at the appropriate time based on these register values. Reading or modifying the hardware can allow for the detection of a debugger.</p>
<p><strong>Timing and Latency Anti-Debugging</strong><br />
Finally timing and latency can be used as an effective anti-debugging method. When executing a program within a debugger, specifically when single stepping, a much larger latency occurs between execution of instructions. This latency can be detected and compared against a reasonable threshold to detect the existence of a debugger attached to our process.</p>
<p>Each of the classes of anti-debugging outlined above has merit when used individually to protect a process. While none of them can be assured to ever protect a program from a determined reverse engineer or debugger, implementation of these techniques (or many of them if appropriate) can sufficiently slow down the debugging process and hopefully make the attacker spend his time on other, easier, ventures. In the remainder of this series on anti-debugging we will review in depth some of the more interesting methods of each of the above classes. So bring along your debugger and your development environment and let the games begin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.veracode.com/blog/2008/12/anti-debugging-series-part-i/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>BlackHat Recap</title>
		<link>http://www.veracode.com/blog/2008/08/blackhat-recap/</link>
		<comments>http://www.veracode.com/blog/2008/08/blackhat-recap/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 22:43:18 +0000</pubDate>
		<dc:creator>Chris Eng</dc:creator>
				<category><![CDATA[Application Security]]></category>
		<category><![CDATA[Binary Analysis]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[RESEARCH]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[blackhat]]></category>
		<category><![CDATA[recap]]></category>

		<guid isPermaLink="false">http://www.veracode.com/blog/?p=202</guid>
		<description><![CDATA[Another BlackHat has come and gone. As usual, it was a very busy week juggling customer meetings, recruiting, conference planning, vendor parties, and, oh yes, the actual BlackHat presentations. I had a fantastic time catching up with old friends and finally getting the opportunity to meet more of the Security Twits and others in the [...]]]></description>
			<content:encoded><![CDATA[<p>Another BlackHat has come and gone.  As usual, it was a very busy week juggling customer meetings, recruiting, conference planning, vendor parties, and, oh yes, the actual BlackHat presentations.  I had a fantastic time catching up with old friends and finally getting the opportunity to meet more of the <a href="http://n0where.org/security-twits/">Security Twits</a> and others in the security community.  I didn&#8217;t submit a talk this year, but nevertheless, <a href="http://flickr.com/photos/fakedankaminsky/">fake Dan Kaminsky</a> was still excited to see me.</p>
<p><a href="http://www.veracode.com/blog/wp-content/uploads/2008/08/chris_2742966251_1b47297b33_b.jpg"><center><img src="http://www.veracode.com/blog/wp-content/uploads/2008/08/chris_2742966251_1b47297b33_b-300x225.jpg" alt="" title="chris_2742966251_1b47297b33_b" width="300" height="225" class="aligncenter size-medium wp-image-215 photoborder" /></center></a></p>
<p>My favorite talk, as expected, was the Sotirov/Dowd talk on <a href="http://taossa.com/archive/bh08sotirovdowd.pdf">How To Impress Girls With Browser Memory Protection Bypasses</a>.  The attack is a conceptually simple, yet completely reliable technique for exploiting vulnerabilities in web browsers.  Of course, the media has <a href="http://searchsecurity.techtarget.com/news/article/0,289142,sid14_gci1324395,00.html">sensationalized</a> the impact of their findings, but ultimately, this is still significant as far as browser-based exploits are concerned (here is a <a href="http://blogs.zdnet.com/Bott/?p=513">more accurate report</a>).  It&#8217;s worth mentioning that part of the technique allowing them to load a .NET DLL at an arbitrary location under Vista was reliant on an implementation bug wherein the OS disables ASLR if the version in the .NET COR header was below a certain value.  However, the address space spraying and stack spraying techniques are likely to be extended to other platforms utilizing similar memory protection mechanisms.  </p>
<p>As for the girls?  I can report first-hand that the ladies at TAO on Wednesday night were hanging on <a href="http://twitter.com/alexsotirov">Alex</a>&#8216;s every word.  They were particularly impressed when he whipped out the laptop for a live demo.  Unfortunately, none of the dozen iPhone owners in the immediate vicinity thought to snap a picture (too busy Twittering).  Oh well.  </p>
<p>I also enjoyed Hovav Shacham&#8217;s talk on return-oriented programming.  Simply put, he described a generalization of the return-to-libc shellcode approach with the intent to demonstrate that one could achieve Turing-complete computation using &#8220;found code&#8221; in process images.  By chaining together series of mini-computations ending in return (RET) instructions, it was possible to build higher-level programming constructs such as branches and loops.  The nature of the x86 instruction set provides some flexibility because instructions are interpreted differently depending on how you align the instruction pointer (i.e. the old shellcode trick of searching the process image for any JMP EBX instruction and using that as your EIP).  In RISC architectures such as SPARC, however, you don&#8217;t have that luxury; if your %pc isn&#8217;t aligned properly you get a bus error.  So it was quite interesting to see that they were able to extend the concept to RISC.  The practicality of the attack technique is limited by the fact that the shellcode is tuned to a particular binary image &#8212; if the shellcode was built using instructions extrapolated from glibc 2.3.5, it won&#8217;t work for a system running glibc 2.4.  </p>
<p>I thought Scott Stender&#8217;s talk on <a href="http://isecpartners.com/files/iSEC%20Partners%20-%20Concurrency%20Attacks%20in%20Web%20Applications.pdf">Concurrency Attacks in Web Applications</a> was interesting as well.  In a nutshell, spewing thousands of simultaneous requests at web application transactions that are not thread-safe can create interesting problems.  In the presentation, Scott ran his demo against a VM running on the attack machine.  I found myself wondering how effective the same attack would be over the Internet &#8212; would it be significantly less reliable (or not at all)?  Race conditions are generally easier to exploit locally than remotely due to more predictable execution conditions.  Certainly this is an under-tested vulnerability class though.</p>
<p>One presentation I wasn&#8217;t able to attend but want to follow up on is <a href="http://twitter.com/nate_mcfeters">Nate McFeters</a>, John Heasman, and Rob Carter&#8217;s talk which discussed the GIFAR attack I&#8217;ve been hearing so much about lately.  The gist is that you can create a file that is both a valid GIF and a valid JAR, then use some Java applet tricks to initiate HTTP requests on behalf of the victim.  </p>
<p>Finally, the <a href="http://pwnie-awards.org/2008/">Pwnie Awards</a> didn&#8217;t fail to disappoint.  Drama ensued over the Most Overhyped award, but at least this year some of the winners showed up to claim their awards!  <a href="http://twitter.com/halvarflake">Halvar</a> rapping Symantec lyrics was also quite memorable.</p>
<p>All in all, a fun and informative week, but as usual, I was relieved to get the hell out of Vegas and head home on Friday morning. </p>
<p>P.S. For a much more entertaining BlackHat/Defcon Recap, read <a href="http://securityuncorked.net/2008/08/anecdotes-blackhat-defcon/">Jennifer Jabbusch&#8217;s account</a> of the week&#8217;s events.  It&#8217;s my favorite one so far!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.veracode.com/blog/2008/08/blackhat-recap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trip Report: PH-Neutral</title>
		<link>http://www.veracode.com/blog/2008/05/trip-report-ph-neutral/</link>
		<comments>http://www.veracode.com/blog/2008/05/trip-report-ph-neutral/#comments</comments>
		<pubDate>Wed, 28 May 2008 20:56:40 +0000</pubDate>
		<dc:creator>Chris Eng</dc:creator>
				<category><![CDATA[Application Security]]></category>
		<category><![CDATA[Binary Analysis]]></category>
		<category><![CDATA[Malware]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[RESEARCH]]></category>
		<category><![CDATA[Vulnerabilities]]></category>
		<category><![CDATA[berlin]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[europe]]></category>
		<category><![CDATA[ph-neutral]]></category>

		<guid isPermaLink="false">http://www.veracode.com/blog/?p=98</guid>
		<description><![CDATA[I spent the weekend in Berlin attending a conference called PH-Neutral, run primarily by the Phenoelit crew. This was the first European security conference I&#8217;ve attended and I found it quite different from any North American security gathering I&#8217;ve been to, such as BlackHat, CanSecWest, SOURCE Boston, BlueHat, or RSA. Everything was far more casual [...]]]></description>
			<content:encoded><![CDATA[<p>I spent the weekend in Berlin attending a conference called PH-Neutral, run primarily by the <a href="http://www.phenoelit.de/">Phenoelit</a> crew.  This was the first European security conference I&#8217;ve attended and I found it quite different from any North American security gathering I&#8217;ve been to, such as <a href="http://blackhat.com">BlackHat</a>, <a href="http://cansecwest.com/">CanSecWest</a>, <a href="http://www.sourceboston.com/">SOURCE Boston</a>, <a href="http://www.microsoft.com/technet/security/bluehat/default.mspx">BlueHat</a>, or <a href="http://rsaconference.com/">RSA</a>.  Everything was far more casual and laid back, which is something I had heard about European conferences but hadn&#8217;t experienced until now (even EUSecWest is held in a club whereas CanSecWest is in a Marriott).</p>
<p><a href='http://www.veracode.com/blog/wp-content/uploads/2008/05/2525962901_6c15d2f291_o.jpg'><center><img src="http://www.veracode.com/blog/wp-content/uploads/2008/05/2525962901_6c15d2f291_o-300x225.jpg" alt="PH-Neutral Bridge" title="2525962901_6c15d2f291_o" width="300" height="225" class="aligncenter size-medium wp-image-103 photoborder" /></center></a></p>
<p>The event was held at <a href="http://www.insel-berlin.net/">Die Insel</a>, on a tiny island a few kilometers outside of Berlin&#8217;s city center, near Treptower Park.  The venue is mostly used for live music so basically it feels like a dark, somewhat dingy club (certainly the bathrooms are reminiscent of a club).  The presentations were on the 3rd floor in a room that probably held about 60 people in close quarters; to handle overflow, a closed-circuit feed was being simulcast on the 4th floor, which was a bit less crowded and, more importantly, opened out onto a rooftop deck which meant better ventilation.  The bottom floor led out to a Biergarten with tables, beach chairs, and a stage which was used for DJing.  The layout was actually pretty efficient for allowing around 200 people to mill about and socialize/network while not having to stray too far from where the talks were presented.</p>
<p><a href='http://www.veracode.com/blog/wp-content/uploads/2008/05/2525962813_b842faf96d_o.jpg'><center><img src="http://www.veracode.com/blog/wp-content/uploads/2008/05/2525962813_b842faf96d_o-225x300.jpg" alt="Bridge to Die Insel" title="2525962813_b842faf96d_o" width="225" height="300" class="aligncenter size-medium wp-image-102 photoborder" /></center></a></p>
<p>As far as the event itself, when I said &#8220;laid back&#8221; earlier, don&#8217;t interpret that to mean disorganized or watered down in any way.  It was run with stereotypical German efficiency, from badging to presentations to the after-hours parties.  The presentations were just as technical and relevant as any of the more &#8220;corporate&#8221; conferences.  Unfortunately for me, I don&#8217;t know that many people in European security circles, and most of the ones I do know weren&#8217;t in attendance.  Those I did meet, however, were impressively smart and well-versed.  Nobody was trying to conduct business transactions or slip away for meetings, which is inevitably what happens when only technical folks are present!</p>
<p><a href='http://www.veracode.com/blog/wp-content/uploads/2008/05/2526783152_fed88680d4_o.jpg'><center><img src="http://www.veracode.com/blog/wp-content/uploads/2008/05/2526783152_fed88680d4_o-225x300.jpg" alt="PH-Neutral Registration" title="2526783152_fed88680d4_o" width="225" height="300" class="alignnone size-medium wp-image-101 photoborder" /></center></a></p>
<p>For me, a few talks stood out.  Fukami and BeF&#8217;s talk on <a href="https://www.flashsec.org/mediawiki/images/5/57/SWF_and_the_Malware_Tragedy.pdf">SWF and the Malware Tragedy</a> discussed methods for automated static detection of malware in Flash movies.  Much of it centered on heuristics related to inconsistencies in the file format or tag structure, abnormal concentrations of strings in the constant pool, or the existence of various obfuscation techniques.  Ultimately, there are false positive issues to be addressed but that is just a fact of life with static analysis, and it will be an iterative process to refine those heuristics as the attack vectors evolve.  I thought this talk was particularly timely given the increasing prevalence of Flash as a conduit for exploits/malware, such as the most recent <a href="http://trailofbits.com/2008/05/28/flash-zero-day-attacks-wow/">Flash 0day</a> that made the news (granted, this was an exploit against Flash itself, not just using Flash as a delivery mechanism, but close enough).</p>
<p>I also enjoyed pierre&#8217;s talk on counterintelligence, basically a mélange of wiretapping and other bugging devices discovered in the wild.  War stories are always interesting, particularly when it comes to the realm of physical security.  One of the x-ray images he showed of a bugged pen was identical to a pen that I own (minus the bugging device of course&#8230; I hope).  The feel of the talk reminded me a bit of James Atkinson&#8217;s talk at SOURCE, &#8220;Telephone Defenses Against the Dark Arts&#8221; (video: <a href="http://sourceboston2008.blip.tv/file/799027/">Part 1</a> and <a href="http://sourceboston2008.blip.tv/file/800299/">Part 2</a>), which also got rave reviews.  </p>
<p>Mike Eddington&#8217;s presentation on the <a href="http://peachfuzz.sourceforge.net/">Peach 2</a> fuzzing framework was also quite interesting.  Peach 2 was released several months back but I haven&#8217;t really been paying much attention to it or any other fuzzing tool for some time.  In fact the last time I really had to implement a protocol fuzzer, I was using SPIKE 2.9, so that gives you some indication of how long it&#8217;s been.  Peach 2 includes some powerful built-in capabilities such as node relationships (e.g. field 1 represents the length of field 2; field 10 is a CRC-32 of fields 1 through 9), data transforms (those with battle scars from ASN.1 will be happy), state machines (packets 1 and 2 have to be normal in order to fuzz packet 3), monitoring agents (detecting when a crash happens and under what conditions), and much more.  I am itching to go fuzz something now just so I can tinker with Peach.</p>
<p>All in all, it was a good trip and I enjoyed the opportunity to see how things are done across the pond, and to do a little sightseeing in a historic and beautiful city.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.veracode.com/blog/2008/05/trip-report-ph-neutral/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

