<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Defender Mindset</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/johnla/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/johnla/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 04:12:07 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>How InfoSec Security Controls Create Vulnerability</title>
      <link>https://docs.microsoft.com/archive/blogs/johnla/how-infosec-security-controls-create-vulnerability</link>
      <pubDate>Sat, 20 Feb 2016 08:04:37 GMT</pubDate>
      <dc:creator><![CDATA[John Lambert (MSTIC)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/johnla/2016/02/20/how-infosec-security-controls-create-vulnerability/</guid>
      <description><![CDATA[One frequent reality in many intrusions is that attackers don&rsquo;t target the data they are...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family:Calibri;font-size:medium;">One frequent reality in many intrusions is that attackers don&rsquo;t target the data they are interested in directly; they target the security controls designed to protect them.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">That is, the very solution InfoSec professionals craft to protect assets from risks become the means by which the attackers are able to access them.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">They steal legitimate credentials of elevated accounts. They target the account management system.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">They use security data such as access control lists and security group memberships to target users for compromise. How did the InfoSec solution become the InfoSec problem?</span></p>
<h2><span style="color:#2e74b5;font-family:Calibri Light;font-size:large;">The Key Aspects that Undermine Security Controls</span></h2>
<p><span style="font-family:Calibri;font-size:medium;">The protection of information in a network has been long studied by information security professionals. There are lengthy standards, numerous certification regimes, and a bevy of security control solutions for risk management problems.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">It is the application of these InfoSec methods without due consideration of the following aspects that leads to networks where the choices in individual risk management decisions fail to create a defensible system:</span></p>
<ol>
<li>
<p>Lack of recursive threat modeling</p>
</li>
<li>
<p>Security controls with dependencies that resemble a complex IT org chart</p>
</li>
<li>
<p>The difficulty in visualizing the security dependency graph, especially as it changes</p>
</li>
</ol>
<p><span style="font-family:Calibri;font-size:medium;">This doomed security control system then becomes the interim target of intrusions because of its power over the assets the attackers ultimately seek.</span></p>
<h2><span style="color:#2e74b5;font-family:Calibri Light;font-size:large;">Lack of Recursive Threat Modeling</span></h2>
<p><span style="font-family:Calibri;font-size:medium;">Part of an information security program is defining critical assets and threat modeling risks.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">These risks are then minimized by the application of one or more security controls&mdash;authentication, access control, vulnerability scanning, and so forth. A critical aspect, however, is that these controls have their own risks. Security controls are not a magical, impenetrable substance.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">The controls to protect information and systems are themselves information and systems.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span></p>
<p><span style="font-family:Calibri;font-size:medium;">For example, to protect a sensitive document repository, one might employ access controls and authentication (the access control list, account database, and secrets are information), deploy encryption technology (the keys, their storage, and escrowed instances are information), install a data loss prevention system (an appliance with its own operating system and information), and check for weaknesses with a vulnerability scanner (another system with its own information).</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span></p>
<p><span style="font-family:Calibri;font-size:medium;">The selection of controls must be recursively and holistically threat modeled for completeness.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">This difficulty in doing this can be exacerbated if the subject matter expertise to do the threat modeling is different at every layer. For example, an InfoSec practitioner using a Data Loss Prevention solution to mitigate sensitive data leaving the network may be an expert on SOX, PCI, and categories of customer PII, but they may not be an expert on the security implementation requirements of a Linux based appliance they procured.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">Controls come with risks and must be treated accordingly.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span></p>
<h2><span style="color:#2e74b5;font-family:Calibri Light;font-size:large;">The Org Chart of IT Creates a Graph of Security Dependencies</span></h2>
<p><span style="font-family:Calibri;font-size:medium;">Once networks get to a certain size, IT organizations specialize. Endpoint management is handled by one team, whereas the data center is handled by another.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">Vulnerability scanning is handled by a dedicated team and identity management by another.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">These teams tend to have their own support infrastructure.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">&nbsp;&nbsp;</span><span style="font-family:Calibri;font-size:medium;">InfoSec controls are not separable from IT.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">This matrix that exists at an organization level expresses itself as a graph of security dependencies at the information level.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">For example, the vulnerability scanning systems may use a &ldquo;god account&rdquo; that has admin rights on every host in the network to scan for weaknesses.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">The vulnerability scanners may be patched or backed up by a different IT team with admin rights to them.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">The vulnerability scanner servers are accessed with admin rights from a set of endpoints that are managed by yet another IT team who has control over those endpoints.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">The matrix of IT services arising from domain specialization creates a lattice of critical dependencies, each of which can present opportunities for lateral movement.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">If the dependencies of the security controls resemble the complexity of the org chart, it&rsquo;s time to simplify. </span></p>
<h2><span style="color:#2e74b5;font-family:Calibri Light;font-size:large;">The Difficulty of Visualizing Security Dependencies</span></h2>
<p><span style="font-family:Calibri;font-size:medium;">Security dependencies are often difficult to see.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">Identifying the security dependencies of a host involves significant subject matter expertise to inventory the critical settings: the file servers hosting scripts run on every user logon, the background service that pulls down executables from upstream servers to update themselves, the network printers used by the host that cause it to download and install device drivers, and so on.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">Networks are very dynamic.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">The provisioning or decommissioning of systems affects the graph.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">User login behavior and where credentials are used can vary.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">Changes in network connectivity or domain trusts can affect it.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">There are hidden edges in the graph&mdash;an unpatched server or appliance effectively creates new edges in the dependency graph.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">The reuse of a password across different trust domains creates a hidden link.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">If you can&rsquo;t manage what you don&rsquo;t measure, you can&rsquo;t prune a graph you&rsquo;re not visualizing.</span></p>
<p><span style="font-family:Calibri;font-size:medium;">This is exacerbated in many environments because the fulfillment of compliance requirements does not leave InfoSec professionals enough time to do the analysis necessary to protect a living network. Management support affects this greatly. If achievement of conformance with various InfoSec standards is all that management supports, then the talent, time, and analysis to ensure the details are right won&rsquo;t be there.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">Analysis of this kind requires whitespace from other compulsory activities. </span></p>
<h2><span style="color:#2e74b5;font-family:Calibri Light;font-size:large;">How do Successful Defenders Cope?</span></h2>
<p><span style="font-family:Calibri;font-size:medium;">Despite these obstacles, I find defenders at many organizations able to cope with these challenges.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">Here are the practices I see in them:</span></p>
<ol>
<li>
<p>They manage from the terrain, not the map.&nbsp; They seek to know what&rsquo;s truly running in their network, not just the services that IT officially manages.</p>
</li>
<li>
<p>They better manage isolation and compartmentalization leading to fewer spaghetti dependencies to manage.&nbsp; They reduce the number of ingress and egress paths to remove duplication.</p>
</li>
<li>
<p>They have a bench of subject matter experts to do the required threat modeling.&nbsp; They know they can&rsquo;t secure things they don&rsquo;t understand. Any technology indistinguishable from magic has no place on their network.</p>
</li>
<li>
<p>They have a keen appreciation of the difference between the risks of Murphy and Satan.&nbsp; &ldquo;Murphy risks&rdquo; cause problems but ones that are not intentional in nature&mdash;for example an outage or commodity malware landing opportunistically on a host in the network.&nbsp; &ldquo;Satan risks&rdquo; are risks with intent. There is an active adversary.&nbsp; InfoSec security control selection does well against Murphy, but requires different thinking for Satan.</p>
</li>
<li>
<p>They have a heavy emphasis on detective controls that look for abuse of legitimate access. They &ldquo;Assume Breach&rdquo; and work from the assumption that their controls will be compromised and are prepared to work the kill chain starting at the end first.</p>
</li>
<li>
<p>They have management support for the whitespace required to analyze and defend a complex system. Compliance requirements, while mandatory, are seen as necessary but not sufficient.</p>
</li>
<li>
<p>They embrace the matrix and coordinate well across their peer IT teams and users of the network.</p>
</li>
<li>
<p>They employ penetration testing but instead of treating it as a report card, an output, they treat it as an input. They use pentesting in a diagnostic way informing a comprehensive security program.</p>
</li>
<li>
<p>They do attack research.&nbsp; They know that knowledge on how to find vulnerabilities and assess their exploitability is just as valuable for defenders as it is for attackers.&nbsp; Their blue teams bleed red and their red teams bleed blue.</p>
</li>
<li>
<p>They actively manage their graph. They reduce the number of standing administrators.&nbsp; They consider the attack surface of their defense.&nbsp;</p>
</li>
</ol>
<p><span style="font-family:Calibri;font-size:medium;">Until InfoSec teams are better able to handle the aspects of recursive threat modeling, deal with the matrix effects of IT, visualize their security dependencies better, and find the whitespace to do it all, security controls will continue to be a primary attack surface targeted by attackers in intrusions.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">InfoSec regimes also need to do a better job at documenting successful methods and practices for doing this kind of analysis.</span><span style="font-family:Calibri;font-size:medium;">&nbsp; </span><span style="font-family:Calibri;font-size:medium;">It&rsquo;s critical to get right, because that&rsquo;s the Defender&rsquo;s Mindset.</span></p>
<p><span style="font-family:Times New Roman;font-size:medium;"><br /></span><span style="font-family:Calibri;font-size:medium;"> -----</span></p>
<p><span style="font-family:Calibri;font-size:medium;">This blog expands on a topic from this tweet: </span><a href="https://twitter.com/JohnLaTwC/status/699304590500634625"><span style="color:#0563c1;font-family:Calibri;font-size:medium;">https://twitter.com/JohnLaTwC/status/699304590500634625</span></a></p>
<p><span style="font-family:Calibri;font-size:medium;">Thanks to Tal Be&#39;ery (<a href="https://twitter.com/TalBeerySec">@TalBeerySec</a>) from the Microsoft ATA team, Adam Shostack (<a href="https://twitter.com/adamshostack">@adamshostack</a>), and Erica E&nbsp;for reviewing a draft of this post. </span></p>]]></content:encoded>
    </item>
    <item>
      <title>The Inside Story Behind MS08-067</title>
      <link>https://docs.microsoft.com/archive/blogs/johnla/the-inside-story-behind-ms08-067</link>
      <pubDate>Sat, 26 Sep 2015 10:10:00 GMT</pubDate>
      <dc:creator><![CDATA[John Lambert (MSTIC)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/johnla/2015/09/26/the-inside-story-behind-ms08-067/</guid>
      <description><![CDATA[Seven years ago a small set of targeted attacks began.  In 2008 an unknown set of attackers had a...]]></description>
      <content:encoded><![CDATA[<span style="font-family: Calibri;font-size: medium">Seven years ago a small set of targeted attacks began.  In 2008 an unknown set of attackers had a zero day vulnerability that would soon have worldwide attention.  They were patient and used it quietly in several countries in Asia.  The vulnerability was not just good--it was the kind of vulnerability that offensive teams and bug hunters dream about.  It was, as we say in the business, “wormable”. That word sends chills down any defender’s spine.  In short, the attackers had a remote code execution (RCE) vulnerability that affected every version of Windows, gave them full control at SYSTEM level rights, left almost no forensic footprint, and could be used anonymously from anywhere on the Internet.  Their exploit was 95% reliable. Almost perfect. Almost.</span>
<h2><span style="color: #2e74b5;font-family: Calibri Light;font-size: large">Exploit Mitigations</span></h2>
<span style="font-family: Calibri;font-size: medium">The story starts a year earlier.  If you meet anyone that works in the Trustworthy Computing group at Microsoft, one thing you notice is that many of us chart our career milestones by Microsoft security bulletins.  “MS03-007? That was a doozy.” “Sure, but MS03-026 was crazy.” “You’re right, that was crazy.”  To understand MS08-067 you need to understand MS07-029, an RCE vulnerability in Windows DNS.  MS07-029 was one of a series of Remote Procedure Call (RPC) server vulnerabilities that were steadily being ferreted out by Microsoft, attackers, and security researchers alike.  There was one difference. MS07-029 was the first RCE that where we had our Visual Studio return address protection (/GS) and Windows Data Execute Prevention (DEP) in effect.  We refer to these defenses as exploit mitigations and we had been steadily adding them since XP SP2.  It was one of the ways we were using <i>security engineering</i> to combat security issues in engineering. Once an exploit has trashed the internal memory of a process, there is no recovery and the only option is to force a crash—a terrible user experience for sure, but better than resulting in a compromised machine. Exploit writers know we have been adding a steady stream of mitigations: SafeSEH, SEHOP, heap hardening, ASLR, MemProtector, IsoHeap, and Control Flow Guard.  These mitigations not only close off avenues for exploitation, but they also give us the ultimate two-fer.  They feed telemetry.</span>
<h2><span style="color: #2e74b5;font-family: Calibri Light;font-size: large">Exploits feed Telemetry</span></h2>
<span style="font-family: Calibri"><span style="font-size: medium">Crashes are a terrible experience for users so Windows has a facility called Windows Error Reporting (WER) that can, if the user consents, send the crash data to Microsoft. WER receives hundreds of millions of crashes from poorly behaving apps and buggy hardware running on over one billion PCs.  Engineers “bucket” them by the underlying root cause and work their way down the priority list—first fixing bugs affecting the greatest number of customers.  Remember that the next time a Windows Error Reporting dialog appears—you’re voting for your bug.  </span></span>

<span style="font-family: Calibri;font-size: medium">The crash buckets for the bug in MS07-029 were revealing.  The figure shows a significant increase in crashes in Windows DNS after the issue became public (early April 2007).  Once an issue is public, security researchers and attackers alike race to re-discover the vulnerability and move from proof-of-concepts to working exploits. The crash buckets for Windows DNS suddenly became very active.  Every idea has its moment of inspiration. For me, it was looking at that chart: just before we learned of the attack, every few days there was a crash--a blip in the WER universe.  I looked at each of them and saw that all of them were exploits. If we had the ability to determine when a crash was an exploit, we could respond much earlier in the attack lifecycle and protect customers sooner. To find 0-days, you won’t find them in the big noisy buckets generating hundreds of thousands of hits per day. You need to live in the long tail of small data.  Determined to make security crashes “loud”, I went into the strange and bizarre world of bit flips, one hit wonders, unreproducible race conditions, and 0-days.</span>

<a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/04/69/ms07-029.png"><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/04/69/ms07-029.png" border="0" /></a>
<h2><span style="color: #2e74b5;font-family: Calibri Light;font-size: large">Living in the Tail</span></h2>
<span style="font-family: Calibri"><span style="font-size: medium">By September 2008 we had built a system that screened millions of crashes for security exploits.  Along the way I felt like I joined the world’s smallest profession—that of an exploit failure engineer. On September 25</span><sup><span style="font-size: small">th</span></sup><span style="font-size: medium"> a crash came in that got my attention--an exploit in netapi32.dll. This alone was not unusual.  With MS06-040 we fixed a buffer overrun in netapi32!NetpwPathCanonicalize that received millions of crashes every day from botnets attempting (and failing because of /GS) to infect vulnerable PCs.  This new crash was in very similar code, but in a different WER bucket. It was not in the top 100 or top 1,000 issues. It was bucket #45,000 with exactly 2 hits ever.  This was living in the tail. </span></span>

<a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/04/69/45000.png"><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/04/69/45000.png" border="0" /></a>
<h2><span style="color: #2e74b5;font-family: Calibri Light;font-size: large">Enter !pwnd</span></h2>
<span style="font-family: Calibri;font-size: medium">What made this tiny bucket stand out?  First, there was an exploit.  We had written a custom debugger extension, colorfully called !pwnd (Windows debugger extensions are invoked by prefixing it with the ‘bang’ symbol). It found shellcode in the crash dump. I reviewed the shellcode and saw that it used an egghunt to find the payload.  An egghunt is an exploit engineering technique used when a buffer overrun is constrained in terms of how much payload can be sent.  The solution is to split the attack into two parts. In the first part, you interact with the target in a benign way, sending over data that contains your real payload preceded by a unique sequence of bytes (the “egg”), but without triggering the vulnerability.  If you do this the right way, your payload sticks around in memory somewhere. Then you trigger the vulnerability and your constrained shellcode searches around in memory for the egg and jumps to it.  This was the first exploit for netapi32.dll that used an egghunt. An eyebrow was raised.</span>

<a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/04/69/egghunt.png"><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/04/69/egghunt.png" border="0" /></a>

<span style="font-family: Calibri;font-size: medium">The second thing unusual about this crash dump was not just the way it failed.  It was the way it was succeeding before it crashed.  I looked beyond the crashing thread to the other threads in the process.  One of them revealed the attacker had already exploited the process and the shellcode was in the middle of downloading a payload using URLDownloadToFileA!</span>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="623" valign="top">&nbsp;

&nbsp;

0:066&gt; kPn99

&nbsp;

# ChildEBP RetAddr

&nbsp;

00 0150f048 7c90e9ab ntdll!KiFastSystemCallRet(void)

&nbsp;

01 0150f04c 7c8094e2 ntdll!ZwWaitForMultipleObjects(void)+0xc

&nbsp;

...

&nbsp;

08 0150f2b4 7813b13a urlmon!CUrlMon::StartBinding(

&nbsp;

int fBindToObject = 0,

&nbsp;

struct IBindCtx * pbc = 0x00185540,

&nbsp;

struct IMoniker * pmkToLeft = 0x00000000,

&nbsp;

struct _GUID * riid = 0x7813b394 {0000000c-0000-0000-c000-000000000046},

&nbsp;

void ** ppvObj = 0x0150f2fc)+0x169

&nbsp;

09 0150f2d8 7815bcd2 urlmon!CUrlMon::BindToStorage(

&nbsp;

struct IBindCtx * pbc = 0x00185540,

&nbsp;

struct IMoniker * pmkToLeft = 0x00000000,

&nbsp;

struct _GUID * riid = 0x7813b394 {0000000c-0000-0000-c000-000000000046},

&nbsp;

void ** ppvObj = 0x0150f2fc)+0x49

&nbsp;

0a 0150f31c 781b73d2 urlmon!CBaseBSCB::KickOffDownload(

&nbsp;

wchar_t * szURL = 0x0150f400 "hxxp://59.106.145.58/n2.exe")+0x193

&nbsp;

0b 0150f330 781b7847 urlmon!CFileDownload::KickOffDownload(

&nbsp;

wchar_t * szURL = 0x0150f400 "hxxp://59.106.145.58/n2.exe")+0x2d

&nbsp;

0c 0150f348 781b7a4a urlmon!URLDownloadToFileW(

&nbsp;

struct IUnknown * caller = 0x00000000,

&nbsp;

wchar_t * szURL = 0x0150f400 "hxxp://59.106.145.58/n2.exe",

&nbsp;

wchar_t * szFileName = 0x0150f380 "update.exe",

&nbsp;

unsigned long dwReserved = 0,

&nbsp;

struct IBindStatusCallback * callback = 0x00000000)+0x51

&nbsp;

0d 0150f480 0150f5b8 urlmon!URLDownloadToFileA(

&nbsp;

struct IUnknown * caller = 0x00000000,

&nbsp;

char * szURL = 0x0150f6a1 "hxxp://59.106.145.58/n2.exe",

&nbsp;

char * szFileName = 0x0150f6d1 "update.exe",

&nbsp;

unsigned long dwReserved = 0,

&nbsp;

struct IBindStatusCallback * callback = 0x00000000)+0x109

&nbsp;</td>
</tr>
</tbody>
</table>
<span style="font-family: Calibri;font-size: medium">While egghunts weren’t new, this was a new flavor of shellcode for netapi32 exploits and clear evidence of a successful exploit. The final nail in the coffin was the version information in the crash dump. Netapi32.dll was fully patched!  There seemed to be only one explanation for this: a new 0-day in the wild. </span>

0:088&gt; lmvm netapi32

Image path: C:\WINDOWS\system32\netapi32.dll

Image name: netapi32.dll

Timestamp:        Thu Aug 17 05:28:27 2006 (44E460EB)

File version:     5.1.2600.2976
<h2><span style="color: #2e74b5;font-family: Calibri Light;font-size: large">Going in Reverse</span></h2>
<span style="font-family: Calibri;font-size: medium">Most of the time security researchers find a vulneraility then work to write an exploit.  I was going in reverse: examining an exploit to determine the vulnerability, armed with only a forensic crash and no way to reproduce it. Had the exploit blown away the crucial clues in the buffer overrun itself? I studied the crash over and over. I looked at the source code for netapi32.  Vulnerabilities are often obvious in hindsight but stubborn to reveal themselves at first. Here was my dilemma: if I could not find the vulnerability, despite having a clear exploit, we could not act. Engineers first need to understand the bug to fix it.  If I could not find the bug, this opportunity would pass us by. I was stuck and the clock was ticking, so what did I do? I asked for help. </span>

<span style="font-family: Calibri;font-size: medium">I brought the case to the manager of the MSRC security engineers, Andrew Roths.  Andrew is a brilliant security engineer. The only problem was Andrew had, like me, looked at many crash dumps before and knew all too well the elusive nature of finding new issues in the tail of data. There are many dead ends, false starts, and fool’s gold. I remember this time vividly. There was some tension in the air because I was pressing for help from a busy team on something the odds said were unlikely. After all, this code had been pored over by Microsoft and security researchers intensely already.  Would a latent buffer overrun have escaped all those eyeballs?  There are often confounding factors in a crash. You can debug a crash for hours confident you have a vulnerability dead to rights only to find out the machine had a buggy driver randomly flipping bits in memory. Life in the tail is harsh. </span>

<span style="font-family: Calibri"><span style="font-size: medium">I remember the moment Andrew stopped by my office. I was ready for a debate about whether we should pull security engineers off of already confirmed vulnerability cases, potentially delaying them, to work on this elusive vulnerability. The look on his face told me something had changed. He said, “I found a vulnerabilty.” What Andrew had done said a lot about himself.  Like any good manager, Andrew wanted to shield his people from randomization.  He took the case on himself.  He thought this might be another dead end and wanted to prove it to bring the issue to closure.  MSRC engineers care deeply about their analysis of vulnerabilities and his doggedness broke the case. He walked me through his analysis, and once we were sure, there was only one thing to do next.   </span></span>
<h2><span style="color: #2e74b5;font-family: Calibri Light;font-size: large">“Wormable”</span></h2>
<span style="font-family: Calibri;font-size: medium">We walked down the hallway to the office of the crisis manager, Phillip.  He was in the middle of a meeting with someone in his office.  There must have been something about the expression on our faces because he turned to his visitor and abruptly said, “I’ll talk with you later”.  We entered and I said, “we have a zero day.”  We explained the basic facts.  We had a vulnerabilty, that could be exploited remotely,  anonymously, that affected all versions of Windows. It was wormable and someone was already exploiting it.  When you say the word ‘wormable’ to a crisis manager, it activates some latent response DNA.  In his quiet way he went from 1 to 11 and immediately got to work mobilizing everyone. Scarred by Code Red and Blaster, when an issue is wormable, at Microsoft everyone shows up and works it as job #1. </span>

<span style="font-family: Calibri;font-size: medium">At this point, I let the vulnerability response process drive the engineering fix and went back to my crashes. What else could telemetry tell us about activity and spread? Could I tell if this was targeted or already being used in mass infections?  I used one of my exploit failure engineering skills of “dialing into the buckets.” That is, finding all the relevant crashes that represent this issue on every version of Windows, every SKU, every possible way the exploit could fail. On Windows Vista and Windows Server 2008 it always failed.  The Security Development Lifecycle (SDL) process at Microsoft made sure those OS editions had full ASLR and DEP for the svchost.exe process and the RPC interface had been upgraded to require authentication—a classic example of a win from defense in depth, now fueling my radar.</span>
<h2><span style="color: #2e74b5;font-family: Calibri Light;font-size: large">Attacker Impatience is the Defender’s Reward</span></h2>
<span style="font-size: medium"><span style="font-family: Calibri">Why did the original exploit fail? The short answer is that the attacker made a mistake. The vulnerability was in canonicalizing the path component of a filename (e.g. turning \foo\..\bar\filename.ext into \bar\filename.ext). An attacker could trigger conditions that confused the way the code indexed the string and a buffer would get copied somewhere on the stack it should not.  Normally this invalid input would cause the buggy code to crash, but the exploit authors figured out a way around this problem. Triggering the vulnerability would cause the code to sweep and search for a slash character (‘\’ or 0x5c) that was outside the bounds of the buffer.  All that normally sits outside of the buffer are thread stack contents: local variables, return addresses, and pointers.  The attacker needed to place a 0x5c byte nearby otherwise the code would sweep through the stack and crash the second it touched the guard page that abuts every thread stack.  Their solution for this was to first call the vulnerable function with a benign input that had the slash character but would not trigger the vulnerability. This data would stay latent on the stack, like a ghost, the next time the function was called.  This technique was perfectly reliable if Windows used the same thread for both requests.  This happened nearly all the time. Nearly.  In a quirk of fate, the Windows RPC thread pool handed the second request containing the exploit to a different thread—one that did not have the carefully placed slash character.  The netapi32 code kept searching for it, eventually running off the end of the thread stack, hitting the guard page, and crashing the process with a stack overflow error (</span>0xC00000fd<span style="font-family: Calibri">).  My interpretation is that the attack had succeeded and was downloading the payload, but the attacker got impatient or goofed and ran the exploit a second time. Patience is a virtue after all!</span></span>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="623" valign="top">0:088&gt; .ecxr

&nbsp;

eax=064c2ffe ebx=064f005c ecx=064ff49a edx=064ff544 esi=064ff464 edi=064ff464

&nbsp;

eip=5b878809 esp=064ff464 ebp=064ff474 iopl=0         nv up ei pl nz na po cy

&nbsp;

cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010203

&nbsp;

netapi32!ConvertPathMacros+0x101:

&nbsp;

5b878809 6683385c        cmp     word ptr [eax],5Ch       ds:0023:064c2ffe=????

&nbsp;

0:088&gt; .exr -1

&nbsp;

ExceptionAddress: 5b878809 (netapi32!ConvertPathMacros+0x00000101)

&nbsp;

ExceptionCode: c00000fd (Stack overflow)

&nbsp;

ExceptionFlags: 00000000

&nbsp;

NumberParameters: 2

&nbsp;

Parameter[0]: 00000000

&nbsp;

Parameter[1]: 064c2ffe

&nbsp;</td>
</tr>
</tbody>
</table>
<h2><span style="color: #2e74b5;font-family: Calibri Light;font-size: large">Crashes as Situational Awareness</span></h2>
<span style="font-family: Calibri;font-size: medium">After “dialing into the buckets” I provided situational awareness to the response process. By examining the locale information in the crashes we had some sense of geographic spread. It went from Japan to Malaysia, Philippines, Vietnam, and beyond.  Below is the chart of activity. The barely visible blue bars are the crash activity.  The red bars are the success activity. </span>

<a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/04/69/success.png"><img alt=" " src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/04/69/success.png" border="0" /></a>

<span style="font-family: Calibri;font-size: medium">Once MSRC was ready with the patch, we made the decision to ship it as an out-of-band update. Every patch release starts the clock in terms of copycat exploits.  This is the one of those dilemmas in the MSRC business. Naturally you want to ship an update as soon as it’s ready.   But when you ship an out-of-band update, many IT teams aren’t ready and this slows down how quickly systems are updated.  Attackers don’t hesitate to download the patch, diff it, and start building exploits, and defenders caught on their back foot may be at a disadvantage as they scramble to rearrange their schedule to deploy the update.  We considered. Can you hold until Patch Tuesday when IT teams around the world are ready to receive and act? Or do you ship early and disrupt customers?  The answer was clear. We had a critical vulnerability. We saw an uptick in activity. The patch was ready.  We went out-of-band.</span>
<h2><span style="color: #2e74b5;font-family: Calibri Light;font-size: large">Windows Update</span></h2>
<span style="font-family: Calibri;font-size: medium">We were rushing to extinguish a fire before it turned into an inferno and Windows Update was our fire hose. The engineers who built Windows Update made a phenomenal inoculation system. While all we observed were targeted attacks, we knew a worm could be released at any moment with hundreds of millions of vulnerable systems to use as oxygen.  MSRC used every megaphone it could to tell customers to patch.  In a week, Windows Update patched 400 million PCs and untold millions more behind corporate firewalls with WSUS. I can’t think of another system that can update 400 million of anything at a similar pace. Ask anyone about MS08-067 and most will mention Conficker.  At this point in October, Conficker did not even exist.  Conficker, as disruptive as it was, affected only the tail of computers that had not patched. Imagine what would have happened if Conficker had half a billion more systems to infect.</span>
<h2><span style="color: #2e74b5;font-family: Calibri Light;font-size: large">Exploit Reliability</span></h2>
<span style="font-family: Calibri;font-size: medium">The moment we went public, the attackers disappeared and I never saw them again.  I soon saw crashes from people rediscovering the vulnerability, from vulnerability scanners probing for vulnerable systems, and soon enough, from botnet exploits.  In the chart above, I show successes.  WER only sees failures so how did we know about successes? When the exploit was successful it would post a reply to a webserver.  Once the attack became public, security researchers from around the world wanted those logs and soon enough the logs were publicly available on the Internet, revealing the successful attacks. Correlating the successes with the failures we were able to conclude that we had found the exploit within its first 6 uses. The exploit was 95% reliable and our assumption that we were only seeing a shadow of real activity was correct. The decision to go out-of-band was the right one.</span>
<h2><span style="color: #2e74b5;font-family: Calibri Light;font-size: large">Final Thoughts</span></h2>
<span style="font-family: Calibri;font-size: medium">For me, MS08-067 will always be a special memory.  Security is often a slog and offense gets the headlines.  This story shows that defense can be just as creative and exciting.  The ingenuity in the hunt, the thrill of discovery, and the desire to protect customers gets in people’s blood and it’s the reason security is more often a tribe than a job. That’s the Defender’s Mindset.</span>

<span style="font-family: Calibri;font-size: medium">While I describe these events as a personal anecdote, pioneering exploit crash dump analysis would not have been possible without many incredible people, including: Fred Aaron, Jinwook Shin, Darren Canavor, Andrew Roths, Allen Jones, Matt Thomlinson, David Grant, Nicola Cowie, Mark Wodrich, Damian Hasse, Roberto Bamberger, Kinshuman Kinshumann, Steven Wort, Vince Orgovan, Matt Miller, Ken Johnson, Adam Zabrocki, John Banes, Chris Betz, and Kirk Glerum, who is widely considered the father of “Watson”. Many others were involved in the response and I apologize for not naming all of you.  To all our security partners and the security professionals at customers who worked this incident, you protected the world!</span>
<h2><span style="color: #2e74b5;font-family: Calibri Light;font-size: large">References</span></h2>
<span style="font-family: Calibri;font-size: medium">Debugging in the Very Large by Kirk Glerum et al., http://research.microsoft.com/apps/pubs/default.aspx?id=81176</span>

<span style="font-family: Calibri;font-size: medium">Security Bulletin for MS08-067, </span><span style="font-family: Calibri;font-size: medium"><a href="https://technet.microsoft.com/en-us/library/security/ms08-067.aspx">https://technet.microsoft.com/en-us/library/security/ms08-067.aspx</a></span>]]></content:encoded>
    </item>
    <item>
      <title>Defenders think in lists. Attackers think in graphs. As long as this is true, attackers win.</title>
      <link>https://docs.microsoft.com/archive/blogs/johnla/defenders-think-in-lists-attackers-think-in-graphs-as-long-as-this-is-true-attackers-win</link>
      <pubDate>Sun, 26 Apr 2015 08:03:00 GMT</pubDate>
      <dc:creator><![CDATA[John Lambert (MSTIC)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/johnla/2015/04/26/defenders-think-in-lists-attackers-think-in-graphs-as-long-as-this-is-true-attackers-win/</guid>
      <description><![CDATA[Defender Mindset
A lot of network defense goes wrong before any contact with an adversary, starting...]]></description>
      <content:encoded><![CDATA[<h2>Defender Mindset</h2>
A lot of network defense goes wrong before any contact with an adversary, starting with how defenders conceive of the battlefield. Most defenders focus on protecting their assets, prioritizing them, and sorting them by workload and business function. Defenders are awash in lists of assets—in system management services, in asset inventory databases, in BCDR spreadsheets. There's one problem with all of this. Defenders don't have a list of assets—they have a graph. Assets are connected to each other by security relationships. Attackers breach a network by landing somewhere in the graph using a technique such as spearphishing and they hack, finding vulnerable systems by navigating the graph. Who creates this graph? You do.
<h2>What Is the Graph?</h2>
The graph in your network is the set of security dependencies that create equivalence classes among your assets. The design of your network, the management of your network, the software and services used on your network, and the behavior of users on your network all influence this graph. Take a domain controller for example. Bob admins the DC from a workstation. If that workstation is not protected as much as the domain controller, the DC can be compromised. Any other account that is an admin on Bob's workstation can compromise Bob and the DC. Every one of those admins logs on to one or more other machines in the natural course of business. If attackers compromise any of them, they have a path to compromise the DC.
<h2>Six Degrees of Mallory</h2>
Attackers can lay in wait on a compromised machine, using a password dumper such as mimikatz until a high value account logs on to the machine. Let's examine an example graph.

<img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/04/69/metablogapi/042615_1503_Defendersth1.png" alt=" " />

<span style="color: #44546a;font-size: 9pt"><em>Figure 1 Example network logon graph </em></span>

The cluster on the left is single Terminal Server used by hundreds of users. If attackers compromise this machine, they can dump the credentials of many users over time.

<img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/04/69/metablogapi/042615_1503_Defendersth2.png" alt=" " />

<span style="color: #44546a;font-size: 9pt"><em>Figure 2 A compomised terminal server can lead to many credentials </em></span>

How can attackers move laterally to get to the High Value Asset?

<img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/04/69/metablogapi/042615_1503_Defendersth3.png" alt=" " />

<span style="color: #44546a;font-size: 9pt"><em>Figure 3 An attack path exists from compromising a terminal server to a high value asset </em></span>

By searching the graph, attackers discover multiple paths to the High Value Asset. Compromising the terminal server can allow attackers to also compromise User46 and User128. Those users are admins on Machine2821 and Machine115 respectively. Compromising those workstations allows attackers to compromise User1 and User34, both of which are admins on the High Value Asset. For the High Value Asset to be protected, all the dependent elements must be as protected as thoroughly as the HVA—forming an equivalence class.
<h2>Security Dependencies</h2>
In a Windows network, when users perform certain kinds of logons (Interactive, Terminal Server, and others), those users' credentials (and single-sign-on equivalents such as a Kerberos TGT or NTLM hash) are exposed to theft if the underlying host is compromised. Beyond this, there are many kinds of relationships that create security dependencies:
<ul>
	<li>Local admin accounts with a common password. Compromise one system, dump the local admin password, and use that password on other hosts with the same password.</li>
	<li>File servers housing logon scripts that run for many users and software update servers.</li>
	<li>Print servers that deliver print drivers to client machines when used.</li>
	<li>Certificate authorities that issue certificates valid for smart card logons.</li>
	<li>Database admins that can run code under the context of a database server running as a privileged user.</li>
</ul>
And so on. There are indirect relations as well. A machine that has a vulnerability can be compromised, suddenly allowing attackers to create new edges in the graph. Or users may have an account in two untrusted domains with the same password, creating a hidden edge between domains.
<h2>Manage your Graph</h2>
What can you do as a defender? The first step is to visualize your network by turning your lists into graphs. Next, implement controls to prune the graph:
<ul>
	<li>Examine unwanted edges that create huge connectivity bursts. Implement infrastructure partitioning and credential silos to reduce them.</li>
	<li>Reduce the number of admins. Use Just-In-Time / Just Enough techniques for privilege minimization.</li>
	<li>Use two factor authentication to mitigate certain edge traversals.</li>
	<li>Apply a solid credential rotation approach in case a user account is compromised.</li>
	<li>Rethink forest trust relationships.</li>
</ul>
<h2>Learn to Spot List Thinking</h2>
Defenders need to ensure that attackers don't have a leg up on them when visualizing the battlefield. In this contest, defenders can have the upper hand. They can have full information about their own network, whereas attackers need to study the network piece by piece. Defenders should take a lesson from how attackers come to understand the graph. Attackers study the infrastructure as it is—not as an inaccurate mental model, viewed from an incomplete asset inventory system, or a dated network diagram. Manage from reality because that's the prepared Defenders Mindset.
<h2>Further Reading</h2>
There are a number of papers about attack graphs. Here are a few:

Heat-ray: Combating Identity Snowball Attacks Using Machine Learning, Combinatorial Optimization and Attack Graph by J. Dunagan, D. Simon, and A. Zheng, http://alicezheng.org/papers/sosp2009-heatray-10pt.pdf

Two Formal Analyses of Attack Graphs by S. Jha, O. Sheyner and J. Wing, http://www.cs.cmu.edu/~scenariograph/jha-wing.pdf

Using Model Checking to Analyze Network Vulnerabilities by P. Ammann and R. Ritchey, http://cyberunited.com/wp-content/uploads/2013/03/Using-Model-Checking-to-Analyze-Network-Vulnerabilities.pdf

A Graph-Based System for Network-Vulnerability Analysis by C. Phillips and L. Swiler, http://web2.utc.edu/~djy471/CPSC4660/graph-vulnerability.pdf

Automated Generation and Analysis of Attack Graphs by J. Haines, S. Jha, R. Lippman, O. Sheyner, J. Wing, https://www.cs.cmu.edu/~scenariograph/sheyner-wing02.pdf

[And thanks to @4Dgifts for mentioning the two below]

Modern Intrusion Practices by Gerardo Richarte, https://www.blackhat.com/presentations/bh-usa-03/bh-us-03-richarte.pdf

Attack Planning in the Real World by Jorge Lucangeli Obes, Gerardo Richarte, Carlos Sarraute, http://arxiv.org/pdf/1306.4044.pdf]]></content:encoded>
    </item>
  </channel>
</rss>