<?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>Perimeter Grid &#187; mitigations</title>
	<atom:link href="http://perimetergrid.com/wp/category/mitigations/feed/" rel="self" type="application/rss+xml" />
	<link>http://perimetergrid.com/wp</link>
	<description>Building Security in a Networked World</description>
	<lastBuildDate>Thu, 12 Aug 2010 17:28:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>BlackHat 2010: Day 1</title>
		<link>http://perimetergrid.com/wp/2010/08/12/blackhat-2010-day-1/</link>
		<comments>http://perimetergrid.com/wp/2010/08/12/blackhat-2010-day-1/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 17:28:48 +0000</pubDate>
		<dc:creator>Grant Bugher</dc:creator>
				<category><![CDATA[attacks]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[crypto]]></category>
		<category><![CDATA[industry]]></category>
		<category><![CDATA[mitigations]]></category>
		<category><![CDATA[products]]></category>

		<guid isPermaLink="false">http://perimetergrid.com/wp/?p=115</guid>
		<description><![CDATA[I&#8217;ve just returned from a trip to BlackHat Briefings USA 2010 and DefCon 18. As always, it was an enjoyable week in Las Vegas learning about the latest research, networking with the surprisingly small world of security professionals, and generally having fun hanging out with a lot of interesting people with the hacker mindset. BlackHat [...]<p>a</p>
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just returned from a trip to <a href="http://blackhat.com/html/bh-us-10/bh-us-10-home.html">BlackHat Briefings USA 2010</a> and <a href="http://defcon.org/html/defcon-18/dc-18-index.html">DefCon 18</a>.  As always, it was an enjoyable week in Las Vegas learning about the latest research, networking with the surprisingly small world of security professionals, and generally having fun hanging out with a lot of interesting people with the hacker mindset.</p>
<p>BlackHat started out with a <a href="http://blackhat.com/html/bh-us-10/bh-us-10-keynote.html">keynote from Jane Holl Lute, Deputy Secretary of Homeland Security</a>.  She gave the sort of banal, predictable speech we expect from a political appointee &#8212; the country needs a secure homeland, dynamic economy, and the rule of law.  &#8220;Cyberspace&#8221; isn&#8217;t a warzone, because wars happen somewhere, kill people, are lawless, and &#8220;cyberspace&#8221; isn&#8217;t like this.  (The one sure sign you&#8217;re listening to a government official is the constant use of the prefix &#8220;cyber-&#8221;.  An even more sure sign is the use of &#8220;cyber&#8221; as a noun by itself, which so far as I can tell is done <em>only</em> by feds.)</p>
<p>She states that the five essential missions of DHS are to prevent terrorist attack, secure borders (while expediting trade &amp; travel), enforce immigration laws, ensure the safety &amp; security of &#8220;cyberspace,&#8221; and help build a resilient society.  While I really like the emphasis on resilience in her rhetoric, I do wish DHS had more visible efforts in that direction rather than appearing to be wholly focused on prevention.  She also laments that billions have been spent in cybersecurity, but the most fundamental problems still aren&#8217;t fixed, and claims that the administration wants to build a cybersecurity strategy and vision for the nation.  I find this claim curious for two reasons: first of all, billions have been spent on physical security, too, and yet we don&#8217;t seem to have &#8220;fixed&#8221; crime and violence, so why should we expect information security to be any different?  And second, DHS saying we <em>need</em> a &#8220;cybersecurity&#8221; strategy implies that they don&#8217;t <em>have</em> one.</p>
<p>Jeff Moss seemed far more excited about this talk than its content warranted.  Simple politeness to a speaker, or the effect of his presence on the Homeland Security Advisory Council?  Also, during Q&amp;A one person asked her why, given that the TSA is the laughingstock of the world, we should expect DHS to do any better with the Internet.  (While the question is admittedly a cheap shot and not an actual argument, her response &#8212; which was to say that the TSA is just fine and not mocked throughout the world at all &#8212; did not exactly inspire confidence either.)</p>
<p>My first session after the keynote was called <a href="http://blackhat.com/html/bh-us-10/bh-us-10-briefings.html#Grugq">Base Jumping, by the Grugq</a>.  This was one of two major talks about cell phone hacking on GSM this year.  The GSM protocol specification runs dozens of documents and thousands of pages, but according to the Grugq, the important one is GSM 04 08, which defines layer 3.</p>
<p>GSM is based on TDMA (Time Division Multiple Access,) so decoding is based on time &#8212; the clock in a phone must be synced with the clock in the base station.  Only a tiny amount of data is sent per timeslot.  There are only 23 bytes in a timeslot, so you can do a complete exhaustion fuzzing in 3 days (and he did.)</p>
<p>Communication is done over a variety of named channels.  BCCH (broadcast control channel) is how a base station sends out its information messages. PCH (paging channel) announces incoming SMS or phone calls. RACH (random access channel) is used by the phone to request a channel, which it gets back over AGCH (access granted channel.)  Opening a channel is slow &#8211; it takes 2-3 seconds.  Since it&#8217;s based on timeslots, can take quite a while for the base station to have an open slot of the appropriate channel to reply in.</p>
<p>Collisions are frequent since channel number is just 25 bits, and some cheap phones actually hardcode a list of random numbers instead of generating them (apparently generating a 25-bit number is just too hard for them.)</p>
<p>Police sometimes use IMSI catchers, which impersonate the network and make the phones all hand over their IMSI (International Mobile Subscriber Identifier &#8212; your ID off your SIM card that tells the phone company who you are.)  The protocol is flawed &#8212; the phone authenticates with the network, but the network does not authenticate to the phone, and thus can be impersonated.</p>
<p>A German group built an open-source baseband for a common, cheap cell phone (the Motorola C118 or C123, about 5 Euro on eBay.).  This can then be hacked to send arbitrary GSM traffic.  Among the Grugq&#8217;s apps were:</p>
<p>RACHell: request channel allocation, then flood the base station with requests.  This will DoS the entire cell by using all the channels.  A cell can only hold about 1000 users.  Since the cell is backed up to a base station controller (BSC), this attack may take down the BSC as well (which shuts down the whole tower for half a day.)</p>
<p>IMSI Flood: send IMSI ATTACH messages, indicating a user coming online.  These are sent pre-authentication, and if you send too many random numbers as IMSIs, it can overwhelm the HLR/VLR infrastructure (the database that tells which tower has which phones attached to it) and takes down the whole network.  This could also be used to make police IMSI catchers pretty much useless.  I got the idea that the Grugq had not actually tested this, since taking down a cell network might get a little unwanted attention.</p>
<p>IMSI DETACH: When phones are turned off, they tell the network they&#8217;re no longer available via sending a single unauthenticated frame.  If you have someone&#8217;s IMSI (which you can look up by phone number for $0.006,) you can send one for someone else, which disables that phone from receiving calls or SMS and cuts off any in-progress phone calls.  The victim can still make new calls, however, which will reattach them to the network &#8212; but if you&#8217;re sending DETACHes every 5 seconds, this will do little good.</p>
<p>Baseband fuzzing: fuzzing the baseband (the radio in individual phones) by impersonating the tower pretty much causes every phone available to crash.  However, lacking the code for the basebands, the Grugq didn&#8217;t find any remote exploits here.  However, the overall point is that GSM is no longer a walled garden &#8212; anyone can send GSM traffic with minimal equipment now, and protocol security is required.</p>
<p>The next session I attended was <a href="http://blackhat.com/html/bh-us-10/bh-us-10-briefings.html#KaneParry">More Bugs in More Places, by David Kane-Parry of Leviathan Security</a>.  This was an overview of the SDKs and security models for Android, Windows Phone 7, BlackBerry, and iPhone.  There was nothing particularly new here, nor did he come to any conclusion as to the superiority or inferiority of any one of the platforms, so I&#8217;m not going to go into details.</p>
<p>The next talk was <a href="http://blackhat.com/html/bh-us-10/bh-us-10-briefings.html#Jack">Barnaby Jack of IOActive with the wildly popular topic of jackpotting ATMs</a>.</p>
<p>Current ATM attacks are mostly skimmers, physical theft, Ram raids (dragging the ATM away with a truck,) card trapping and shoulder surfing PINs, or frontal attack via safe cutting or even explosives.  Barnaby Jack wanted to instead attack the software.  Most new model ATMs are Windows CE based, with an ARM/Xscale processor, remote connection via TCP/IP or dial-up, with SSL support and a Triple DES encrypted PIN pad.  Since the developers of Windows CE developers concerned were more concerned with protection (in the process sense) than security, this provides an opportunity.</p>
<p>To reverse engineer this, he bought a couple of ATMs and had them delivered to his house (which the delivery people found rather bizarre, but did.)  ATMs boot directly to a proprietary ATM application.  In order to get a shell, he connected a JTAG interface for full debugging access to the processor core, set a breakpoint on CreateProcess(), and replaced the target ATM executable string with explorer.exe.  With explorer, he could connect a USB disk and keyboard and copy files off for offline research, make registry changes permanent (so as to always boot Explorer), create a debugging environment, then set up remote app debugging in Visual Studio.</p>
<p>The external attack surface is limited to the card reader, keypad, network, and motherboard inputs.  This leads to two possible attack plans &#8212; remote over the network ,or a walk-up attack.  It turns out the walk-up attack is quite possible, since while the cash is protected by a two-inch-thick steel safe, the motherboard is protected by <em>a one-key-fits-all lock you can buy keys for on the Internet</em>.</p>
<p>With motherboard accessible, you can access USB, SecureDigital, and CompactFlash slots.  On boot, the app code checks these drives for firmware upgrades and applies them.  (And there&#8217;s a reboot switch on the motherboard, too!)</p>
<p>From a remote perspective, ATMs support remote monitoring and configuration to allow changing splash screens, cash denominations, etc., or even do remote firmware upgrades.  There are multiple levels of authentication, but Barnaby Jack found a vulnerability in this authentication process allowing for a remote authentication bypass.  (He did not disclose his authentication bypass, but said he found it by fuzzing, so this work will probably be duplicated by others.)</p>
<p>He demonstrated two tools &#8212; one was Dillinger, a remote ATM attack and administration tool which exploits the remote authentication bypass.  It&#8217;s reliable on dial-up or TCP/IP, and exchange scanning with a VoIP wardriver like WarVox is possible.  Dillinger allows management of unlimited ATMs, can test remote bypass, retrieve location &amp; master passwords, upload rootkits, and even retrieve the track data from all the cards that have been inserted into the machine.</p>
<p>Scrooge, an ATM rootkit, runs on the device hidden in background, activated by special key sequence or custom card.  It runs on any ARM/Xscale ATM, or Intel ones with some tweaks, but must be customized for different ATM models.  It has a keyboard filter that hooks the ATM keypad &amp; side buttons &#8212; SetWindowsHook() is undocumented on CE but still works.  A special key sequence (or a card whose track data spells out &#8220;GIMMEDALOOT&#8221;) launches a menu.  Scrooge captures track data and pin-pad input, and can issue remote commands.</p>
<p>This is better seen than described.  Here&#8217;s some video of remote ATM hacking with Dillinger:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/qwMuMSPW3bU&amp;hl=en_US&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="385" src="http://www.youtube.com/v/qwMuMSPW3bU&amp;hl=en_US&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>And here we have the aftermath of a physical attack, where he opened the ATM with a key, stuck in a USB drive, and hit the reset button on the motherboard:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/fS3Z8Xv-vUc&amp;hl=en_US&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="385" src="http://www.youtube.com/v/fS3Z8Xv-vUc&amp;hl=en_US&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>The &#8220;777 Jackpot!&#8221; on the screen and the peppy music are a nice touch.</p>
<p>As for how to prevent these sorts of vulnerabilities in the future, he recommends that ATM vendors offer upgrade options on the physical locks (say to at least making the key unique), implement binary signing at the kernel level to prevent unauthorized firmware upgrades, and disabling remote management on the device.</p>
<p>For the final presentation of the day, I attended <a href="http://blackhat.com/html/bh-us-10/bh-us-10-briefings.html#Kaminsky">Dan Kaminsky&#8217;s talk</a>, which was actually not the talk described in the BlackHat documentation at all, but rather an entirely different talk on using DNSSEC to implement public key infrastructure, due to the fact that the DNSSEC root was finally signed (after only 18 years&#8230;) three weeks ago.</p>
<p>Dan seeks to use DNSSEC to solve a variety of problems, by creating what he calls a Domain Key Infrastructure:</p>
<ul>
<li>For users: when you receive an email, you can actually know for certain who it came from.
</li>
<li>For infrastructure buyers: we need strong authentication as much today as we did when trying (and failing) to create PKI in the past, and with DNSSEC we can actually create a working PKI.  60% of security breaches are credential-related.
</li>
<li>For infrastructure builders: DKI will make security products scale, and allow devices to validate the identity of peers.  You can build scalable federated systems.
</li>
<li>For hackers and penetration testers: Dan&#8217;s new company will be actively supporting an aggressive public audit of all DNSSEC and DKI technologies.
</li>
</ul>
<p>Dan&#8217;s definitely right about one thing &#8212; we aren&#8217;t going to get security via moralizing about user education or waiting for regulation. Will have to deliver a better product as judged by the people who have to run it.</p>
<p>DNSSEC is simple &#8212; it works just like DNS, but referrals and authoritative records are signed.  Thus, when referred elsewhere, you&#8217;re told not only where the server to ask is, but also how to recognize it.  Keys can lead to other keys.  </p>
<p>DNSsec was complex to deploy because it was designed to allow &#8220;key in a vault&#8221; security, where keys are offline and not generated on demand.  When it was proposed <em>eighteen years ago</em>, CPUs were slow, and some installations are incredibly large (e.g. .com)  Offline keying is cumbersome.  However, there&#8217;s an alternative that&#8217;s relatively simple to deploy.</p>
<p>Phreebird is a DNSSEC server that&#8217;s simple because it uses online keysigning, just like SSL, SSH, and IPsec.  There is some risk here, of course, but we seem to accept it everywhere else, as everyone keeps keys online for some protocols.  Those who are really concerned about security can use a hardware security module.  Phreebird works as a proxy, and has effectively nothing to configure &#8212; you change the port of the DNS server, run Phreebird, and then supply the signature to your DNS registrar.  It&#8217;s presently implemented as a UDP port forwarder, but they&#8217;re rebuilding it as a Linux mangle table.  It&#8217;s very fast; according to Dan, it&#8217;s an order of magnitude faster than the DNS servers it&#8217;s proxying, so there should be almost no load.  For performance, it caches signed responses, but always passes queries to the real nameserver so that all scenarios work &#8212; but if it gets the same thing, it pulls up the cached signed response instead of resigning.  Phreebird is open source and will be out in the next few weeks.</p>
<p>Distributed authentication is only interesting if it&#8217;s end-to-end.  The current methods of DNSSEC lookups, chasing &#038; tracing, are blocked by various types of servers, which makes operational implementation difficult.  Phreebird also supports wrapping DNS (and DNSSEC) in HTTP, using a custom DNS server that exposes an HTTP endpoint and takes base64-encoded DNS requests.  They claim there is no performance hit.</p>
<p>Likewise, while X.509 is flawed (since a certificate just has to chain to one of a few hundred root CAs by way of thousands of untrustworthy intermediaries, and there is no exclusion or delegation,) it can still be used to wrap DNSSEC &#8212; high performance, easy tunneling via DNS over X.509 over SSL.  When one of these certificates is received, you just need to extract all the keys from the trust chain and validate it all.</p>
<p>From here, Dan got into the more interesting stuff &#8212; what he calls DKI (Domain Key Infrastructure.)  What if you could use DNSSEC to create a working PKI system?  Since DNSSEC lets you strongly authenticate a domain, you can then ask that domain to authenticate users, and trust the response since you have a key for the domain.  To demonstrate this, he presented PhreeShell: federated identity for OpenSSH.  With this modification, .ssh/authorized_keys2 contains identities (e.g. grant@perimetergrid.com) rather than keys &#8212; it makes delegating access trivially easy.</p>
<p>Trusting DNSSEC eliminates the scaling issues of federated PKI.  Really, you&#8217;re not trusting DNSSEC so much as ICANN, but it seems a fairly good choice for a single root keyholder in that it has external political constraints and a delegation system designed to prevent operational dependency.</p>
<p>So how do we implement DKI everywhere?  Eventually, by adding the functionality to everything &#8212; link in LDNS or libunbound.  On Linux, you can make most things work by patching X509_verify_cert in OpenSSL, because practically everything calls out to it for crypto, but there&#8217;s nothing so simple in the browser world, where IE uses CryptoAPI, Firefox and Chrome use NSS, and most apps are cross-platform.  For this, Dan has an app called Phoxie, which is a remote validation proxy for production browsers that allows certificate verification against DNSsec in current browsers.  It&#8217;s also possible to make self-certifying URLs, but they look horrible and become unusable if the certificate ever expires or needs rotated, so they&#8217;re not a good solution.</p>
<p>Finally, we may get secure email out of this.  If we can verify what server sent an email (which with DNSSEC we can), we can also in many cases be sure who sent it (as if the email came from a &#8220;respectable&#8221; domain it wouldn&#8217;t let users send mail as each other.)  Right now the user experience around secure email is minimal, but our faith in it has been low &#8212; if most email could be verified, we could easily get to a world where email clients only stated mail was &#8220;From&#8221; someone if this fact had been cryptographically verified, and otherwise used some suspicion-inducing verbiage (e.g. the X-Supposedly-From header.)</p>
<p>Overall, Dan&#8217;s talk was interesting, but I find my enthusiasm is rather limited by lack of faith any of this stuff will be <em>used</em>.  DNSSEC has been around for 18 years and no one uses it yet; having the root signed is a wonderful step and I hope it leads to the revolution in PKI Dan&#8217;s touting, but I also feel like I&#8217;ll believe it when I see it.</p>
<p>After all the talks, I dropped in on parties thrown by Mandiant, IOActive, and NetWitness, but unfortunately had to skip Tenable and Rapid7.  There are so many parties, receptions, and events that it&#8217;s impossible to visit all or even most of them.</p>
<p>a</p>
]]></content:encoded>
			<wfw:commentRss>http://perimetergrid.com/wp/2010/08/12/blackhat-2010-day-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Secure Use of Cloud Storage</title>
		<link>http://perimetergrid.com/wp/2010/08/03/secure-use-of-cloud-storage/</link>
		<comments>http://perimetergrid.com/wp/2010/08/03/secure-use-of-cloud-storage/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 05:39:50 +0000</pubDate>
		<dc:creator>Grant Bugher</dc:creator>
				<category><![CDATA[SOA/XML]]></category>
		<category><![CDATA[attacks]]></category>
		<category><![CDATA[mitigations]]></category>

		<guid isPermaLink="false">http://perimetergrid.com/wp/?p=110</guid>
		<description><![CDATA[At BlackHat Briefings USA 2010 in Las Vegas this year, I presented a session entitle Secure Use of Cloud Storage, covering ways that developers can use (and misuse) cloud storage systems like Microsoft&#8217;s Windows Azure Storage and Amazon&#8217;s Simple Storage Service (S3) and SimpleDB. While the released versions are available on the BlackHat official website, [...]<p>a</p>
]]></description>
			<content:encoded><![CDATA[<p>At BlackHat Briefings USA 2010 in Las Vegas this year, I presented a session entitle Secure Use of Cloud Storage, covering ways that developers can use (and misuse) cloud storage systems like Microsoft&#8217;s Windows Azure Storage and Amazon&#8217;s Simple Storage Service (S3) and SimpleDB.  </p>
<p>While the <a href="http://www.blackhat.com/html/bh-us-10/bh-us-10-archives.html#Bugher">released versions</a> are available on the <a href="http://www.blackhat.com">BlackHat official website</a>, I&#8217;m also making these available here for those who are interested.  You can download either the <a href='http://perimetergrid.com/Secure%20Use%20of%20Cloud%20Storage.pptx' >unabridged slide deck</a> (which was cut down considerably to fit in the BlackHat 75-minute time limit) or the <a href="http://perimetergrid.com/Secure%20Use%20of%20Cloud%20Storage%201.0.docx">complete whitepaper</a>.  These are both more recent than the versions on the BlackHat site.</p>
<p>In addition, I&#8217;ll be posting writeups of the talks I attended at BlackHat 2010 and DefCon 18 in the coming days.</p>
<p>a</p>
]]></content:encoded>
			<wfw:commentRss>http://perimetergrid.com/wp/2010/08/03/secure-use-of-cloud-storage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BlackHat 2008, Day 2</title>
		<link>http://perimetergrid.com/wp/2008/08/13/blackhat-2008-day-2/</link>
		<comments>http://perimetergrid.com/wp/2008/08/13/blackhat-2008-day-2/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 16:42:52 +0000</pubDate>
		<dc:creator>Grant Bugher</dc:creator>
				<category><![CDATA[SOA/XML]]></category>
		<category><![CDATA[attacks]]></category>
		<category><![CDATA[legal]]></category>
		<category><![CDATA[mitigations]]></category>
		<category><![CDATA[trusted client]]></category>

		<guid isPermaLink="false">http://perimetergrid.com/wp/?p=66</guid>
		<description><![CDATA[The second day of BlackHat 2008 began with a keynote speech by Rod Beckstrom, the director of NCSC (the National Cyber Security Center.) Most of this consisted of painfully strained Civil War analogies and the overuse of the word &#8220;Cyber&#8221; to describe absolutely everything. He made some good points &#8212; specifically, that in order to [...]<p>a</p>
]]></description>
			<content:encoded><![CDATA[<p>The second day of BlackHat 2008 began with a keynote speech by <a href="https://www.blackhat.com/html/bh-usa-08/bh-usa-08-speakers.html#Beckstrom">Rod Beckstrom</a>, the director of NCSC (the National Cyber Security Center.)  Most of this consisted of painfully strained Civil War analogies and the overuse of the word &#8220;Cyber&#8221; to describe absolutely everything.  He made some good points &#8212; specifically, that in order to truly solve information (er, &#8220;Cyber&#8221;) security problems, we have to know the desired end state, which is more than just fixing the exploits or vulnerabilities of the week.  We don&#8217;t even fully understand the physics and economics of networks, security, and risk management.  The economics of security has to be based around risk management &#8212; if the marginal cost of a security measure exceeds the marginal loss it prevents, it&#8217;s counterproductive (something the government seems to often miss when it comes to &#8220;national security&#8221; anti-terrorism measures.)  He seemed overly worried about the IP protocol stack as a single point of failure, and wants to keep it out of the systems it&#8217;s currently out of (say, SMS, which works even when most of the cell network is down.)  I find this overly alarmist mainly because the IP protocol stack has been constantly attacked and exhaustively examined for nearly thirty years, and even the hackers have pretty much given up on this sort of attack.  Yes, a successful exploit of the IP stack that let you, say, reroute, modify, or destroy traffic would be catastrophic on the same scale as Kaminsky&#8217;s DNS attacks of the last month, but so would an asteroid strike &#8212; the potential impact is huge, but the likelihood is very low.</p>
<p>All that said, I wouldn&#8217;t argue for IP-izing currently-working non-IP networks like SMS, either.  There&#8217;s simply no reason to.</p>
<p>Next, <a href="https://www.blackhat.com/html/bh-usa-08/bh-usa-08-speakers.html#Evans">Arian Evans</a> of WhiteHat security spoke on web application canonicalization, encoding, and transcoding attacks.  This was one of the more interesting (and personally useful) talks of the conference for me.  Web application vulnerabilities fall into two categories &#8212; syntax vulnerabilities, which fork code-paths, like SQL injection, cross-site scripting, etc., and semantic issues, consisting of errors in business logic.  Syntax issues are normally fought by signature-based methods like IDS/IPS, WAFs (Web Application Firewalls), and XML firewalls.  However, encoding syntax attacks can cause them to bypass these defenses.</p>
<p>Internationalized websites often require encoding and code page transitions in order to work.  In addition, developers use encodings for type safety.  An attacker can take advantage of these to get a syntax attack to its target:</p>
<ol>
<li>Choose a vulnerability you want to exploit (e.g. XSS, SQL Injection)</li>
<li>Identify the parser on the target (browser, database, application, etc.)</li>
<li>Identify the supported encodings, codepages, and character sets on the target</li>
<li>Identify intermediate interpreters between you and the target that canonicalize alternative encodings, such as web browsers, web application firewalls, proxies, or other applications</li>
<li>Encode your attack such that it will be parsed in the desired way by the target after being canonicalized by all the intermediaaries</li>
</ol>
<p>This results in complex nested encodings, such as encoding SQL with the CHAR/CHR functions, then decimal encoding that, then URI encoding that result.  The resultant mess goes right past IDS/IPS, but each interpreter strips off a layer of encoding, and when the payload finally reaches the target, it is interpreted property and works.  More sophisticated, internationalized apps are often <em>easier </em>to hit, because you have more options for submitting encoded (in another codepage) metacharacters that are later transcoded by the applications.</p>
<p>The solutions offered for this were the usual &#8212; strong data typing, strong output encoding (to prevent XSS), and enforcing the code/data boundary whenever possible (which isn&#8217;t often when it comes to web apps.)  Still, this is very good stuff for demonstrating a SQL injection or XSS vulnerability to a business manager who insists that it&#8217;s not <em>really</em> exploitable.</p>
<p>Next, <a href="https://www.blackhat.com/html/bh-usa-08/bh-usa-08-speakers.html#Buetler">Ivan Buetler</a> gave a presentation on smart cards, specifically the security of APDU, the Application Protocol Data Unit.  Smart cards are mass-produced by a few companies, then sent out to companies or agencies that want to use them for security.  The buyer initializes them with software and policy, then gives them to a user, who personalizes them with specific keys (often under the guidance of their employer.)  Software from the manufacturer can be used to initialize or personalize cards.  This demo used the Axalto Access Client, specifically the COVE and CMS administration tools.</p>
<p>The card itself enforces PIN policies and (sometimes) generates keys.  During initialization, applets (written in Java and converted to a smart card bytecode) are uploaded to the card to add functionality.  The upload, and all communication with the card, is done in APDU codes.  These are laid out in the ISO 7816 specification, but there are <em>many </em>vendor extensions, which tend to be poorly documented &#8212; so many that the ISO spec is almost useless in reading APDU.  However, it&#8217;s a simple command structure &#8212; a command consists of a class byte, an instruction byte, two 1-byte parameters, a data length, and a variable-length data field (and of course a checksum.)  Ivan used an app called Smart Card Toolkit Pro 13.4.2 (I can find no reference to it on the Internet other than offers to pirate or crack it) to sniff the communication with the cards and read the APDUs.  He also developed his own tools to hook winscard.dll so as to add himself to the stream as a man in the middle and be able to modify APDUs (and thus send arbitrary commands to the card.)</p>
<p>This revealed some significant vulnerabilities.  For instance, during initialization, a card can be set to either generate its own keys, or to accept keys being uploaded as-is.  However, this is &#8220;enforced&#8221; by the card later <em>telling the personalization software </em>that it would like to generate its own keys.  It&#8217;s a classic trusted-client scenario; if you modify the APDUs, the application can be convinced to ignore the card&#8217;s settings, and the card takes whatever the app sends.  Lacking any APDU documentation, Ivan was only able to find a few settings like this, but if the designers of the Axalto smart card system think that&#8217;s an acceptable practice, there are probably many more.</p>
<p><a href="https://www.blackhat.com/html/bh-usa-08/bh-usa-08-speakers.html#Stender">Scott Stender</a> of iSec Partners spoke next, about concurrency attacks in web applications.  This started out with an explanation of multiprocessing (in short, on any given core, two things that execute &#8220;simultaneously&#8221; don&#8217;t really &#8212; they alternate really fast, which means that they <em>do </em>execute in an order, and you can&#8217;t always predict what that order is.)  This would have been a more interesting talk to me had I not spent years debugging crazy stress and performance issues in the past &#8212; I&#8217;m quite familiar with concurrency and race conditions.</p>
<p>With web applications, web app frameworks like .NET and Java Struts define an interface that contains request context (e.g. cookies, local variables, session variables.)  Access to shared resources needs to be protected, but since web access is asynchronous, threads sometimes find themselves working with dirty or stale data.  The classic example is a bank &#8211; imagine a money transfer process like this:</p>
<ol>
<li>Collect source account number, destination account number, source account balance, destination account balance, and amount to transfer.</li>
<li>Verify that the source account balance exceeds the amount to transfer.</li>
<li>Set the destination account balance to its former balance plus the amount transferred, and set the source account balance to its former balance minus the amount transferred.</li>
</ol>
<p>Seems perfectly sane.  Now imagine that I put in a request to transfer my entire balance, then while that request is between steps 2 and 3, I start another request to transfer my entire balance, and it completes steps 1 and 2 before the first request resumes at 3.  With multiprocessing this is quite possible &#8212; and it would result in my transferring twice as much money as I have (and likely without even having a negative source account balance.)</p>
<p>Concurrency flaws allow manipulating stateful assets (like the above bank accounts) or changing security parameters (like auth credentials or single-use redemption tokens such as gift certificate codes.)</p>
<p>The solution is well-established in the database world &#8212; transactions.  Transactions are atomic, concurrent, isolated, and durable (the so-called &#8220;ACID test&#8221;) &#8212; a transaction succeeds or fails as a single unit (no part of it happens unless all of it happens), and none of the resources in a transaction may be touched until the transaction is complete.  Web apps can implement their own transactions, or use the transactional support of their underlying database architecture.  The important part is that there is some kind of end-to-end scoped lock (and global locks &#8212; that is, eliminating multiprocessing altogether and just doing one thing at a time &#8212; are both impractical for performance and lead to deadlocks.)</p>
<p>Concurrency flaws can be found in testing pretty easily &#8212; run load/stress tests and check for discrepancies afterwards.  Usually something will show up. You can also add test hooks that encourage context changes to increase the likelihood of finding something.  Scott also promised to upload his own tool, SyncTest, <a href="http://www.isecpartners.com/tools.html">here </a>in the coming weeks.</p>
<p><a href="https://www.blackhat.com/html/bh-usa-08/bh-usa-08-speakers.html#Grossman">Jeremiah Grossman and Arian Evans</a> also presented &#8220;Making Money on the Web the Black Hat Way.&#8221;  This was all about business logic flaws, and the way they&#8217;ve been exploited to help underhanded people make tons of money without exploiting traditional &#8220;bugs&#8221; at all.  These included:</p>
<ol>
<li>Creating artificial scarcity in ticket sales for events via denial of service.  When you consider purchasing tickets, the site &#8220;reserves&#8221; them for a short time until you choose to purchase or not.  Since it costs nothing to reserve tickets for a few minutes&#8230; one person can reserve a <em>lot </em>of tickets.</li>
<li>Breaking CAPTCHAs for spammers.  Some have terribly flawed implementations (e.g. the correct answer in a hidden field, or the image name), while others can be recognized by OCR software.  Keep in mind that if OCR can read the CAPTCHA even 10% of the time, it&#8217;s &#8220;broken&#8221; &#8212; and it&#8217;s hard to make something that a computer can&#8217;t read even one time in ten that a <em>human </em>can still read.  Also, there&#8217;s the Mechanical Turk solution &#8212; disguise CAPTCHA-solving as a &#8220;game&#8221; (usually one with porn as a prize) or just pay people overseas to solve them at low rates.</li>
<li>Various overseas companies offer &#8220;password recovery&#8221; services, that will tell you &#8220;your&#8221; password for a small fee, usually $30-$150.  Basically, they just guess those horrible cognitive password questions (&#8220;What was your first car?  Who was your favorite teacher?&#8221;)</li>
<li>Coupon fraud.  Electronic coupons sometimes have predictable numbers, and some offers allow many coupons per order.  Some people have bought over $150,000 of stuff with these coupons.</li>
<li>Gaming micro-deposits.  When you set up an electronic transfer, the bank will sometimes send you a small deposit (less than $1), which you then tell them the amount of to verify account ownership.  Michael Largent opened <em>58,000 </em>brokerage accounts and collected these payments.  It&#8217;s not illegal under any normal financial law &#8212; the bank is sending you a gift.  However, he got charged under the USA PATRIOT Act for <em>using fake names </em>(58,000 of them.)  This is a really dubious charge (who uses a fake name on the Internet?  Oh, that&#8217;s right, <em>everybody</em>), but that&#8217;s par for the course in Federal law.</li>
<li>Application service provider bank robbery.  Small banks don&#8217;t really make and run their own web sites &#8212; they buy a standard &#8220;banking product&#8221; from an application service provider.  Some of these are <em>really, really bad </em>&#8211; the example one Grossman showed had no authorization.  Once you logged in as <em>a </em>user, you could transfer money to and from <em>any </em>user so long as you knew the right account numbers (which other bugs in the site were very helpful in providing to you.)  Crack an ASP, and you don&#8217;t just get to rob a bank, you get to rob <em>many </em>banks.</li>
<li>Slow order cancellation.  QVC, the popular shopping channel, was apparently not very good at canceling orders.  One woman started to order something, then canceled the order at the last step, and received the order anyway.  Finding this interesting, she tried it again.  And again, and again, until she&#8217;d received $412,000 in QVC merchandise and sold it on eBay.  According to law, if you are sent merchandise you did not order you&#8217;re entitled to keep it as a free gift.  She&#8217;d probably been able to keep doing it for years, too, if QVC hadn&#8217;t caught on because she sold the items on eBay <em>still in their QVC packaging</em>.  Ah, criminals are always so entertaining.</li>
<li>Affiliate scams.  People take advantage of affiliate offers in a host of ways.  The most common are cookie-stuffing methods &#8212; rather than getting people to click links to affiliate sites like they&#8217;re supposed to, sneaky affiliates will embed links to the affiliate sites (often dozens or hundreds of offers) in IMG or IFRAME tags.  Now whenever someone buys <em>anything</em> online the affiliate gets a check.  They avoid referrer fields with SSL pages (or META REFRESH, or several other techniques.)  Some get much more devious, with DNS rebinding, GIFAR, Flash malware, or other techniques.  However, the affiliate networks can catch all this, because people sent to affiliate sites by such scams convert at a much lower rate (nearly zero) than those who clicked through to the site on purpose.  This said, while people are caught constantly, apparently there is no evidence that anyone has ever been sued or charged over this sort of activity &#8212; it&#8217;s in a legal grey area where it&#8217;s not clear what, if anything, to charge them <em>with.</em></li>
<li>Trading on semi-public information.  BusinessWire (a popular place to post press releases for business) had a forceful browsing vulnerability &#8212; press releases that had been uploaded but not officially released were stored at publicly-accessible URLs and just not linked to the home page.  When someone found out, they started reading tomorrow&#8217;s news today and making stock trades on it.  They made $8 million.  A federal judge declared that they did not violate SEC regulations, because they had no insider privilege or fiduciary duty to the company &#8212; they were trading on nonpublic information, but no one who was forbidden to give it to them gave it to them.  They could still be prosecuted for hacking, maybe (is typing a URL directly to a page and not following a link trail &#8220;hacking&#8221;?). but that&#8217;s hard to prove if you&#8217;re remotely careful &#8212; usually we catch hackers by following the money to them, Al Capone style.  If the money is <em>legal, </em>and you have to catch them for the technical exploit, that&#8217;s <em>hard</em>.</li>
</ol>
<p>The moral of the story: business logic flaws are serious money, possibly much more than the syntax flaws we spend so much time worrying about.  Test everywhere, profile users, detect leaks and aberrant behavior.</p>
<p>The final presentation of the day that I attended was one by <a href="https://www.blackhat.com/html/bh-usa-08/bh-usa-08-speakers.html#Meer">Michael Slaviero and Haroon Meer</a> of SensePost on getting data out of protected networks.</p>
<p>Long ago, once someone compromised a machine, they could simply enable a shell on some port, then telnet in.  However, firewalls stopped that, so they began to do reverse tunneling with ssh and netcat (as well as more custom software like tcpr and fport.)  Outbound filtering stopped that, too, and so we got web shells &#8212; pieces of ASP/ASP.NET/PHP/whatever-the-web-server-runs code that could be uploaded into a webroot and would provide remote control facilities and file transfers.  However, there are now a host of mechanisms available for tunneling data out of a compromised machine.</p>
<p>For one, XP&#8217;s IPv6 support can be used as a port proxy.  The netsh command can set up a proxy such that one port on one (internet-accessible) machine is redirected to a different port on another (internal, behind the firewall) machine.  Thus, one compromised edge machine can provide direct network access to any machine it can reach on any port.  The ssh -L and -R can be used to similar effect on UNIX hosts.  This is a great reason for defense in depth &#8212; if an edge machine is owned, the firewall as a source of protection is largely eliminated.</p>
<p>There is also DNS2TCP.  If an attacker can get this onto a compromised machine, it allows full 2-way tunneling of arbitrary TCP over DNS &#8212; the one protocol that is allowed everywhere.  Once again, this bypasses the firewall.  SensePost also demonstrated their own app (glenn.jsp) which encoded TCP over well-formed HTTP POST via base64 encoding.  This is not just sending arbitrary traffic over port 80 (where an application-layer firewall will block it) &#8212; it&#8217;s true, valid HTTP requests against a real web page on the server, tunneling arbitrary TCP.</p>
<p>So with an edge web server under the attacker&#8217;s control, the firewall is bypassed in several ways, and your network is open to the attacker.  But what if the attacker uses SQL Injection to get in?  Then instead of a web server, they have a back-end SQL server with (hopefully) no access to the Internet, and thus no way to upload DNS2TCP or reach glenn.jsp.  Well, it turns out that there are other ways that operate only on SQL.</p>
<p>Squeeza is an advanced SQL Injection tool.  It separates content generation from return channel &#8212; you can have it return output via HTTP errors, via DNS tunneling (entirely in SQL!), or even via a blind timing channel (which is hideously slow &#8212; over a hundred milliseconds per <em>bit</em> &#8212; but works.)  You can send all sorts of content through it &#8212; profile the version of the server, use existing OLE objects on the server in the server&#8217;s context (such as to write a working portscanner entirely in SQL), or (in many cases) take control of the machine.</p>
<p>SQL Server 2005 was the first SDL-developed version of SQL Server, and was intended to be far more secure by default than previous versions of SQL Server (which had over 1,000 stored procs enabled by default.)  However, SQL Server is by its nature very hard to secure &#8212; it is very public, very capable, and highly targeted.  What&#8217;s more, new features sell while better security doesn&#8217;t &#8212; so while most things are disabled by default, SQL 2005 has more &#8220;things&#8221; than ever before.</p>
<p>The downfall of a compromised SQL Server is in-band signaling.  SQL Server&#8217;s configuration is controlled by stored procedures within SQL Server &#8212; so if you&#8217;ve gained sa access on a SQL Server, you can just turn all the disabled services back on.  This includes the dreaded xp_cmdshell stored procedure (which runs shell commands as the server.)  Using the new web service integration, you can write new SOAP endpoints entirely within SQL and place them on arbitrary ports &#8212; enable batch mode on those endpoints and they&#8217;ll allow running arbitrary SQL (thus getting you out of having to tunnel over DNS or use blind timing to get data out.)  And if you enable the CLR, you can run arbitrary .NET code in the server (subject to CAS restrictions &#8212; unless you&#8217;re running as sa, in which case there are no restrictions at all.)</p>
<p>There are several interesting ways to get your arbitrary .NET apps onto the server.  You can order the server to load them directly from a UNC path &#8212; if the server has outbound access to your server, which is unlikely.  However, you can write SQL that creates the assembly in memory from raw hex and loads it.  You leave no trace on the disk, and run arbitrary code.</p>
<p>All this talk really tells you from a defender&#8217;s perspective is the importance of defense in depth.  A compromise of either the web server or the database server essentially takes down the firewall from the attacker&#8217;s perspective &#8212; they can reach <em>anything</em> the server can, and can run port sweeps to find out what&#8217;s within reach.  Thus, it&#8217;s vital to do several things:</p>
<ol>
<li>Run the web server and database server with least privilege.  The attacker can&#8217;t get more access than the servers themselves have &#8212; both services should be running with only the minimal privilege required to perform their function.  Web servers should only have access to the web root &#8212; and most importantly, only <em>read</em> access.  Databases should never be accessed as sa &#8212; only as an account with execute access to needed stored procs and select access to needed tables.  Don&#8217;t let a database INSERT or UPDATE &#8212; use stored procs for that.</li>
<li>Segment your network securely.  The web server shouldn&#8217;t be able to hit any IPs or ports that it doesn&#8217;t actually <em>need</em> to hit to serve web pages.  Likewise with the database server.  Both inbound and outbound filtering is important.</li>
</ol>
<p>Overall, it was a great conference, and there was a lot of good information handed out.  I&#8217;ll be posting a recap of DefCon 16 over the next few days as well (once I have a chance to boil a notebook full of notes down to an intelligible post.)</p>
<p>a</p>
]]></content:encoded>
			<wfw:commentRss>http://perimetergrid.com/wp/2008/08/13/blackhat-2008-day-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>BlackHat 2008, Day 1</title>
		<link>http://perimetergrid.com/wp/2008/08/06/blackhat-2008-day-1/</link>
		<comments>http://perimetergrid.com/wp/2008/08/06/blackhat-2008-day-1/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 06:21:10 +0000</pubDate>
		<dc:creator>Grant Bugher</dc:creator>
				<category><![CDATA[SOA/XML]]></category>
		<category><![CDATA[attacks]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[industry]]></category>
		<category><![CDATA[mitigations]]></category>

		<guid isPermaLink="false">http://perimetergrid.com/wp/?p=63</guid>
		<description><![CDATA[Today was the first day of this year&#8217;s BlackHat Briefings in Las Vegas. The biggest security conference of the year, it&#8217;s always an interesting place to be and often involves the release of new and previously unknown exploits. The keynote speaker was Ian Angell, of the London School of Economics, who was speaking, ostensibly, about [...]<p>a</p>
]]></description>
			<content:encoded><![CDATA[<p>Today was the first day of this year&#8217;s <a href="http://www.blackhat.com/">BlackHat Briefings</a> in Las Vegas.  The biggest security conference of the year, it&#8217;s always an interesting place to be and often involves the release of new and previously unknown exploits.</p>
<p>The keynote speaker was <a href="http://www.blackhat.com/html/bh-usa-08/bh-usa-08-speakers.html#Angell">Ian Angell</a>, of the London School of Economics, who was speaking, ostensibly, about risk.  He is described as having &#8220;very radical and constructive&#8221; views on the subject.  His primary point was that when you put together a bunch of parts into a system, it often goes off the rails &#8212; every action leads not just to a reaction, but a loop wherein the unintended consequences feedback into themselves.  This makes control very difficult (he brought up Goodhart&#8217;s Law, &#8220;any observed statistical regularity will tend to collapse when pressure is placed on it for control purposes.)  The IT industry is obsessed with providing more information, but omnipresent computer screens distract and cause errors in judgment &#8212; people come to rely entirely on the system, suspending independent thought and just blindly following the machine, while simultaneously missing details in the information overload.</p>
<p>Humans are obsessed with categorization &#8212; the attempt to treat the similar as identical.  We deal with complexity by dropping less-significant relationships from our mental models &#8212; but those relationships still exist, and this creates uncertainty and risk.  Not just computer systems have this problem; bureaucracy is the most effective way to deal with <em>normal </em>situations, but as anyone who has dealt with one knows, it is terrible at dealing with anything out of the ordinary.</p>
<p>However, for all this, I found Professor Angell basically useless.  He&#8217;s comes across as very smart and amusing, but he points out problems without the slightest inkling of a solution.  Yes, systems create complexity, from which comes risk.  Shall we then abandon IT security in favor of a hunter-gatherer society?   I don&#8217;t think I could get an answer on that from him.</p>
<p>The next presentation was by <a href="http://www.blackhat.com/html/bh-usa-08/bh-usa-08-speakers.html#Dhanjani">Billy Rios and Nitesh Dhanjani</a> on the phishing culture and community.  They observed some phishing code and noticed common strings, and thought to do a Google search on them with the intent of finding other places that phishing code was in use.  Instead, they found thousands of credit card numbers, SSNs, and other identity information all over the Internet, in public forums, searchable on Google.  The phishers throw around identities constantly, just to prove their authenticity.  Meanwhile, they phish each other constantly &#8212; most of the phishing kits they found had back-doors in them or secret code to email a copy of all identities captured to their author.  They&#8217;re not hackers at all; they generally know just enough to upload a kit someone else wrote to a site someone else hacked and collect the information.  Also, ironically, the Google anti-malware blacklist turns out to be a fantastic way to find already-hacked sites to put phishing kits on &#8212; it&#8217;s full of Administrative logins and passwords.</p>
<p>This was followed by Dan Kaminsky&#8217;s DNS update, which I&#8217;m going to discuss in a separate post; for all its hype, I think it lived up to it.  Faulty DNS is a Really Bad Thing.</p>
<p><a href="http://www.blackhat.com/html/bh-usa-08/bh-usa-08-speakers.html#Dhanjani">Michael Ossmann</a> had a presentation to give on software radio and the future of wireless security.  Unfortunately, it was long on software radio and short on security.  He mostly spoke about the <a href="http://www.ettus.com/">USRP</a>, a piece of open-source hardware (also available pre-built for $700) that gives full software radio capabilities to a PC.  It can capture a significant amount of bandwidth in a range up into the 2.4 GHz band.  Ossmann&#8217;s demonstration of this involved doing packet-capture on Project 25 radios, and a replay attack on a remote-control toy.  Essentially, command-line tools can capture radio on most frequencies, and then (as it&#8217;s just a bitstream) DSP techniques can manipulate it arbitrarily.</p>
<p>While his speech had very little about security in it, the implications are significant in the long term.  Making a good radio means either using very expensive analog components, or using cheap analog components and a lot of CPU power.  In a few years, &#8220;a lot of CPU power&#8221; will be available on your phone, just given the rate at which CPUs improve.  Wireless (802.11) security didn&#8217;t become a big issue as soon as it was possible to crack WEP (i.e. almost instantly) &#8212; it became a big issue when wireless cards with raw packet injection and monitor mode started to be cheap and ubiquitous.  Wireless hacking takes a $700 USRP now; it&#8217;ll take a cell phone in 5 years (since as CPUs get more powerful, software radio gets cheaper than hardware, it&#8217;s only a matter of time until radios in phones and such are pure software, and thus reprogrammable.)  You can see the beginning of this in <a href="http://wiki.thc.org/gsm">THC&#8217;s GSM Project</a>.  If the cell phone network finds itself, security-wise, as badly off as 802.11 is today, it could be a frightening thing.<a href="http://www.blackhat.com/html/bh-usa-08/bh-usa-08-speakers.html#Stamos"></a></p>
<p><a href="http://www.blackhat.com/html/bh-usa-08/bh-usa-08-speakers.html#Stamos">Alex Stamos</a> and company from iSec Partners had a presentation on Rich Internet Application frameworks.  Rich Internet Applications aren&#8217;t well-defined, but they contain one or more of the following: AJAX UIs, local storage, an offline mode, running outside the browser, access to hardware resources, or the general appearance of a thick-client app.  Adobe, Microsoft, and others have created various apps and tools to help developers create these rich web apps.</p>
<p>Adobe AIR is the most full-featured of them &#8212; an AIR application runs in a full desktop runtime based on Flash.  There&#8217;s no sandboxing &#8212; a locally-installed AIR app has the full powers of the user, like an ActiveX control.  You can develop them in Flash, Flex, or JavaScript.  However, AIR apps can be launched from the web by ordinary Flash files (assuming the app is already installed on your computer.)  There is a remote mode, for running directly off the web with reduced privileges, but there&#8217;s a method for communicating and even passing objects between the local (full-trust) and remote modes.  Overall, it&#8217;s a scary thing, in the way that EXEs are scary (i.e. it&#8217;s insecure, but not any more insecure than everything else.)</p>
<p>Microsoft&#8217;s Silverlight is rather more restricted; it&#8217;s closer to Flash than to AIR.  Silverlight apps can be written in XAML with any .NET language, and use a scaled-down .NET runtime.  There is socket support, like Flash, but it is limited to certain sockets (4502-4534) and requires a policy file (clientaccesspolicy.xml) on the target server, even if the target server is the same site it came from.</p>
<p>Google Gears is even less functional than Flash and Silverlight; it&#8217;s essentially running HTML and JavaScript from the local machine.  There is local storage, and data sync with an API and SQLite for relational-database-like storage.  Also, it has the ability to run processes in a threadpool outside the browser, so as not to get shut down by the browsers&#8217; tight-loop detection.  Bizarrely, it allows the app author to customize the installation warning dialog, making it quite easy to convince people to install weird Gears apps.  It would be good for distributed malware, like cryptanalysis.</p>
<p>Yahoo! Browser Plus is designed to make it easy to write browser plugins, which is kind of like making it easy to make bombs.  There are some things that shouldn&#8217;t be easy, because the less of them, the better, and browser plugins (almost all of which seem to be adware/spyware) are one of them.  BrowserPlus add-ons are initialized by an HTTP call to Yahoo!, and run with full trust.  It&#8217;s like ActveX with a built-in Ruby interpreter (an old, buggy one, even.)</p>
<p>Finally, Mozilla Prism is a site-specific browser with the browser UI stripped off.  Formerly known as WebRunner, it&#8217;s used to &#8220;desktopize&#8221; web apps.  The risk here is comparitively low, though the script has XPCOM privileges (basically, control over the browser itself, like a Firefox extension would have.)</p>
<p>You can also just use HTML5 for some rich functionality, like local storage.  There is DOM storage, allowing you to persist up to 5MB of data locally, as well as SQLite-based database functionality.  DOM storage is essentially the ability to save immense cookies that are subject to SQL injection attacks.  The W3C has had better ideas.  Also, unlike cookies, you can&#8217;t easily turn DOM storage off (there&#8217;s a Firefox about:config setting, but nowhere in the UI.)  As mobile devices bundle Webkit browsers (like Safari), they&#8217;ll be subject to this type of storage &#8212; it would be pretty easy to DoS a mobile device by writing dozens of 5MB cookies.</p>
<p>So, what does all this lead to?  A host of new security issues we never had to think about before, of course!   The RIA data stores are vulnerable to XSS &#8212; if your email or other personal data is in an AIR or Gears app, and someone gets an XSS on the sites the apps come from, they can steal your entire data store.  You can have SQL injection against JavaScript now, thanks to SQLite databases.  The same Flash-based XSS attacks we&#8217;ve seen now work on Silverlight and AIR as well.</p>
<p>On the bright side, they had some good prescriptive guidance for app developers:</p>
<ol>
<li>Don&#8217;t use predictably-named data stores</li>
<li>Parameterize SQL, even on local SQLite stores</li>
<li>Domain-lock sites if possible</li>
<li>Don&#8217;t use AIR when Flash/Flex/Silverlight/etc. will do fine</li>
<li>Let users opt out of RIA functionality</li>
</ol>
<p>Finally, <a href="http://www.blackhat.com/html/bh-usa-08/bh-usa-08-speakers.html#Miller">Ty Miller</a> had some shellcode to show us &#8212; reverse DNS tunnelling staged-loading shellcode, in fact.  The trend in vulnerabilities has been toward client-side exploits of late, now that socket-based servers have been hardened significantly.  However, if you do buffer-overflow a client app and get it to execute shellcode, the challenge is often getting a connection back to the attacker.  Clients are often behind firewalls, proxies, NATs, or all three.</p>
<p>Of the common shellcode techniques (port binding, callback, find-socket, address reuse, download &amp; execute, and HTTP tunneling), only one (HTTP tunneling) works reliably with client apps &#8212; and Metasploit&#8217;s HTTP tunneling shellcode only works on IE6 with ActiveX enabled.  DNS tunneling (like Kaminsky&#8217;s OzymanDNS from 2004) would also get back &#8212; and even more reliably than HTTP, since it wouldn&#8217;t need to worry about authenticated proxies.</p>
<p>DNS gets through everything.  When you make a DNS request, it goes to your company or ISP&#8217;s DNS server, which forwards it on to a top-level server (like .com) and then to the DNS server that owns the domain name.  Practically everything makes DNS lookups (as Dan Kaminsky went into today), and nothing works if they&#8217;re blocked, so any computer is all but guaranteed to have DNS access.  With a malicious DNS server, you can actually tunnel arbitrary data through DNS.</p>
<p>Miller&#8217;s shellcode consisted of a tiny first stage which finds kernel32, creates pipes for STDIN and STDOUT, then makes an nslookup (yes, it shells out to nslookup) for a TXT record on the malicious DNS server.  The TXT record type can be extremely long, and the record it gets back contains the second-stage shellcode and a command to run.  The second stage shellcode runs the command, captures the output, and sends it back in fragmented DNS requests.  It then polls periodically for more commands to run.  The DNS requests all have a sequence number in them, guaranteeing that they don&#8217;t get cached and always get through.</p>
<p>He&#8217;s making his code available at <a href="http://projectshellcode.com">projectshellcode.com</a>, a site where he hopes to focus shellcode research and start a collection.  I think this is of dubious value (unlike exploits, shellcode is not really very useful to security folks on the &#8220;good guys&#8217;&#8221; side most of the time), but it&#8217;ll be interesting to take a look at what he&#8217;s come up with.</p>
<p>a</p>
]]></content:encoded>
			<wfw:commentRss>http://perimetergrid.com/wp/2008/08/06/blackhat-2008-day-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The DNS Exploit Revealed&#8230; and used</title>
		<link>http://perimetergrid.com/wp/2008/07/29/the-dns-exploit-revealed-and-used/</link>
		<comments>http://perimetergrid.com/wp/2008/07/29/the-dns-exploit-revealed-and-used/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 07:30:03 +0000</pubDate>
		<dc:creator>Grant Bugher</dc:creator>
				<category><![CDATA[attacks]]></category>
		<category><![CDATA[mitigations]]></category>

		<guid isPermaLink="false">http://perimetergrid.com/wp/?p=58</guid>
		<description><![CDATA[So, Dan Kaminsky&#8217;s DNS exploit I previously mentioned has been revealed. It turns out that what Kaminsky found was pretty much what I speculated &#8212; he just had it put together into a coherent attack, and fully recognized the implications. If I want to poison your DNS server, say, to redirect www.yourbank.com to my malicious [...]<p>a</p>
]]></description>
			<content:encoded><![CDATA[<p>So, <a href="http://perimetergrid.com/wp/2008/07/17/the-mysterious-dns-exploit/">Dan Kaminsky&#8217;s DNS exploit</a> I previously mentioned has been revealed.  It turns out that what Kaminsky found was pretty much what I speculated &#8212; he just had it put together into a coherent attack, and fully recognized the implications.</p>
<p>If I want to poison your DNS server, say, to redirect www.yourbank.com to my malicious web server, I can make a DNS request to it and ask for www.yourbank.com.  Your DNS server either already knows the address (because it&#8217;s in the cache), or it sends a request to yourbank.com (the top-level DNS name for www.yourbank.com) asking where to find it.  This request has a random sequence number, called the XID, from 0 to 65,535 on it, and the reply needs to match that number to be accepted.</p>
<p>However, DNS works through UDP, which is spoofable.  That is, the way you know where a UDP packet came from is&#8230; to take its word for it.  UDP packets have a sender address attached.  So I can request www.yourbank.com from your DNS server, then send a reply claiming to be &#8220;from&#8221; yourbank.com answering the request and pointing to my malicious web server.  The only thing stopping me is the XID &#8212; I have to guess which XID your DNS server used, since I didn&#8217;t get to see the request packet.  Ten years ago, there were ways to predict XIDs, but that&#8217;s all fixed now.  So all I can do is flood you with hundreds of replies with different XIDs, and hope I guess the right XID before the real reply arrives.  Once the real one arrives, it goes into the cache, and I can&#8217;t ask for www.yourbank.com anymore (well, I can ask, but the server won&#8217;t do the lookup &#8212; it already knows where the site is.)  So it&#8217;s a race &#8212; can I guess the XID faster than the real DNS server can respond?  Since I only get to try once, it&#8217;s a race that, as the attacker, I will almost always lose.</p>
<p>A bit about DNS replies &#8212; they can contain multiple bits of information.  This is to cut down on requests, because sometimes one server has many names.  For instance, if I request &#8220;login.yourbank.com&#8221;, the DNS can reply with a packet that essentially says &#8220;login.yourbank.com is actually www.yourbank.com, and by the way, www.yourbank.com is 1.2.3.4&#8243;.  I can&#8217;t, however, do this with a totally different domain &#8212; I can&#8217;t say, for instance, &#8220;www.evilsite.com is actually www.google.com, and www.google.com is 6.6.6.6&#8243;, because the DNS server wasn&#8217;t <em>asking </em>about Google, so it&#8217;s not interested in hearing my DNS server&#8217;s speculation about where it is.  This defense is somewhat whimsically called &#8220;baliwick checking.&#8221;</p>
<p>Here&#8217;s Kaminsky&#8217;s exploit: if I query your DNS server about an <em>invalid subdomain</em>, and provide in my spoofed responses a reference to something else in the same subdomain, then I can attempt to poison your DNS cache all day long, until I get it right.  Say I can get 100 spoofed replies in before a real reply.  Now I don&#8217;t query for www.yourbank.com &#8212; I query for 00001.yourbank.com, which does not exist.  I spoof replies that say &#8220;00001.yourbank.com is actually www.yourbank.com, and by the way, www.yourbank.com is 6.6.6.6&#8243;.  If that doesn&#8217;t work within half a second, then I&#8217;ve failed.  And since I&#8217;ve got time for 100 replies, and only a 1 in 65,535 chance of any of them being right, I probably fail &#8212; the odds are only 1 in 655 that I&#8217;ll succeed.  So&#8230; I just try again 654 more times, with 00002.yourbank.com, and so on.  Since I&#8217;m rotating subdomains, I never run into the case where it&#8217;s already cached and I can&#8217;t force a lookup.</p>
<p>It sounds so simple &#8212; because it is.  It&#8217;s by-design behavior of DNS.  It&#8217;s exactly how DNS has worked for 20 years.  And it&#8217;s completely devastating.  Armed with this knowledge and a DNS server you control (which you can set up in minutes on any Linux box), you can reroute any vulnerable DNS server on the Internet, forcing all customers who use that server to your malicious sites.  According to Kaminsky, 52% of DNS servers are still vulnerable.</p>
<p>There&#8217;s already a <a href="http://www.metasploit.org">Metasploit</a> plugin (called Baliwicked) for both the malicious DNS server and the attack client.  You&#8217;ll need to sync them from the live tree if you want them, as they&#8217;re not in the main Metasploit package yet.  However, it gets worse &#8212; today, a new Metasploit plugin called <a href="http://www.infobyte.com.ar/developments.html">Evilgrade</a> was released which uses this ingeniously.  Evilgrade uses the Baliwicked exploit to remap DNS for the sites used by the auto-update functionality in eight popular software packages (Sun Java, WinZip, WinAmp, Mac OS X, OpenOffice, iTunes, the LinkedIn Toolbar, Download Accelerator, notepad++, and speedbit) to a malicious web site (itself.)  What do those auto-updaters have in common?  They all call home, look for updates, and if they find them, <em>download and install whatever&#8217;s there without checking to see if it&#8217;s real</em>.  With the DNS being redirected, this means they download arbitrary Trojan horse code from the malicious site and install it, telling the user it&#8217;s a &#8220;critical update&#8221; to their software.</p>
<p>You might notice that no Microsoft software is on the list.  This is because Microsoft&#8217;s updater technologies are all based on Windows Update, which checks a digital signature on downloaded updates before running it.  Since an attacker can&#8217;t spoof the signature without Microsoft&#8217;s private keys (which are very closely guarded), the MS auto-update is useless for this sort of attack.</p>
<p>Unfortunately, as an end user, there&#8217;s very little you can do to protect yourself from this sort of attack.  Your ISP needs to update their DNS server &#8212; most have, at this point, but only a bare majority; many, many sites and ISPs are still vulnerable.  Any HTTP site can be spoofed right now &#8212; only HTTPS sites are safe (and even those only if you check the certificate and don&#8217;t access sites with SSL errors.)  And auto-updaters could be installing any number of things &#8212; Evilgrade is particularly bad because you don&#8217;t have to pick a site you know the victim will go to to spoof, because the auto-updaters will go to their home sites automatically, whether the user wants to or not.  If you use any of the products spoofed by Evilgrade, it would probably be a good idea to turn off auto-update for a few weeks.</p>
<p>The lesson here is that the security community needs to <em>stop trusting DNS </em>&#8211; it is not a security technology, it never was, and it is not designed to be reliable.  However, old habits die hard, especially when there is no viable substitute for many scenarios right now.</p>
<p>a</p>
]]></content:encoded>
			<wfw:commentRss>http://perimetergrid.com/wp/2008/07/29/the-dns-exploit-revealed-and-used/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Mysterious DNS Exploit</title>
		<link>http://perimetergrid.com/wp/2008/07/17/the-mysterious-dns-exploit/</link>
		<comments>http://perimetergrid.com/wp/2008/07/17/the-mysterious-dns-exploit/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 04:16:56 +0000</pubDate>
		<dc:creator>Grant Bugher</dc:creator>
				<category><![CDATA[attacks]]></category>
		<category><![CDATA[mitigations]]></category>

		<guid isPermaLink="false">http://perimetergrid.com/wp/?p=52</guid>
		<description><![CDATA[On Tuesday, July 8th, Microsoft&#8217;s usual package of patches seemed to end-users like every other Patch Tuesday &#8212; some security updates to various and sundry Windows files to patch security vulnerabilities unknown.  However, it contained something very unusual this time &#8212; a design change to DNS. DNS has been around since the 1970&#8242;s, so people [...]<p>a</p>
]]></description>
			<content:encoded><![CDATA[<p>On Tuesday, July 8th, Microsoft&#8217;s usual package of patches seemed to end-users like every other Patch Tuesday &#8212; some security updates to various and sundry Windows files to patch security vulnerabilities unknown.  However, it contained something very unusual this time &#8212; a design change to DNS.</p>
<p>DNS has been around since the 1970&#8242;s, so people don&#8217;t expect it to change much.  And this wasn&#8217;t an ordinary patch, fixing a bug in the code where it was behaving in an unintended fashion.  In this case, <a href="http://www.doxpara.com/">Dan Kaminsky </a>found something potentially extremely serious in the <em>designed behavior </em>of DNS and reported it to all the major DNS vendors.  As a result, it wasn&#8217;t just Microsoft that released a patch, but also Apple, Cisco, and the <a href="http://www.isc.org/index.pl?/sw/bind/index.php">Internet Systems Consortium</a> (makers of BIND, the primary DNS daemon of the UNIX world.)</p>
<p>Dan did this in secret, to prevent people from exploiting the bug.  This led to <a href="http://www.matasano.com/log/1089/dan-kaminsky-could-have-made-hundreds-of-thousands-of-dollars-with-this-dns-flaw/#comments">a lot of skepticism</a> about whether it was a &#8220;real&#8221; vulnerability, or just Kaminsky (a ubiquitous figure in the security press and an amusing character by anyone&#8217;s measure) engaging in self-promotion by pointing out something already well-known.</p>
<p>If the linked blog post seems confusing, what he is implying is that all Kaminsky &#8220;found&#8221; was the fact that the DNS sequence number, used to match DNS replies with queries, is extremely short, such that if you can send 65,535 spoofed replies to a DNS server before the real server manages to reply, you can poison the cache.  While this is true, and a problem, it&#8217;s been known for a decade and is not interesting.  It&#8217;s exploitable in another way, too &#8212; you could ensure your forged response gets in first by forcing a user to make many queries (e.g. by giving him a web page with tens of thousands of embedded images) with while you spoofed a flood of responses with constant sequence numbers.  If you attached CNAMEs to all of those, and put the images on subdomains of the target (e.g. 1.google.com, 2.google.com, 3.google.com, etc.), you could potentially clobber the DNS record for a top-level domain on the end-user&#8217;s server.</p>
<p>The end result of which would be that if a user visits your malicious web site, you change the IP that, say, google.com goes to for everyone using that DNS server.</p>
<p>However, bad as all that sounds, it seems that Kaminsky found something even worse.  All of the skeptics of his discovery who have been let in on the secret have <a href="http://www.matasano.com/log/1093/patch-your-non-djbdns-server-now-dan-was-right-i-was-wrong/">come</a> <a href="http://blog.trailofbits.com/2008/07/09/dan-kaminsky-disqualified-from-most-overhyped-bug-pwnie/">around</a> to his side, and all the DNS vendors issued a design-change patch.  Among other things, this patch broke ZoneAlarm &#8212; everyone running ZoneAlarm found themselves suddenly unable to use the Internet at all.  (At least, so it appeared &#8212; my guess is that they were actually just unable to make DNS queries, but to a normal non-tech-savvy user this amounts to a total loss of Internet.)</p>
<p>So, what is this exciting new DNS vulnerability?  Right now, heaven only knows (well, and Dan.)  But Kaminsky has promised to tell us all about it at BlackHat 2008, and I&#8217;ll certainly be there to post the results here.  For now&#8230; patch your DNS servers.  The only hint we have right now is that source port randomization (one of the mitigations in the DJBDNS secure DNS package) would have stopped it.</p>
<p>a</p>
]]></content:encoded>
			<wfw:commentRss>http://perimetergrid.com/wp/2008/07/17/the-mysterious-dns-exploit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Blacklists and Cross-Site Scripting</title>
		<link>http://perimetergrid.com/wp/2008/04/08/blacklists-and-cross-site-scripting/</link>
		<comments>http://perimetergrid.com/wp/2008/04/08/blacklists-and-cross-site-scripting/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 17:41:01 +0000</pubDate>
		<dc:creator>Grant Bugher</dc:creator>
				<category><![CDATA[attacks]]></category>
		<category><![CDATA[mitigations]]></category>

		<guid isPermaLink="false">http://perimetergrid.com/wp/?p=44</guid>
		<description><![CDATA[Microsoft gets a lot of criticism over Internet Explorer not being &#8220;standards-compliant.&#8221; However, it&#8217;s actually not so simple, for a variety of reasons. One of them is that the web itself is not very standards-compliant &#8212; while IE8 has a standards-compliant-browser mode, it has to offer an IE7 rendering fallback mode because most web sites [...]<p>a</p>
]]></description>
			<content:encoded><![CDATA[<p>Microsoft gets a lot of criticism over Internet Explorer not being &#8220;standards-compliant.&#8221;  However, it&#8217;s actually not so simple, for a variety of reasons.  One of them is that the web itself is not very standards-compliant &#8212; while IE8 has a standards-compliant-browser mode, it has to offer an IE7 rendering fallback mode because most web sites don&#8217;t render properly if you strictly interpret XHTML.  (Opera and Firefox violate the standards in the same way for the same reason.)</p>
<p>However, another is that sometimes doing things the &#8220;right&#8221; way can be bad for security.  To prevent cross-site scripting attacks, many websites implement a blacklist &#8212; they search for specific &#8220;bad&#8221; data and refuse to show it.  Others are behind a protective appliance that filters out &#8220;bad&#8221; data and eliminates it before it even reaches the web server.  This is not the proper way to do this &#8212; you should allow a whitelist of good data, not look for badness, which comes in many forms &#8212; but it is nevertheless common.  This process will, however, filter out obvious attacks, like a user putting this into a message post:</p>
<p style="codeblock">&lt;script&gt;alert(&#8220;This is some script!&#8221;);&lt;/script&gt;</p>
<p>However, it&#8217;s not so likely to catch, say, this:</p>
<p style="codeblock">¼óãòéðô¾áìåòô¨¢Ôèéó éó óïíå ïâæõóãáôåä óãòéðô¡¢©»¼¯óãòéðô¾</p>
<p>So, what the heck is that?  Actually, it&#8217;s the same script in 7-bit ASCII, but the high-order bit of each byte is set, making it a different character.  If you were running a blacklist checking for, say, &lt;script&gt; tags, this would sail right through.  Likewise, a filtering appliance will not see anything wrong with this.</p>
<p>However, if this is displayed on a web page with the encoding set to US-ASCII, (e.g. a page with &lt;meta http-equiv=content-type content=&#8217;text/html; charset=us-ascii&#8217;&gt; on it, which an attacker may also be able to inject given the right circumstances) Internet Explorer will render it properly, causing the script to execute!  Other browsers, however, will be safe due to their non-standards-compliance.  They don&#8217;t render 7-bit ASCII properly, instead taking the presence of an 8th bit to indicate that you really &#8220;meant&#8221; UTF-8, and thus show only the gibberish characters above.</p>
<p>Standards compliance is not an unalloyed good &#8212; the standards are documents on paper, and don&#8217;t always consider their own security implications.  They were written to tell people how to do things, not how <em>not</em> to do them.  Real browser behavior is based on a combination of standards and precedent.  There are few real-world reasons why rendering US-ASCII as US-ASCII and not ISO-8859-1 is important &#8212; on non-malicious pages, you should get basically the same output.  However, trying to do the &#8220;right&#8221; thing can open up a security vulnerability.  Due to this and the compatibility issues, I think that Microsoft&#8217;s attempt to make IE8 the first standards-compliant browser is not actually going to work out &#8212; my guess is that when it comes time to release it, they&#8217;ll make the IE7-like rendering mode the default, with standards-compliant mode only an option.</p>
<p>So, as a web developer, how can you defend against attacks like the above?  You could look for &#8220;&lt;script&gt;&#8221; encoded in US-ASCII, but there are dozens of other encodings out there, and as <a href="http://ha.ckers.org/xss.html">RSnake&#8217;s XSS Cheat-Sheet</a> shows, there are dozens of bad things you can encode in them.  What you instead have to do is use regular expressions to allow only a limited subset of <em>good</em> user input.  For fields like ZIP code, this is easy (allow numbers only, and the &#8211; character if you want ZIP+4), but with general message posts, it can be harder.  Letters, numbers, common punctuation marks, spaces, and carriage returns may be enough.  If you need to use HTML tags, it&#8217;s best to go in multiple passes &#8212; match the tags you want to allow (like bold and italics) and replace them with a custom marker, then HTML Encode the entire message, and then finally replace the custom markers with allowed (unencoded) tags.  It&#8217;s still not 100% effective in all cases, but it&#8217;s a lot safer than any blacklist can be.</p>
<p>a</p>
]]></content:encoded>
			<wfw:commentRss>http://perimetergrid.com/wp/2008/04/08/blacklists-and-cross-site-scripting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Whole-Disk Encryption Cracked</title>
		<link>http://perimetergrid.com/wp/2008/02/28/whole-disk-encryption-cracked/</link>
		<comments>http://perimetergrid.com/wp/2008/02/28/whole-disk-encryption-cracked/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 18:19:10 +0000</pubDate>
		<dc:creator>Grant Bugher</dc:creator>
				<category><![CDATA[attacks]]></category>
		<category><![CDATA[crypto]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[mitigations]]></category>
		<category><![CDATA[physical security]]></category>
		<category><![CDATA[products]]></category>

		<guid isPermaLink="false">http://perimetergrid.com/wp/2008/02/28/whole-disk-encryption-cracked/</guid>
		<description><![CDATA[Early this week, some researchers at Princeton University&#8217;s Center for Information Technology Policy released a fascinating video of whole-disk encryption being cracked quite quickly and easily. Whole-disk encryption products &#8212; such as PGP Whole Disk Encryption, TrueCrypt System Encryption, and Windows Vista&#8217;s BitLocker &#8212; work by encrypting the entire hard disk with a symmetric key, [...]<p>a</p>
]]></description>
			<content:encoded><![CDATA[<p>Early this week, some researchers at Princeton University&#8217;s Center for Information Technology Policy released a <a href="http://citp.princeton.edu/memory/">fascinating video</a> of whole-disk encryption being cracked quite quickly and easily.</p>
<p>Whole-disk encryption products &#8212; such as <a href="http://www.pgp.com/products/wholediskencryption/">PGP Whole Disk Encryption</a>, <a href="http://www.truecrypt.org/docs/?s=system-encryption">TrueCrypt System Encryption</a>, and <a href="http://www.microsoft.com/windows/products/windowsvista/features/details/bitlocker.mspx">Windows Vista&#8217;s BitLocker</a> &#8212; work by encrypting the entire hard disk with a symmetric key, save for a small loader.  When the computer is powered on, the loader prompts the user for a password or other authenticator (like a smart card or a certificate on a USB keyfob), which is used to decrypt the key.  Assuming the correct authenticator is provided, the key is decrypted and then the OS is booted from the encrypted drive.  The key remains in memory until the machine is powered off, since continuous access to the key is required to access the drive.</p>
<p>The purpose of whole-disk encryption is to protect against an attacker bypassing all of the operating system&#8217;s defenses (logins &amp; passwords, filesystem ACLs, etc.) by simply pulling out the hard disk and putting it in another computer (or, equivalently, booting up a LiveCD on the system) such that the operating system isn&#8217;t loaded at all.  Instead, the drive is mounted into an OS the attacker controls, where he has the ability to change ACLs, bypass logins, etc.  With whole-disk encryption, you can&#8217;t do this &#8212; even if you steal a laptop, without the boot password the entire drive contains nothing but a useless encrypted bitstream.</p>
<p>(As a side note, Vista BitLocker has a mode in which the symmetric key is stored in the TPM of the laptop, so no boot password is required.  At first this seems useless &#8212; why encrypt if decryption is automatic? &#8212; but it does provide protection against simply stealing the hard disk or booting into another OS.  The OS being booted must be in that specific computer, as only it has the TPM, and must be BitLocker-aware and capable of getting the key from the TPM.  It&#8217;s not completely secure in the stolen-laptop scenario, but neither is it useless.)</p>
<p>The Princeton group&#8217;s attack on whole-disk encryption relies on a little-known fact &#8212; computer memory (DRAM) is not wiped out when the system is powered off.  Rather, it becomes unreliable, decaying over a period of seconds to minutes as it gets randomized bit by bit.  It turns out that if cooled to a very low temperature, this decay is slowed considerably, to the point of being stable for tens of minutes.  Thus, the attack is as follows: get access to a laptop that is <em>currently operating </em>(so that the whole-disk encryption key is in memory), spray the RAM with an inverted compressed air can to cool it to -50 degrees Celsius, and power the system off.  Either move the RAM to a system with a custom OS, or attach an external drive to the system and boot off that.  The custom OS boots with a minimal memory footprint and then copies everything from RAM to a file on disk.  Thus, in less than a minute a &#8220;snapshot&#8221; of RAM has been taken.  This snapshot can then be inspected to locate prospective cryptographic keys and try them on the target drive.  Some knowledge of the particular whole-disk encryption product being used would be needed to find the exact spot in memory where the key is, and some error-correction techniques must be used in case a bit or two has been flipped, but it reduces the problem from cryptographically impossible to something that can be cracked in a few minutes or at worst hours.</p>
<p>So is this the end of whole-disk encryption?  No, not at all.  First of all, whole-disk encryption still successfully protects computers that are powered off (or in hibernation) &#8212; in that state, the computer does not have a copy of the encryption key available to it until the user re-enters his password.  In most stolen-laptop scenarios, the computer isn&#8217;t running at the time!  Whole-disk encryption is still a critical mitigation in the case of portable computers containing confidential data, and enterprises and government agencies would do well to implement it.  Of course, the best mitigation for this is to <em>not carry confidential data around on your laptop</em>.  It always strikes me as absurd when some government employee loses millions of confidential records on a stolen laptop &#8212; why did they need to have millions of records to carry around with them?  Do they really need all of those on-the-go?  It&#8217;s possible that in a minority of cases they do, and in those cases encryption is imperative (either of the whole-disk variety or on the file), but in most cases they&#8217;d have been better off leaving those files at the office.</p>
<p>Second, this is only a concern in <em>targeted attacks</em>.  If a typical thief rips off your laptop and discovers whole-disk encryption in place, they&#8217;re not going to execute this attack and get at your data.  Instead, they&#8217;ll just reformat the hard drive and sell the laptop as hardware.  The only reason someone would carry out this attack is if they knew that your laptop in particular contained valuable data and thus set out to steal it specifically.  In other words, if you&#8217;re a <em>spy</em>, and your laptop is classified TOP SECRET UMBRA, you have to worry about this attack.  If you have a typical corporate desktop and aren&#8217;t widely known to carry around your company&#8217;s entire credit card database, whole-disk encryption will probably protect you just fine.</p>
<p>There are several things that can be done, both by end-users and whole-disk encryption vendors, to mitigate this attack.  For end-users:</p>
<ul>
<li>If using Vista BitLocker, do not use the automatic mode &#8212; choose a mode that requires the use of a USB keyfob or a password to unlock.  This makes this attack ineffective when the system is entirely powered off.</li>
<li>Do not use sleep/suspend-to-RAM when the computer is not actually in your hands &#8212; either power off or use hibernate.  In a sleep or suspend-to-RAM scenario, the whole-disk encryption key is still maintained in memory and can be recovered.</li>
<li>If you have a few truly critical files, use file encryption (such as Windows&#8217;s Encrypted File System or PGP&#8217;s file encryption) on those files with a different password than that used on the whole-disk encryption.</li>
</ul>
<p>For makers of whole-disk encryption software:</p>
<ul>
<li>Provide an option to re-encrypt the symmetric key during sleep or screen-saver activity.  This would mean the the laptop would need to be stolen during a truly active state; however, it would also inconvenience the user with more frequent password prompts.</li>
<li>Consider the cryptographic key expansion mitigation described in the <a href="http://citp.princeton.edu.nyud.net/pub/coldboot.pdf">Princeton research paper</a>.  It vastly increases the chances of even a small amount of decay of memory rendering the key unrecoverable.  Of course, it does so at the cost of performance (by requiring an additional hashing and XOR operation every time the key must be used.)</li>
</ul>
<p>a</p>
]]></content:encoded>
			<wfw:commentRss>http://perimetergrid.com/wp/2008/02/28/whole-disk-encryption-cracked/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASUS Eee PC and Linux vmsplice Vulnerabilities</title>
		<link>http://perimetergrid.com/wp/2008/02/11/asus-eee-pc-and-linux-vmsplice-vulnerabilities/</link>
		<comments>http://perimetergrid.com/wp/2008/02/11/asus-eee-pc-and-linux-vmsplice-vulnerabilities/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 05:32:27 +0000</pubDate>
		<dc:creator>Grant Bugher</dc:creator>
				<category><![CDATA[attacks]]></category>
		<category><![CDATA[mitigations]]></category>
		<category><![CDATA[products]]></category>

		<guid isPermaLink="false">http://perimetergrid.com/wp/2008/02/11/asus-eee-pc-and-linux-vmsplice-vulnerabilities/</guid>
		<description><![CDATA[It wasn&#8217;t a good weekend for Linux. The ultraportable ASUS Eee PC has seen quite a bit of publicity lately. With prices starting as low as $300, it&#8217;s about as cheap as laptops get, and runs on a solid-state drive instead of a hard disk. Of course, to get such a low price, it doesn&#8217;t [...]<p>a</p>
]]></description>
			<content:encoded><![CDATA[<p>It wasn&#8217;t a good weekend for Linux.</p>
<p>The ultraportable <a href="http://usa.asus.com/products.aspx?l1=24&amp;l2=0&amp;l3=0&amp;l4=0&amp;model=2005&amp;modelmenu=1">ASUS Eee PC</a> has seen quite a bit of publicity lately.  With prices starting as low as $300, it&#8217;s about as cheap as laptops get, and runs on a solid-state drive instead of a hard disk.  Of course, to get such a low price, it doesn&#8217;t ship with Windows on it &#8212; instead, it has a customized version of Xandros Linux using IceWM with a host of open-source applications, like OpenOffice, Firefox, etc.  Xandros is a Debian derivative, so the apt package system can be used to get almost any popular Linux application.</p>
<p>Linux gets a lot of good press for being &#8220;secure&#8221;, by which the media usually means &#8220;free from viruses and spyware.&#8221;  This is pretty much true, for the simple reason that it&#8217;s not worth anyone&#8217;s time to write a virus for Linux when the market share is so low.  However, there&#8217;s a big difference between &#8220;free of malware&#8221; and &#8220;secure by default.&#8221;  It turns out that the Xandros Linux on the Eee ships with Samba 3.0.24, which dates back to February &#8217;07.  (Samba is the Linux version of the SMB protocol &#8212; it&#8217;s the package that lets Linux machines participate in Windows networks, both to be able to connect to Windows fileshares &amp; to share files themselves.)  Samba is, of course, installed and on by default &#8212; it wouldn&#8217;t be &#8220;easy to use&#8221; if you had to manually start Samba, would it?</p>
<p>Samba 3.0.24, unsurprisingly considering its age, has known critical security flaws.  One of these is a remote root exploit published by RISE Security; the result of this is that <a href="http://www.risesecurity.org/blog/entry/6/">any Eee PC can be remotely and silently compromised with a simple Metasploit plugin</a>.  If you&#8217;re on the Internet with an Eee, anyone can take remote control of your computer, access and change files, etc.  You don&#8217;t need viruses and spyware when you have direct control.</p>
<p>If you do have an Eee, I suggest using apt to update Samba immediately.  Assuming the Eee works like every other Debian derivative out there, a simple &#8220;sudo apt-get upgrade samba&#8221; ought to take care of the problem.</p>
<p>However, it gets worse.  That vulnerability only affects people running an old version of Samba &#8212; it only gets attention because a brand-new PC is shipping with said old version of Samba.  Also this last weekend, <a href="http://www.milw0rm.com/">milw0rm</a> released a <a href="http://www.milw0rm.com/exploits/5092">local root exploit for all Linux kernels</a> 2.6.17 through 2.6.24.1 (the current kernel.)  This affects basically every Linux 2.6 system out there, as it affects kernels from June &#8217;06 through today.  Since upgrading a kernel is somewhat of an ordeal (it requires taking the system down at the very least, and on many flavors of Linux involves some work besides; Ubuntu makes it quite easy if you&#8217;re using the default kernel, though), it&#8217;ll be months before many of these machines are upgraded.</p>
<p>It&#8217;s a local root exploit, so you have to be logged onto the machine to use it.  Obviously, for Linux-based desktops and laptops that isn&#8217;t much of a concern; if someone&#8217;s sitting at your computer, they can take it over no matter what you do.  However, where this gets scary is shared web hosting.  Most small web sites are on shared servers; many (even hundreds) of sites on the same box.  What&#8217;s more, a web hosting company may have all of their various servers trusting each other in such a way that having root on any one means having full control of <em>all </em>of them.</p>
<p>If you have a shell account on a Linux 2.6 box, full control is now as easy as pasting <a href="http://www.milw0rm.com/exploits/5092">this code </a>into a file on the machine, and typing</p>
<p class="codeblock">cc -static -Wno-format vmsplice-exploit.c<br />
./a.out</p>
<p>Presto!  Root shell.  Most web hosts don&#8217;t give you shell anymore (unfortunate, in my opinion, and the main reason I&#8217;m on <a href="http://www.dreamhost.com">DreamHost</a>), but that doesn&#8217;t matter &#8212; you could upload the source via FTP, along with a simple PHP page that builds it, runs it, and has it send you a shell.  There are a <em>lot </em>of hosts on the Internet vulnerable to this right now.  (Interestingly, DreamHost is not, as its servers are using the Linux 2.4 kernel instead of the 2.6 branch, and thus lack support for vmsplice.)</p>
<p>Unfortunately, I don&#8217;t have enough Linux kernel experience to know exactly what this exploit <em>does </em>to discuss it further &#8212; I&#8217;ve only done kernel-mode work on Windows, with my Linux coding being strictly in userland.  However, vmsplice provides user-mode code with control over a kernel buffer, so any number of tiny bugs could have resulted in a catastrophic compromise (like this one.)  Linux Torvalds has <a href="http://marc.info/?l=linux-kernel&amp;m=114547247100565&amp;w=2">an email about splice() here</a>, which does a great job explaining how splice() and vmsplice() can be used to move data around in a copy-free manner through a kernel buffer, but nothing much about <em>why </em>you would do such a thing.</p>
<p>So what to do about this one?  There are three choices:</p>
<ol>
<li>If you&#8217;re running a Linux 2.4 kernel, or anything predating 2.6.17, you&#8217;re safe.  Well, you&#8217;re safe from <em>this</em>; there are other security bugs in year-old kernels.</li>
<li>Upgrade to a kernel post-2.6.24.1.  If you happen to run a cutting-edge distribution like Gentoo, you can just sync the tree today, rebuild the kernel, and be good to go.  And if you&#8217;re running Gentoo, you actually know how to do that.  Debian Stable also has an apt package with a 2.6.18.dfsg.1-18etch1 kernel that&#8217;s safe.</li>
<li>There are some workarounds (hacks, really) on <a href="http://www.groupsrv.com/linux/about141039.html">this thread</a>.  Note that disabling vmsplice, while it will fix this vulnerability, means crippling a Linux syscall; while this syscall is used only rarely, if you do this and software <em>does </em>try to use vmsplice it may corrupt kernel memory.  Thus, option #2 is much, much better; get an updated kernel for your distro that fixes the bug.</li>
</ol>
<p>a</p>
]]></content:encoded>
			<wfw:commentRss>http://perimetergrid.com/wp/2008/02/11/asus-eee-pc-and-linux-vmsplice-vulnerabilities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OS-Based Mitigations Against Common Attacks</title>
		<link>http://perimetergrid.com/wp/2008/02/04/os-based-mitigations-against-common-attacks/</link>
		<comments>http://perimetergrid.com/wp/2008/02/04/os-based-mitigations-against-common-attacks/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 23:41:44 +0000</pubDate>
		<dc:creator>Grant Bugher</dc:creator>
				<category><![CDATA[attacks]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[mitigations]]></category>

		<guid isPermaLink="false">http://perimetergrid.com/wp/2008/02/04/os-based-mitigations-against-common-attacks/</guid>
		<description><![CDATA[In my last post about finding a job in information security, when discussing application security, I off-handedly mentioned several mitigation technologies &#8212; GS, DEP, SAL, and ASLR. These are technologies developed by OS vendors to provide system-wide protection against common attacks, and are things every application developer should know about when dealing with native (unmanaged) [...]<p>a</p>
]]></description>
			<content:encoded><![CDATA[<p>In my last post about <a href="http://perimetergrid.com/wp/2008/01/31/how-to-get-a-job-in-information-security/">finding a job in information security</a>, when discussing application security, I off-handedly mentioned several mitigation technologies &#8212; GS, DEP, SAL, and ASLR.  These are technologies developed by OS vendors to provide system-wide protection against common attacks, and are things every application developer should know about when dealing with native (unmanaged) code.</p>
<p>The scourge of C and C++ apps for the last decade and a half has been the <a href="http://en.wikipedia.org/wiki/Buffer_overflow">stack buffer overflow</a>.  This is an attack wherein the attacker discovers that an application is trying to fit some piece of user input into a spot in memory without first checking to see if it will fit.  In the most common scenario, the spot in memory is a local variable, which means that carefully-crafted input can overwrite the return pointer on the stack with a user-selected value.  If this is done, when the function finishes it will transfer execution to the user-provided input, which can then take control of the running process and do anything that that process&#8217;s owner is capable of.  If the process is an OS service, running with a privileged account like root on a UNIX/Linux system or Administrator/SYSTEM on a Windows system, it may be able to take full control of the system.  I first learned this attack in Aleph One&#8217;s classic Phrack article, <a href="http://insecure.org/stf/smashstack.html">Smashing the Stack for Fun and Profit</a>, written in 1996.</p>
<p>Application developers have been told for many years now to be very careful when allocating memory and copying data, especially strings, to prevent these exploits.  However, it&#8217;s relatively difficult, so developers continue to make the same mistakes.  In addition, the attackers get more creative, and have found variations on this attack that are even harder to avoid.  Luckily, OS developers have also been busy trying to find global mitigations for these attacks, so that developers <em>can&#8217;t </em>make these mistakes, and the whole computing ecosystem becomes safer.</p>
<h2>Stack Canaries</h2>
<p>The first common OS-based mitigation technology is the stack canary.  On Windows, this mitigation is activated via the /GS compiler option (for Guard Stack); Solaris also incorporates a similar mechanism called StackGhost, while the latest GCC compiler on Linux has a stack protection feature called PPC.  Of the major OS&#8217;s currently in use, only Mac OS X is missing a stack canary feature.</p>
<p>Whenever a function is called, a stack frame is created in memory for the function call.  The stack frame is arranged as follows:</p>
<table border="1">
<tr>
<td>Local Variables</td>
<td>Saved EBP</td>
<td>Saved EIP</td>
<td>Arguments</td>
</tr>
</table>
<p>Each portion of the frame is just large enough for its contents.  EIP is the instruction pointer &#8212; whatever EIP points to, the processor executes.  The Saved EIP is the return pointer &#8212; when the function returns, that saved value is placed into EIP.</p>
<p>A buffer overflow occurs when the attacker tricks the application into placing something into a local variable that is too large to fit.  It thus overflows its bounds, overwriting the saved registers.  Since the saved EIP has been overwritten, when the function returns, execution jumps to whatever value the attacker wants.  However, in a /GS-compiled binary, this is much more difficult, as the stack frame instead looks like this:</p>
<table border="1">
<tr>
<td>Local Variables</td>
<td>Canary</td>
<td>Saved EBP</td>
<td>Saved EIP</td>
<td>Arguments</td>
</tr>
</table>
<p>The canary is basically an arbitrary random number.  However, the system remembers what it was when the stack frame was entered, and before returning to the saved EIP, it checks to make sure the canary value hasn&#8217;t changed.  This poses a problem for the attacker, because it&#8217;s in the way!  Any value large enough to overwrite the saved EIP will also overwrite the canary, and the attacker doesn&#8217;t know what the canary value is.  In order to get it, he would need to execute some code to read it&#8230; and he can&#8217;t execute code with the canary in the way.  Thus, stack buffer overflows are prevented.</p>
<p>Some creative attackers figured out that you could still sometimes do some damage by overwriting not the saved EIP, but the function arguments.  If a function makes use of delegation and receives function pointers in arguments, you could sometimes still execute code this way, because they would be used <em>during </em>the function, and /GS only checks the canary when the function <em>returns</em>.  Thus, in recent versions of Visual Studio, /GS also causes the system to make a copy of the arguments when a stack frame is created, placed <em>before </em>the local variables.  The copy is used until the function exits; thus, overwriting the arguments does nothing until the function returns, at which time the canary is checked, and any corruption is detected.</p>
<h2>Hardware Data Execution Protection</h2>
<p>Another mitigation added for buffer overflow prevention is what Microsoft calls Data Execution Protection (DEP), which makes use of Intel and AMD&#8217;s NX (No-Execute) flag on recent CPUs.  On NX-enabled CPUs, each memory page is marked as either code (executable) or data (not executable,) and a fatal error occurs if EIP ever points into a data page.  A compiler flag in Visual Studio 2005 and greater (/NXCOMPAT) enables this feature on an application; Linux compilers have also added a similar feature.</p>
<p>The entire stack is marked as a data page, which normally prevents stack overflows.  While the attacker can overwrite EIP, he can&#8217;t make it jump execution into his own input, so he can&#8217;t execute his own code &#8212; only code already in the process.  However, once again, enterprising hackers have found a way around it &#8212; what is called the &#8220;return to libc&#8221; attack.  They overwrite the saved EIP with an address pointing to kernel32!VirtualProtect(), the function that marks pages as code or data!  With carefully crafted arguments, they can actually instruct VirtualProtect to mark the stack as code, then return into their code.  On the bright side, this is very difficult, and won&#8217;t work if the exploitable buffer is a string, because the required arguments are full of null bytes.</p>
<p>A more elaborate attack can call into ntdll!NtSetInformationProcess and disable NX for the entire process.  The advantage to this is that it can be done without null bytes (though it&#8217;s very complicated), so it can go through strings.  The disadvantage, though, is that it won&#8217;t likely work on a securely-configured production server.  If NX is set globally enabled in boot.ini, ntdll!NtSetInformationProcess is unable to override it.</p>
<p>Though I&#8217;ve mentioned Windows-specific function names here, there are Linux equivalents that can be used in attacks.  (Indeed, it&#8217;s called the &#8220;return to libc&#8221; attack because of the name of the UNIX/Linux C runtime library.)</p>
<h2>Address Space Layout Randomization</h2>
<p>All of these evasions of NX protection require being able to instruct the system to jump directly into system functions.  Doing this requires <em>address prediction </em>&#8211; you have to know where in memory the system functions <em>are </em>so you can jump to them.  Even in the simple stack-smashing exploit, the attacker still needs to know where the stack is in order to place that value into the saved EIP.  Address Space Layout Randomization (ASLR) is a relatively new technology that makes address prediction nearly impossible by making libraries load into different locations on every reboot.  If the attacker doesn&#8217;t know where the libraries are, he generally cannot jump to them with any reliability.</p>
<p>ASLR is enabled on Windows using the linker flag /DYNAMICBASE.   OpenBSD has ASLR by default; Linux implementations have a weak form of ASLR but can be upgraded to full ASLR using various popular kernel patch.  Once again, Mac OS X is the only major OS missing this mitigation, though changes in OS X 10.5 imply they are preparing to add it in a future version.</p>
<p>ASLR randomizes where libraries are found, so that it is very difficult to predict where they are.  It does, however, have a few weaknesses:</p>
<ol>
<li>In many cases, executable files themselves are not randomized.  Thus, attackers are prevented from jumping to system functions, but can still jump to functions in the executable file.</li>
<li>Only the high-order bytes of addresses are randomized; the attacker can still jump to anything within 16 memory pages of known address space.</li>
<li>It may be possible to brute-force the location of a library by simply trying all the addresses if you have a section of code that will permit this.</li>
</ol>
<p>Case #3 is very difficult on Windows, since there are no forking daemons and if a service is made to crash several times in a row it will stop restarting (precisely to prevent this sort of brute-forcing.)  However, on UNIX/Linux systems, this is possible, and it may be possible on Windows, too, if the code being exploited eats exceptions (i.e. it has an exception handler that discards errors and keeps the service running.)</p>
<h2>Safe Structured Exception Handling</h2>
<p>On Windows C++ applications, there&#8217;s another way around the stack canaries &#8212; exploiting Structured Exception Handling.  When SEH is used, the stack looks like this:</p>
<table border="1">
<tr>
<td>Local Variables</td>
<td>SEH Next</td>
<td>SEH Ret</td>
<td>Canary</td>
<td>Saved EBP</td>
<td>Saved EIP</td>
<td>Arguments</td>
</tr>
</table>
<p>Those SEH pointers are found before the canary, and thus can be overwritten.  It&#8217;s possible to craft values for those pointers that point into the stack, and then force an exception to occur.  When the exception happens, the pointers are followed and arbitrary code is run.  Stack canaries don&#8217;t help with this (and the canary can&#8217;t be put before the SEH pointers, because in a sense they <em>are </em>local variables, just not ones declared by the programmer), though NX still does.  However, since NX is not available on all processors (nor enabled on all processes), Microsoft also introduced the /SafeSEH compiler flag.</p>
<p>In a /SafeSEH process, when execution begins, the system asks all the libraries in a process to find all of their possible exception handlers and write them to a table.  Before ever jumping to an SEH Next pointer, it verifies that the pointer points to something on the table.  Thus, if the attacker overwrites this pointer, it does no good &#8212; he can&#8217;t run anything that isn&#8217;t an exception handler.</p>
<p>There is a problem with this, though &#8212; it only works if every library used by an application was compiled with /SafeSEH and records its exception handlers on the table.  If even one library didn&#8217;t, then the system can&#8217;t verify the pointers &#8212; they might well be pointing to an exception handler that just wasn&#8217;t registered.</p>
<p>There are no non-Windows equivalents to /SafeSEH, as the SEH method of exception handling is a Windows-specific construct.</p>
<h2>Security Annotation Language</h2>
<p>Ideally, we wouldn&#8217;t need all these mitigations because we wouldn&#8217;t be writing buffer overflows in the first place.  However, when writing complex code, they can be very hard to see.   We would prefer that the compiler just detect the overflows at compile-time, but the compiler doesn&#8217;t always know how our variables will be used, and thus cannot determine where an overflow may lie.</p>
<p>Microsoft&#8217;s Security Annotation Language (<a href="http://blogs.msdn.com/michael_howard/archive/2006/05/19/602077.aspx">discussed in detail on Michael Howard&#8217;s blog here</a>) allows the developer to &#8220;hint&#8221; to the compiler how all the arguments to a function are used.  The developer uses SAL annotations on each function declaration, specifying if arguments are input or output, if they can be NULL, how long their buffers are, etc.  These &#8220;hints&#8221; (actually compiler macros) allow the compiler to verify that no buffer overruns are being introduced.</p>
<p>It&#8217;s more work for the developer, as they have to put some thought into the annotations, and a company making use of SAL has to enforce its use (i.e. no checking in functions that aren&#8217;t annotated.)  However, while it&#8217;s work, it&#8217;s not difficult &#8212; unlike checking for buffer overruns manually, which is <em>very </em>difficult.  With properly-annotated functions, most buffer overruns can be caught at compile time, and fixed before the application is ever released.  Unfortunately, SAL has not seen much use outside of Microsoft itself, due to the extra developer overhead.  It&#8217;s easier to get people to add a few compiler &amp; linker flags than to change the way they program.</p>
<p>a</p>
]]></content:encoded>
			<wfw:commentRss>http://perimetergrid.com/wp/2008/02/04/os-based-mitigations-against-common-attacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using xcache
Page Caching using xcache (user agent is rejected)
Database Caching 7/13 queries in 0.034 seconds using disk

Served from: perimetergrid.com @ 2010-09-10 01:37:47 -->