<?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>An Autonomous Zone &#187; Uncategorized</title>
	<atom:link href="http://anautonomouszone.com/blog/archives/category/uncategorized/feed" rel="self" type="application/rss+xml" />
	<link>http://anautonomouszone.com/blog</link>
	<description>An autonomous zone to promote an exchange of ideas, skills, and experiences with computer (in)security.</description>
	<lastBuildDate>Thu, 09 Apr 2009 23:23:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Windows Messaging and Shatter Attacks</title>
		<link>http://anautonomouszone.com/blog/archives/21</link>
		<comments>http://anautonomouszone.com/blog/archives/21#comments</comments>
		<pubDate>Tue, 08 Jul 2008 20:50:35 +0000</pubDate>
		<dc:creator>Chuck B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anautonomouszone.com/blog/?p=21</guid>
		<description><![CDATA[I was chatting a while ago about Windows Messaging with someone and the pitfalls associated with it.
So – if one is unfamiliar with Windows Message Handling here’s a decent brush-up:
http://www.codeproject.com/KB/dialog/messagehandling3.aspx
BTW – the following is pretty much taken from toassa (like one of the best tech books ever written): http://taossa.com/
Essentially – Windows OS’s deliver messages to [...]]]></description>
			<content:encoded><![CDATA[<p>I was chatting a while ago about Windows Messaging with someone and the pitfalls associated with it.</p>
<p>So – if one is unfamiliar with Windows Message Handling here’s a decent brush-up:</p>
<p><a title="http://www.codeproject.com/KB/dialog/messagehandling3.aspx" href="http://www.codeproject.com/KB/dialog/messagehandling3.aspx">http://www.codeproject.com/KB/dialog/messagehandling3.aspx</a></p>
<p>BTW – the following is pretty much taken from toassa (like one of the best tech books ever written): <a title="http://taossa.com/" href="http://taossa.com/">http://taossa.com/</a></p>
<p><em>Essentially – Windows OS’s deliver messages to windows in a FIFO queue. Messages can be generated by system events like mouse movements or key presses. They can also be generated by other threads on the same desktop. Windows messages control most aspects of the UI, including clipboard operations and properties of a window.</em></p>
<p><em>There are 4 essential steps in creating a functional windowed application:</em></p>
<p><em>1. Creating a WindowProc() function to handle messages.<br />
2. Defining a class that associates this WindowProc() to a window type.<br />
3. Creating an instance of the Window class.<br />
4. Creating a message-processing loop.</em></p>
<p>Anyways, any process with a handle to a window station can send messages to any other window on a desktop object within that window station (any process can send a message to any other desktop object on the same desktop). All that’s needed is a SendMessage() function.</p>
<p>LRESULT SendMessage (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);</p>
<p>So this brings us to shatter attacks.</p>
<p><em>The Windows API ties a lot of functionality into a simple, unprotected, messaging architecture. Every aspect of the user interface is controlled by window messages, and the design of the API provides no method of restricting or verifying a message source.</em></p>
<p>The original shatter attack from 2002 &#8211; Chris Paget&#8217;s paper titled, &#8220;<a title="http://web.archive.org/web/20060115174629/http://security.tombom.co.uk/shatter.html" href="http://web.archive.org/web/20060115174629/http://security.tombom.co.uk/shatter.html">Exploiting design flaws in the Win32 API for privilege escalation</a>&#8220;) exploited window message design by sending a WM_PASTE message to a privileged process with a message pump on the same window station. The WM_PASTE message allows attackers to place a buffer of shell code in the address space of the privileged process. The attack is then completed by sending a WM_TIMER message that includes the address of the shell code buffer. The default handler for the WM_TIMER message simply accepts the address parameter as a function pointer, then runs the code that it points to. The result is a straightforward privilege escalation.</p>
<p>The immediate response to the shatter vulnerability was to simply filter the WM_TIMER message in any privileged process interacting with a user’s desktop. However, there are many other messages that allow manipulation of memory in a target process.</p>
<p>In 2004 Brett Moore had a talk at BlackHat about this:</p>
<p><a title="http://www.blackhat.com/presentations/bh-usa-04/bh-us-04-moore/bh-us-04-moore-up.ppt " href="http://www.blackhat.com/presentations/bh-usa-04/bh-us-04-moore/bh-us-04-moore-up.ppt ">http://www.blackhat.com/presentations/bh-usa-04/bh-us-04-moore/bh-us-04-moore-up.ppt </a></p>
<p>For instance, according to his <a title="http://www.blackhat.com/presentations/bh-usa-04/bh-us-04-moore/bh-us-04-moore-whitepaper.pdf" href="http://www.blackhat.com/presentations/bh-usa-04/bh-us-04-moore/bh-us-04-moore-whitepaper.pdf">whitepaper</a>: <em>Previous shatter attacks have been based on the use of messages that accept a pointer as a parameter. This pointer deirects execution flow to data that has been supplied by the attacer, therefore allowing the attacker to have a process execute code of their choice.</em></p>
<p><em>Several windows message will accept a pointer to a callback function as one of the parameters to the SendMessage API. One of these is LVM_SORTITEMS&#8230;</em></p>
<p>He also mentions messages like HDM_GETITEMRECT, <em>which accepts a pointer to a POINT or RECT structure which will be used to retrieve GDI information about windows. These pointers do not appear to be validated in any way&#8230;<br />
</em></p>
<p>Also &#8211; he has an exploit that demonstrates the use of Progress Control message shatter attacks and discusses other vulnerable messages that can come in handy to exploit.</p>
<p>As a matter of fact, he discovered a more recent vulnerability in a Symantec product using a Shatter Attack (Feb. 2008):</p>
<p><a title="http://www.securityfocus.com/bid/27645 " href="http://www.securityfocus.com/bid/27645 ">http://www.securityfocus.com/bid/27645 </a></p>
<p>For someone looking at the code of the program,  toassa summarizes the following steps to identify potential shatter attack exposures for a given service:</p>
<p><em>1. Check the MMC snap-in for the service to see whether it runs as the interactive user. Use MMC -&gt; open the Properties dialog box for the service -&gt; check the “Log On” tab to see whether the “Allow Service to Interact with Desktop” option is selected.</em></p>
<p><em>2. Examine the code to determine whether it manually attaches to the interactive user’s desktop.</em></p>
<p><em>3. If either case is true, determine whether a message pump is in operation for receiving window messages. If a message pump is in operation, you can consider the application to be at risk.</em></p>
<p>Also, according to my favorite reference &#8211; <a title="http://taossa.com/" href="http://taossa.com/">taossa</a>, certain COM applications can create background messages windows which can be vulnerable as well.</p>
<p>In Brett Moore’s Blackhat 2004 <a title="http://www.blackhat.com/presentations/bh-usa-04/bh-us-04-moore/bh-us-04-moore-up.ppt " href="http://www.blackhat.com/presentations/bh-usa-04/bh-us-04-moore/bh-us-04-moore-up.ppt ">preso</a> (which I also cited earlier) he also makes references to attacking thick applications on windows using shatter attacks – which will probably hit home a lot more for people who don&#8217;t do too much testing on traditional C/C++ programs.</p>
<p>Now Microsoft has done certain things to try to stop shatter attacks over the years – from Wikipedia “<em>In December 2002, Microsoft issued a patch for Windows NT 4.0, Windows 2000, and Windows XP that closed off some avenues of exploitation. This was only a partial solution, however, as the fix was limited to services included with Windows that could be exploited using this technique;</em>”</p>
<p>Also – they did some stuff with Vista using User Interface Privilege Isolation (UIPI).</p>
<p>So most of the vulnerable programs will be third-party applications.</p>
<p>Really – the most devastating scenario that I can think of – and probably the most common is someone with “normal” user privileges exploits a third-party program running as system over Terminal Servers. This would effectively give a normal, segregated user (Term. Services) control over the whole system (system privileges).</p>
<p>Chris Paget originally had these recommendations to solve the problem:</p>
<p><em>I can see two quick and dirty methods which will break a whole lotta functionality, and one very long-winded solution which is never going to be a total solution. Let me explain.</em></p>
<p><em>1. Don&#8217;t allow people to enumerate windows Nasty. Multiple breakages. Theoretically possible, but I&#8217;d hate to see people trying to work around not knowing what windows are on the desktop when they need to.</em></p>
<p><em>2. Don&#8217;t allow messages to pass between applications with different privileges Means that you couldn&#8217;t interact with any window on your desktop that&#8217;s not running as you; means that VirusScan at the very least (probably most personal firewalls, too) would need a whole lotta redesigning.</em></p>
<p><em>3. Add source info to messages, and depend on applications to decide whether or not to process the messages Would need an extension to the Win32 API, and a whole lotta work for people to use it. Big job, and people would still get it wrong. Look at buffer overflows &#8211; they&#8217;ve been around for years, and they&#8217;re still fairly common.</em></p>
<p>So what would someone do if they really wanted to build a safe (not vulnerable to shatter attacks) application that had a desktop GUI?</p>
<p>All would probably agree that it does make sense to run the application as one of least privilege and that might be a first thought – but that’s not always possible as some applications need to communicate to things on a privileged level and make certain system level  calls.</p>
<p>To someone that really, really cares about it &#8211; I might recommend the following as a solution to shatter attacks for an application (This is actually from Wikipedia – don’t laugh – but I think it makes sense):</p>
<p><em>…a two-process design where a process is loaded into the user&#8217;s session that interacts with the service process through inter-process communication. Additionally, when a privileged operation is required to be undertaken, an authenticated call is made that loads additional service code. Once that privileged code is finished doing what needs to be done, it is unloaded from memory so that it does not remain in memory to be a possible target for later exploitation.</em></p>
<p>So – essentially one would need to design the window interface with lower privileges and communicate through IPC to another, more higher privileged (server) process to make the calls that require higher privileges.</p>
<p>Brett Moore – in his 2004 whitepaper concludes with the following (after a lot of patches that Microsoft released in 2002 to protect some system applications that the OS’s shipped with):</p>
<p><em>The exploitation of shatter attacks have come a long way from when the original vulnerability was announced. As we have shown in this document, even the most obscure of messages can be used to make a process execute code that it was not intended to run.</em></p>
<p><em>While there have been discussions around the filtering of messages to protect interactive applications that run under a higher security context. It is becoming apparent that the only sure solution is to not have these applications running on an untrusted users desktop.</em></p>
<p><em>Application designers and system administrators need to be aware of the dangers associated with running higher privileged applications on a users desktop, and take steps to prevent them from been exploited. The examples included in this paper can be used against any interactive application that runs at a higher level, simply by specifying parameters such as the window title. Successful exploitation would allow a user to then execute commands under this higher-level security context.</em></p>
<p>So Brett says there’s not too much one can do either to prevent shatter attacks (but he didn’t mention the whole thing where we can split up the program into 2 different processes and have them communicate over IPC).</p>
<p>Of course &#8211; this is hard to do &#8211; especially when you think your application is not vulnerable because it doesn&#8217;t have any windowing GUI&#8217;s. According to his post <a title="http://archives.neohapsis.com/archives/ntbugtraq/2004-q4/0066.html" href="http://archives.neohapsis.com/archives/ntbugtraq/2004-q4/0066.html">here</a>,  he attacked an application that didn&#8217;t even have a window &#8211; well, not normally anyways:</p>
<p><em>We discovered that [Service X], that did not normally have a window, could<br />
be enticed into generating an error that would display a window. The<br />
service stored a pointer to a lookup table in the window memory pointed to<br />
by GWL_USERDATA. This lookup table held the address of functions, and was<br />
later used to retrieve an address and pass it to a CALL instruction.</em></p>
<p><em>By using the process mapped heap, as explained in my Blackhat presentation,<br />
it was possible to place our shellcode into a known location. We could also<br />
construct a new lookup table, pointing to our shellcode, in a known<br />
location.</em></p>
<p><em>Then by using SetWIndowLongPtr() API we replaced the pointer to the lookup<br />
table with the address of our new lookup table. The service would use our<br />
lookup table and execution would therefore reach the shellcode.</em></p>
<p><em></em>We should keep in mind as well – that it could be a whole different ballgame with Vista and Server 2008. Microsoft did a couple of things to try to fix the problem of shatter attacks (that’s a whole other post).</p>
<p>Although – I was just thinking a little while ago, how one could gain a name really quickly and some easy PR through this kind of research. Just find some programs that have a windowed desktop and that run with system level privilege – read up a little more about shatter attack stuff, then just publish a vulnerability like this: <a title="http://www.securityfocus.com/bid/27645" href="http://www.securityfocus.com/bid/27645">http://www.securityfocus.com/bid/27645</a>. I figure it’d be a good way to get one’s name in print – this particular one (also referenced above) was just released in Feb. 08.</p>
<p>Cheers,</p>
<p>Chuck B.</p>
]]></content:encoded>
			<wfw:commentRss>http://anautonomouszone.com/blog/archives/21/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Breach Misconceptions</title>
		<link>http://anautonomouszone.com/blog/archives/19</link>
		<comments>http://anautonomouszone.com/blog/archives/19#comments</comments>
		<pubDate>Mon, 07 Jul 2008 03:20:36 +0000</pubDate>
		<dc:creator>Chuck B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anautonomouszone.com/blog/?p=19</guid>
		<description><![CDATA[I came across an interesting blog post of security misconceptions from Errata Sec. a while ago:
http://erratasec.blogspot.com/2008/06/verizon-500-breach-report.html
Basically the data came from a report/study of 500 forensic investigations that Verizon released.
http://www.verizonbusiness.com/resources/security/databreachreport.pdf 
Personally – I think the security industry is chock-full of misconceptions of the what/how/why of hackers and breaches.
While this report is interesting – the biggest problem [...]]]></description>
			<content:encoded><![CDATA[<p>I came across an interesting blog post of security misconceptions from Errata Sec. a while ago:</p>
<p><a title="http://erratasec.blogspot.com/2008/06/verizon-500-breach-report.html" href="http://erratasec.blogspot.com/2008/06/verizon-500-breach-report.html">http://erratasec.blogspot.com/2008/06/verizon-500-breach-report.html</a></p>
<p>Basically the data came from a report/study of 500 forensic investigations that Verizon released.</p>
<p><a title="http://www.verizonbusiness.com/resources/security/databreachreport.pdf " href="http://www.verizonbusiness.com/resources/security/databreachreport.pdf ">http://www.verizonbusiness.com/resources/security/databreachreport.pdf </a></p>
<p>Personally – I think the security industry is chock-full of misconceptions of the what/how/why of hackers and breaches.</p>
<p>While this report is interesting – the biggest problem with this report is that it’s a study drawn from 500 forensic engagements handled by the Verizon Business Investigative Response Team, which means the information is gathered from breaches and forensics engagements of large organizations (people who can afford to pay for Verizon forensics services). What’s wrong with this one might ask?</p>
<p>Well – in my opinion – large organizations generally have a larger security budget than say small businesses and home users – which means large organizations generally have things like regular security testing (a lot of the times by law or regulation of some sort), patch-management policies, etc. and they don’t constitute the majority of “breaches.” Sure – they’re still getting hacked, otherwise there wouldn’t be a report like this – but the majority of systems that get compromised/hacked don’t belong to large organizations that have some sort of security entity (person or department) in charge of their systems, rather it’s the small businesses and home users, such as the non-tech savvy grandmas that click on cute and free animated screen saver links from emails and web sites that get compromised. These end users – the people who most likely get hacked aren’t represented here.</p>
<p>Much like trying to gather statistical information from the impact of Cross-Site Scripting (or any client side exploit – which is the most predominate type of exploit these days) – gathering information or statistics on the really vulnerable systems on the internet is almost impossible. These client side exploits generally affect home users, which – by the sheer number of home users it’s really hard to gather test cases. I’d even say that most of the people/systems that have been “hacked” aren’t even aware that they were compromised (like people who lend their system to a botnet).</p>
<p>The thing is – when end users of an organization get hacked, like in a Cross-Site Scripting or Microsoft Office exploit it is generally the lowest-hanging fruit and can have just as much impact as the organization servers getting hacked (confidential information, personal credit card data, etc. being stolen).</p>
<p>This is (again, imho) the way the majority of organizations/systems get compromised these days – and this report doesn’t really take this into account – again it’s very rare that forensics engagements deal with client side breaches.</p>
<p>This is one of the reasons I like to follow Dancho Danchev’s <a title="http://ddanchev.blogspot.com/" href="http://ddanchev.blogspot.com/">blog</a> – it’s a great peek into the latest and greatest what is “really going on” in the blackhat hacker market (motives, techniques, methodologies, etc.).</p>
<p>Here’s are some of the misconceptions that were talked about in the Errata sec. blog:</p>
<p><strong>Misconception:</strong> Hackers target their victims.<br />
<strong>Verizon data:</strong> 85% of attacks were &#8220;opportunistic&#8221;, the hackers didn&#8217;t know who their victims were until after they broke in.</p>
<p><strong>Misconception:</strong> Certified anti-virus products detect over 99% of all viruses.<br />
<strong>Verizon data:</strong> 25% of viruses/malware were customized to their victims and undetectable with standard anti-virus.</p>
<p><strong>Misconception:</strong> Hackers are smart, clever, geniuses, wizards, etc.<br />
<strong>Verizon data:</strong> 55% where of attacks required essentially no skills, the level of &#8220;script kiddies&#8221; running automated tools. Only 17% required &#8220;advanced&#8221; skills.</p>
<p><strong>Misconception:</strong> It&#8217;s the insider threat. No, wait, it&#8217;s outsiders. No, I mean, it&#8217;s the partners.<br />
<strong>Verizon data:</strong> 73% external, 18% internal, 39% partners. However, external breaches tended to be minor, whereas internal and partner breeches were major. Their numbers show that all three are important threats and that it&#8217;s hard to measure which one is worse.</p>
<p><strong>Misconception:</strong> Numbers are definitive.<br />
<strong>Verizon data: </strong>These numbers are bit subjective. For example, they notice that &#8220;physical breaches&#8221; were rare, but that&#8217;s because Verizon wouldn&#8217;t be called in to investigate a physical breach.</p>
<p><strong>Question:</strong> What are hackers after?<br />
<strong>Verizon data:</strong> Credit Card data (84%), Personal identity (32%), Username/passwords (15%)</p>
<p><strong>Question:</strong> How old are the vulnerability exploits hackers use?<br />
<strong>Verizon data:</strong> 71% older than 1-year, another 19% older than 6 months.</p>
<p>(&#8230;)<br />
Cheers,</p>
<p>Chuck B.</p>
]]></content:encoded>
			<wfw:commentRss>http://anautonomouszone.com/blog/archives/19/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IPC Pipe pitfalls, mistakes and solutions</title>
		<link>http://anautonomouszone.com/blog/archives/18</link>
		<comments>http://anautonomouszone.com/blog/archives/18#comments</comments>
		<pubDate>Mon, 07 Jul 2008 01:18:18 +0000</pubDate>
		<dc:creator>Chuck B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anautonomouszone.com/blog/?p=18</guid>
		<description><![CDATA[IPC Pipes (especially on Windows) are a pretty interesting topic for me because it has a lot to do with generic object and file security.
First, here’s the definition of a Pipe from msdn: http://msdn2.microsoft.com/en-us/library/aa365780(VS.85).aspx :
A pipe is a section of shared memory that processes use for communication. The process that creates a pipe is the [...]]]></description>
			<content:encoded><![CDATA[<p>IPC Pipes (especially on Windows) are a pretty interesting topic for me because it has a lot to do with generic object and file security.</p>
<p>First, here’s the definition of a Pipe from msdn: <a title="http://msdn.microsoft.com/en-us/library/aa365780(VS.85).aspx" href="http://msdn.microsoft.com/en-us/library/aa365780(VS.85).aspx">http://msdn2.microsoft.com/en-us/library/aa365780(VS.85).aspx</a> :</p>
<p>A pipe is a section of shared memory that processes use for communication. The process that creates a pipe is the pipe server. A process that connects to a pipe is a pipe client. One process writes information to the pipe, then the other process reads the information from the pipe. This overview describes how to create, manage, and use pipes.</p>
<p>And a little more here <a title="http://msdn.microsoft.com/en-us/library/aa365137(VS.85).aspx" href="http://msdn.microsoft.com/en-us/library/aa365137(VS.85).aspx">http://msdn2.microsoft.com/en-us/library/aa365137(VS.85).aspx</a> :</p>
<p>There are two types of pipes: anonymous pipes and named pipes. Anonymous pipes require less overhead than named pipes, but offer limited services.</p>
<p>The term pipe, as used here, implies that a pipe is used as an information conduit. Conceptually, a pipe has two ends. A one-way pipe allows the process at one end to write to the pipe, and allows the process at the other end to read from the pipe. A two-way (or duplex) pipe allows a process to read and write from its end of the pipe.</p>
<p>So to begin with all pipes are securable objects, so they have specific access rights associated with their DACL entries (much like files).</p>
<p>While looking into this topic a bit a while ago I came across this paper (Discovering and Exploiting Named Pipe Security Flaws for Fun and Profit):</p>
<p><a title="http://www.blakewatts.com/namedpipepaper.html" href="http://www.blakewatts.com/namedpipepaper.html">http://www.blakewatts.com/namedpipepaper.html</a></p>
<p>Here’s some highlights from the paper:<br />
<em><br />
A named pipe is a mechanism that enables interprocess communication for applications to communicate locally or remotely. The application that creates the pipe is known as the pipe server, and the application that connects to the pipe is known as the pipe client. Similar to sockets, after the server creates the named pipe, pipe clients may connect to the server. The function CreateNamedPipe provides the means to create the pipe. Clients use the CreateFile function to connect to the server-end of the named pipe. After the client and server have established a connection, they use the ReadFile and WriteFile functions to communicate.</em></p>
<p><em>The way in which named pipes are created and connected to is conceptually identical to how files are created on a file system&#8211;that&#8217;s no coincidence. Internally, named pipes are implemented as a file system (more on this later). The &#8220;file location&#8221; of creating and connecting to a pipe follows a standard naming convention. This effectively ensures that the creation and connection requests of pipes are internally routed correctly. That convention is as follows: \\.\pipe\pipename. The \\.\ segment is used to route the creation and connection of the pipe to the appropriate file system. The period in the \\.\ segment may be replaced with a remote system name. This enables the associated function to be invoked remotely.<br />
</em><br />
So the above is just a bit about how pipes work and all that. But we probably need this interesting background info as well before we can really talk a lot about vulnerabilities with pipes – “Named Pipe Impersonation”:</p>
<p><em>Impersonation is the process of a pipe server temporarily assuming the security context of the client of its pipe. Pipe servers impersonate their client&#8217;s security context by calling the function ImpersonateNamedPipeClient. The requirements of impersonation are that a client connects to the pipe server and writes some data to it. After the pipe server reads the data from the client, its call to ImpesonateNamedPipeClient will succeed, and it is granted an &#8216;impersonation&#8217; token of the client. The requirement of reading data from the pipe can be bypassed, and is discussed in the &#8216;File System Vulnerabilities&#8217; section.</em></p>
<p><em>Some readers may be wondering as to why in the world would impersonation exist in an interprocess communication mechanism. Impersonation and IPC, implemented properly, can actually lead to better-designed software architecture. In its conception, it was created so that privileged subsystems and services could temporally lower their own security context while processing the requests of its clients. However, if implemented improperly malicious applications can attain full control of the system.</em></p>
<p>So this is really interesting because it leaves room for client attacks:</p>
<p><em>When a client connects to the server-end of a named pipe it may unknowingly be giving the server-end of the pipe the ability to perform any task on their behalf&#8211;by impersonating their security context. Clients can control their impersonation &#8220;level&#8221; by specifying specific flags in their CreateFile call (which is used for connecting the client to the server pipe), however is seldom performed. This process is formally known as setting the security quality of service. So the question on most readers mind is, &#8220;What if the server isn&#8217;t started, or has crashed?&#8221; Well, the answer is very simple. Their security context is up for grabs. Any security context (interactive user, service, etc.) may create the pipe that the client is looking for and assume their security context. This vulnerability classification is known as Superfluous Pipe Connectivity.<br />
</em><br />
This is really interesting because through named pipe impersonation one can gain the privilege level of the client (if the client didn’t specify an impersonation level in the call to CreateFile() when creating the pipe).</p>
<p>Of course, we’re keeping in mind that “client” doesn’t always mean “lower privileged process.”</p>
<p>This type of attack lead to this (system privilege level) vulnerability (it’s actually a combination of client pipe and pipe namesquating):</p>
<p>Service Control Manager Named Pipe Impersonation Vulnerability (http://www.microsoft.com/technet/security/Bulletin/MS00-053.mspx)</p>
<p>There’s also vulnerabilities that were discovered like these:</p>
<p>http://secunia.com/advisories/9229/ (SQL Server Named Pipe Privilege Escalation Vulnerability)<br />
http://www.microsoft.com/technet/security/Bulletin/MS01-031.mspx (Telnet Server Named Pipe Privilege Escalation Vulnerability)</p>
<p>The paper also says this:<br />
<em><br />
Coaxing an application or service into connecting to a pipe is usually trivial in most situations. For instance, when starting a service, the service will typically connect to another service&#8217;s named pipe. A monitoring tool, such as Security Internals&#8217; Pipe Security Explorer, will yield all the named pipes that an application or service connects to. It is probable that some pipes will not exist. If a client application attempts to connect to a server pipe without verifying that the server is running and has created the corresponding named pipe, it&#8217;s possible that at some point in time the client&#8217;s security context may be usurped by a malicious application.</em></p>
<p>Cheers,</p>
<p>Chuck B.</p>
]]></content:encoded>
			<wfw:commentRss>http://anautonomouszone.com/blog/archives/18/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Weak Permissions and Dangerous Signals and Stuff</title>
		<link>http://anautonomouszone.com/blog/archives/17</link>
		<comments>http://anautonomouszone.com/blog/archives/17#comments</comments>
		<pubDate>Mon, 07 Jul 2008 00:56:54 +0000</pubDate>
		<dc:creator>Chuck B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anautonomouszone.com/blog/?p=17</guid>
		<description><![CDATA[So I think this a really cool blog entry by the Windows master Mark Russinovich: “The Case of the Insecure Security Software”.
In short it discusses a tool he wrote called AccessChk which helps identify weak permissions problems. Apparently he had received some requests from groups within Microsoft and elsewhere to extend its coverage of securable [...]]]></description>
			<content:encoded><![CDATA[<p>So I think this a really cool blog entry by the Windows master Mark Russinovich: “<a title="http://blogs.technet.com/markrussinovich/archive/2007/06/19/1256677.aspx" href="http://blogs.technet.com/markrussinovich/archive/2007/06/19/1256677.aspx">The Case of the Insecure Security Software</a>”.</p>
<p>In short it discusses a tool he wrote called AccessChk which helps identify weak permissions problems. Apparently he had received some requests from groups within Microsoft and elsewhere to extend its coverage of securable objects analyzed to include the Object Manager namespace (which stores named mutexes, semaphores and memory-mapped files), the Service Control Manager, and named pipes.</p>
<p>After he had revised AccessChk he ran the tool on his box to see what system-global objects the Everyone and Users groups can modify.</p>
<p>As he states: <em>The ability to change those objects almost always indicates the ability for unprivileged users to compromise other accounts, elevate to system or administrative privilege, or prevent services or programs run by the system or other users from functioning. For example, if an unprivileged user can change an executable in the %programfiles% directory they might be able to cause another user to execute their code. Some applications include Windows services, so if a user could change the service executable they could obtain system privileges.</em></p>
<p>He also played with write access from the Authenticated Users and Users groups on different namespaces. According to the blog:</p>
<p><em>An output line, which looks like “RW C:\Program Files\Vendor”, reveals a probable security flaw.<br />
To my surprise and dismay, I found security holes in several namespaces. The security settings on one application’s global synchronization and memory mapping objects, as well as on its installation directory, allow unprivileged users to effectively shut off the application, corrupt its configuration files, and replace its executables to elevate to Local System privileges. What application has such grossly insecure permissions? Ironically, that of a top-tier security vendor.<br />
For instance, AccessChk showed output that indicated the Users group has write access to the application’s configuration directory (note that names have been changed):<br />
RW C:\Program Files\SecurityVendor\Config\<br />
RW C:\Program Files\ SecurityVendor\Config\scanmaster.db<br />
RW C:\Program Files\ SecurityVendor\Config\realtimemaster.db</em><br />
…<br />
<em>Because Malware would run in the Users group, it could modify the configuration data or create its own version and prevent the security software from changing it. It could also watch for dynamic updates to the files and reset their contents.<br />
For the object namespace, it reported output lines like this:<br />
RW [Section]    \basenamedobjects\12345678-abcd-1234-cdef-123456789abc<br />
RW [Mutant]     \basenamedobjects\87654321-cdab-3124-efcd-6789abc12345</em><br />
…<br />
He also states:</p>
<p><em>In the wake of my discovery, I analyzed the rest of my systems, as well as trial versions of other popular security, game, ISP and consumer applications. A number of the most popular in each category had problems similar to those of the security software installed on my development system. I felt like I was shining a flashlight under a house and finding rotten beams where I had assumed there was a sturdy foundation.<br />
</em><br />
Then he kind of hit the nail on the head:</p>
<p><em>The security research community has focused its efforts uncovering local elevations via buffer overflows and unverified parameters, but has completely overlooked these obvious problems – problems often caused by the software of security ISVs, or in some cases, their own.</em></p>
<p>Now, while I’m sure that the security research hasn’t “completely overlooked these obvious problems” I would bet that it’s an area that could garnish some nice results with a bit of looking into.</p>
<p>Through the process of reading “<a title="http://taossa.com/" href="http://taossa.com/">The Art of Software Security Assessment</a>” I came across a few really cool problems in software similar to this. I had heard of some of these problems before, but I hadn’t gotten into too much detail concerning them.</p>
<p>There are chapters in the book that go into a bit of detail on issues like this that provide a really good fundamental understanding of similar problems:</p>
<p>Chapter 11: Windows I: Objects and the File System<br />
Chapter 12: Windows II: Interprocess Communication</p>
<p>Another cool chapter / subject is Chapter 13:  Synchronization and State. It talks about Reentrancy (Reentrancy refers to a function’s capacity to work correctly, even when it’s interrupted by another running thread that calls the same function), Asynchronous-Safe Code, Signals and other things.</p>
<p>Most pentesters know about buffer/heap overflows, integer overflows, off-by-ones, race conditions, and similar common exploitable vulnerabilities, but what about using Signals to escalate privilege or cause a double free() in code that is not asynchronous-safe?</p>
<p>Here is a great paper by Michael Zalewski “<a title="http://lcamtuf.coredump.cx/signals.txt" href="http://lcamtuf.coredump.cx/signals.txt">Delivering Signals for Fun and Profit</a>” that talks about this:</p>
<p>From the paper:</p>
<p><em>Below is a sample &#8216;vulnerable program&#8217; code:</em></p>
<p><em>&#8212; vuln.c &#8212;<br />
#include &lt;signal.h&gt;<br />
#include &lt;syslog.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;stdlib.h&gt;</em></p>
<p><em>void *global1, *global2;<br />
char *what;</em></p>
<p><em>void sh(int dummy) {<br />
syslog(LOG_NOTICE,&#8221;%s\n&#8221;,what);<br />
free(global2);<br />
free(global1);<br />
sleep(10);<br />
exit(0);<br />
}</em></p>
<p><em>int main(int argc,char* argv[]) {<br />
what=argv[1];<br />
global1=strdup(argv[2]);<br />
global2=malloc(340);<br />
signal(SIGHUP,sh);<br />
signal(SIGTERM,sh);<br />
sleep(10);<br />
exit(0);<br />
}<br />
&#8212;- EOF &#8212;-</em></p>
<p><em>You can exploit it, forcing free() to be called on a memory region filled with 0&#215;41414141 (you can see this value in the registers at the time of crash &#8211; the bytes represented as 41 in hex are set by the &#8216;A&#8217; input characters in the variable $LOG below). Sample command lines for a Bash shell are:</em></p>
<p><em>$ gcc vuln.c -o vuln<br />
$ PAD=`perl -e &#8216;{print &#8220;x&#8221;x410}&#8217;`<br />
$ LOG=`perl -e &#8216;{print &#8220;A&#8221;x100}&#8217;`<br />
$ ./vuln $LOG $PAD &amp; sleep 1; killall -HUP vuln; sleep 1; killall -TERM vuln</em></p>
<p><em>The result should be a segmentation fault followed by nice core dump (for Linux glibc 2.1.9x and 2.0.7).<br />
(gdb) back</em></p>
<p><em>#0  chunk_free (ar_ptr=0&#215;4013dce0, p=0&#215;80499a0) at malloc.c:3069<br />
#1  0&#215;4009b334 in __libc_free (mem=0&#215;80499a8) at malloc.c:3043<br />
#2  0&#215;80485b8 in sh ()<br />
#4  0&#215;400d5971 in __libc_nanosleep () from /lib/libc.so.6<br />
#5  0&#215;400d5801 in __sleep (seconds=10) at ../sysdeps/unix/sysv/linux/sleep.c:85<br />
#6  0&#215;80485d6 in sh ()</em></p>
<p><em>So, as you can see, failure was caused when signal handler was re-entered. __libf_free function was called with a parameter of 0&#215;080499a8, which points somewhere in the middle of our AAAs:</em></p>
<p><em>(gdb) x/s 0&#215;80499a8<br />
0&#215;80499a8:       &#8216;A&#8217; &lt;repeats 94 times&gt;, &#8220;\n&#8221;</em></p>
<p><em>You can find 0&#215;41414141 in the registers, as well, showing this data is being processed. For more analysis, please refer to the paper mentioned above.</em></p>
<p><em>For the description, impact and fix information on Sendmail signal handling vulnerability, please refer to the RAZOR advisory at: adv_sm8120.</em></p>
<p><em>Obviously, that is just an example of this attack. Whenever signal handler execution is non-atomic, attacks of this kind are possible by re-entering the handler when it is in the middle of performing non-reentrant operations. Heap damage is the most obvious vector of attack, in this case, but not the only one.</em></p>
<p>Anyways, none of this stuff is new, but it’s food for thought for anyone who wasn’t really familiar with these type of vulnerabilities.</p>
<p>Cheers,</p>
<p>Chuck B.</p>
]]></content:encoded>
			<wfw:commentRss>http://anautonomouszone.com/blog/archives/17/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Anyone interested in finding bugs?</title>
		<link>http://anautonomouszone.com/blog/archives/15</link>
		<comments>http://anautonomouszone.com/blog/archives/15#comments</comments>
		<pubDate>Sun, 06 Jul 2008 20:50:25 +0000</pubDate>
		<dc:creator>Chuck B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://anautonomouszone.com/blog/?p=15</guid>
		<description><![CDATA[So I’ve written a couple of posts about some fuzzing methodologies, mods to tools, etc. Basically they kind of went over the fact that at the moment I’m into fuzzing compressed binary files like zip, cab, rar, etc. and my thoughts on how I’m going about doing it.
For the last little while I’ve been looking [...]]]></description>
			<content:encoded><![CDATA[<p>So I’ve written a couple of posts about some fuzzing methodologies, mods to tools, etc. Basically they kind of went over the fact that at the moment I’m into fuzzing compressed binary files like zip, cab, rar, etc. and my thoughts on how I’m going about doing it.</p>
<p>For the last little while I’ve been looking into decent ways to fuzz things like how to generate “smart” data sets to fuzz with and how to automate the fuzzing process along with decent ways to monitor and log exceptions/signals.</p>
<p>At this point, I pretty much have a system down. I’ve modified a few fuzzers like Autodafe and Filefuzz to get them to generate (at least what I think is) more meaningful test cases to fuzz with. So now the bulk of the time is usually spent in tearing apart binary file formats in order to perform intelligent block-based fuzzing (which isn’t usually that hard – one can usually find documentation and a breakdown of the format somewhere like wotsit.org or use templates from 010 editor or even in the docs of the program you’re fuzzing). It’s useful to do this for things like knowing where potential trouble areas would be – like a length field or generally breaking down the structures of a binary format for things like knowing when to perform a CRC32 checksum on a structure to get more code coverage in the binary when fuzzing so it doesn’t just fail a checksum and exit – things like that. A smaller portion of the time is pretty much just generating the files using some fuzzers then firing them off. Lastly – there is the fun part of looking over the results when any exceptions are logged / generated and confirming anything found (usually in a debugger).</p>
<p>So I’m thinking that it might be lucrative if I start looking into media format things. I’m thinking files like avi, bmp, tiff (one’s gotta have love for those iphone/safari tiff vulns. out there), pm3, jpg, png, wav, wmf, wmx, mpeg, mpa, midi, rmi, cda, ivf, divx, mov, rm, rts, qt, swf, etc. There are *tons* of different media formats out there and *tons* of different applications that open them (including media players, browsers, plug-ins, etc.).</p>
<p>As I’m going through the motions with this I’m thinking to myself “Self – it would be really cool if a few other cats were in on this – we could get a system going and just pump out a lot of tests, more testing = more potential bugs to be found.”</p>
<p>And so, finally the whole point to my post: if anyone is interested in helping out to find some 0-days it would be really cool. If anyone is interested but doesn’t have much experience with fuzzing (but is willing to learn how to do it) I will be totally down in explaining everything I know about it and where to find the material that I read to learn about it (so that whomever else is interested in learning about it can read it as well). If anyone else is interested in fuzzing stuff to find bugs and they have some experience then I’d really like to hear how they went about it – two (or more) heads are always better than one.</p>
<p>Like I said – I pretty much have a system down and some tools written – it would just be cool to have some extra hands and ideas in the mix.</p>
<p>Interested persons – just hit me up.</p>
<p>anautonomouszone [at] gmail [dot] com</p>
<p>Cheers,</p>
<p>Chuck B.</p>
]]></content:encoded>
			<wfw:commentRss>http://anautonomouszone.com/blog/archives/15/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

