<?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>Neohaxor.org &#187; Dynamic CSRF</title>
	<atom:link href="http://www.neohaxor.org/tag/dynamic-csrf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.neohaxor.org</link>
	<description>InfoSec / Critical Thinking / Misc Crap</description>
	<lastBuildDate>Thu, 21 Oct 2010 16:33:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>MonkeyFist Fu: The Intro</title>
		<link>http://www.neohaxor.org/2009/08/12/monkeyfist-fu-the-intro/</link>
		<comments>http://www.neohaxor.org/2009/08/12/monkeyfist-fu-the-intro/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 18:14:27 +0000</pubDate>
		<dc:creator>Nathan Hamiel</dc:creator>
				<category><![CDATA[Application Security]]></category>
		<category><![CDATA[Bypassing CSRF Protections]]></category>
		<category><![CDATA[Cross Site Request Forgery]]></category>
		<category><![CDATA[Dynamic CSRF]]></category>
		<category><![CDATA[MonkeyFist]]></category>

		<guid isPermaLink="false">http://www.neohaxor.org/?p=184</guid>
		<description><![CDATA[MonkeyFist is a dynamic request attack tool. It allows you to do some interesting things with various forms of cross-site requests and play them back to the user’s browser. These requests may contain session information bypassing Cross-Site Request Forgery protection mechanisms. It’s really a lot more simple than it seems. MonkeyFist is basically a small [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2607/3814323619_7a1f60ee5e_o.png" alt="MonkeyFist Image" /></p>
<p>MonkeyFist is a dynamic request attack tool. It allows you to do some interesting things with various forms of cross-site requests and play them back to the user’s browser. These requests may contain session information bypassing Cross-Site Request Forgery protection mechanisms. It’s really a lot more simple than it seems.</p>
<p>MonkeyFist is basically a small web server that performs some attacks on the data it receives based on information you provide in the payloads.xml file. To do a deeper dive in to the issues that MonkeyFist exploits you can refer to the white paper we wrote prior to Black Hat on Dynamic CSRF located on the docs page of Hexsec <a href="http://hexsec.com/docs">http://hexsec.com/docs</a></p>
<p>The best way to get familiar with MonkeyFist is just to dive right in. If you haven’t done so, you can go here to download it from the Hexsec Labs page <a href="http://hexsec.com/labs">http://hexsec.com/labs</a></p>
<p>MonkeyFist requires you be intimately familiar with the request you want to forge. This should be painfully obvious because you need to tell the tool how to construct the request in order for it to be successful.</p>
<h3>The Files</h3>
<p>There isn’t much to MonkeyFist, all of the files are pretty small. There are a few items in the zip file, but you really only need to worry about MonkeyFist.py and payloads.xml. All of the configuration for payloads in MonkeyFist is done through payloads.xml. We will get in to syntax in another post. In case you didn’t notice the .py extension, MonkeyFist is written in Python. So if your operating system doesn’t have Python installed (Probably just Windows systems) you are going to need it. I suggest version 2.5 or greater. The version that comes with most Linux distributions and OSX is fine. As a final note about the files, ensure that you run MonkeyFist from the same directory as the other files that come with it. Otherwise, it won’t know where they are located <img src='http://www.neohaxor.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>Dependencies</h3>
<p>In the beginning there were no further dependencies but I a saw it was necessary to potentially need to do some more complex parsing for the fixation payload. For that reason I decided to add <a href="http://codespeak.net/lxml">lxml</a>. I could have gotten away with a more simple parser, but was trying to think ahead a bit. To use the Fixation payload you are going to need to install a 2.x version of lxml. This would be different depending on your operating system. If you are using Ubuntu / Debian don&#8217;t just to to apt install lxml, it will give you an old version. Python setuptools helps a lot, it&#8217;s just a good idea to use that anyway.</p>
<p>For OSX Leopard (Make sure you have the development tools installed) I just ran:</p>
<pre><span style="color: #3366ff;">sudo easy_install lxml</span></pre>
<p>For Ubuntu you have to take a few other steps because you need a few dependencies and the development headers for Python.</p>
<p>If you don’t have setuptools installed:</p>
<pre><span style="color: #3366ff;">sudo apt-get install python-setuptools</span></pre>
<p>Then you need to apt-get install the following if you do not have them installed:<br />
libxml2-dev<br />
libxslt1-dev<br />
python2.5-dev</p>
<p>After that you can go ahead and:</p>
<pre><span style="color: #3366ff;">sudo easy_install lxml</span></pre>
<p>If you have build problems you probably don’t have the build tools installed:</p>
<pre><span style="color: #3366ff;">sudo apt-get install build-essential</span></pre>
<p>Then run easy_install again.</p>
<p>If you decide not to run lxml or do not have the ability to install it, the tool will still run you just won’t be able to use the Fixation handler without a nice failure and error message <img src='http://www.neohaxor.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Payload Types</h3>
<p>There are several types of payloads you can construct with MonkeyFist. Each of these would depend on what the goal of the attack would be or the type of content on a site you would have control over. The basic payload types are dynamic redirect, POST construct, dynamic page, and fixation.</p>
<h3>Dynamic Redirect</h3>
<p>The dynamic redirect payload simply parses any cross-domain information looking for session data to dynamically construct in to a GET based payload to send back to the user’s browser. Basically, the user would request something and the tool would respond with a 302 redirect to a location. The location value would be the constructed payload. The user’s browser would just request content like normal and follow the redirect and execute the payload.</p>
<p>This payload type is best used in instances where you have the ability to add images tags or other HTML to a site. This way it could be relatively hidden from a user’s browser.</p>
<h3>Dynamic Page</h3>
<p>This payload constructs a page that performs several functions depending on what type of attack you are performing. You can either have the page perform a GET or a POST for an attack. Both the GET and POST types will be submitted by the user’s browser. So what does the page do? The attack that you construct gets embedded in the page and after the attack happens the user is immediately redirected to a location of your choice. So you could perform an attack and immediately send someone to the Benny Lava video <img src='http://www.neohaxor.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  This could be combined with an URL shortener for further obfuscation.</p>
<p>This payload is best used in instances where you have the ability to embed hyperlinks to pages. Another thing to note about the dynamic page payload is that it makes POST based CSRF a whole lot easier to pull off. If you thought submitted data as a POST was a protection mechanism for CSRF you might want to rethink you point of view <img src='http://www.neohaxor.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>POST Construct</h3>
<p>This payload is a bit different because the POST request is made by the tool and not the user’s browser. This needs to be kept in mind when using it. You will not have the advantage of the browser being helpful and submitting header information. If the cross-domain leakage is enough that you can perform an entire POST request without the user’s browser then this payload can be used. Otherwise, it will be pretty useless to you <img src='http://www.neohaxor.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Fixation</h3>
<p>The fixation payload allows you to make a request for data that you fixate on to the attack you send to the user. This is still experimental and only works in some narrow situations. This will be expanded later. This works as a modified page payload that performs and extra request and parses the response and gains the necessary information to perform the attack. This would be commonly used to make a request for tokens that you can fixate on to a request forged by the user&#8217;s browser.</p>
<h3>Default Payload</h3>
<p>The default payload gets matched when there is no cross-domain information for the tool to match with your entries in the payloads.xml file. It’s best to not perform an attack with this <img src='http://www.neohaxor.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  The best thing to do is to make this a link to some real content like an image. This can make the tool a bit more stealthy.</p>
<p>You need to specify a default payload. Not doing so would be like crossing the streams. Well maybe not that bad, but it wouldn’t be good.</p>
<h3>MonkeyFist Running Options</h3>
<p>There are only a couple of running options with MF and well, all of them do not work as of yet. So, the main one you need to be familiar with is -s. This is the standard attack mode. The -p option specifies the port you would like MF to run on. You won’t need privileged access unless you are trying to run on a low order port. The following would run MonkeyFist on port 8080 using standard attack mode:</p>
<pre><span style="color: #3366ff;">./MonkeyFist -p 8080 -s</span></pre>
<p>You can get the about information by running -a, just in case you were curious about what version you are running.</p>
<pre><span style="color: #3366ff;">./MonkeyFist -a</span></pre>
<p>Of course, if you need some reference there is always the ole’ help with -h</p>
<pre><span style="color: #3366ff;">./MonkeyFist -h</span></pre>
<p>There are a couple of other options that are planned for the future. A testing mode and a random mode will be added as well, but currently, they are not implemented.</p>
<h3>Payloads</h3>
<p>The payloads.xml file is where you define your attacks. This is where all of your work will be done. The exact options that are specified in this file are still being worked out. This is because as content goes, there needs to be flexibility when identifying these issues. There is a basic set of options that allow you to pull of some attacks even as MonkeyFist sits at version 0.4. Expect some changes in these options. The payloads.xml file will be covered in more detail in a future post.</p>
<h3>The Others</h3>
<p>You will notice a few other files in the MonkeyFist zip file. You might not want to delete them or you may have some unintended consequences. The page2.html file is blank, but it won’t be if you pull off any Page attacks. Contents are put in to this file dynamically and change per attack. Markup.py is something I didn’t write, it just allowed me to quickly generate some HTML. This was before I made the decision to use lxml. For now I am going to leave it in there, even though it is not the best option. FistLib.py is the most important. This is the workhorse that takes care of all the work.</p>
<h3>In Closing</h3>
<p>I think that’s it for a small intro on MonkeyFist. In future posts I will explain more about the payloads and how they are constructed. If you notice any problems while running MF please let me know. You can send an email to monkeyfist {at} hexsec {dot} com. This is still a work in progress so please don’t beat me up too bad. I do welcome your feedback though. Thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neohaxor.org/2009/08/12/monkeyfist-fu-the-intro/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Dynamic Cross-Site Request Forgery (CSRF)</title>
		<link>http://www.neohaxor.org/2009/08/11/dynamic-cross-site-request-forgery/</link>
		<comments>http://www.neohaxor.org/2009/08/11/dynamic-cross-site-request-forgery/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 20:57:49 +0000</pubDate>
		<dc:creator>Nathan Hamiel</dc:creator>
				<category><![CDATA[Application Security]]></category>
		<category><![CDATA[Bypassing CSRF Protections]]></category>
		<category><![CDATA[Cross Site Request Forgery]]></category>
		<category><![CDATA[CSRF]]></category>
		<category><![CDATA[Dynamic CSRF]]></category>
		<category><![CDATA[Token Fixation]]></category>
		<category><![CDATA[Weaponizing the Web]]></category>

		<guid isPermaLink="false">http://www.neohaxor.org/?p=154</guid>
		<description><![CDATA[Bypassing CSRF Protections With Dynamic CSRF At our presentation at Black Hat and Defcon this year, Shawn Moyer and I gave a talk called Weaponizing the Web: More Attacks on User Generated Content. During the talk we discussed something we are calling Dynamic Cross-Site Request Forgery (CSRF). Dynamic CSRF methods can be used to create [...]]]></description>
			<content:encoded><![CDATA[<h3 style="font-size: 1.17em;">Bypassing CSRF Protections With Dynamic CSRF</h3>
<p>At our presentation at <a href="http://www.blackhat.com">Black Hat</a> and <a href="http://defcon.org">Defcon</a> this year, Shawn Moyer and I gave a talk called <a href="http://hexsec.com/docs/WeaponizingTheWeb_BHUS09.pdf/view">Weaponizing the Web: More Attacks on User Generated Content</a>. During the talk we discussed something we are calling Dynamic Cross-Site Request Forgery (CSRF). Dynamic CSRF methods can be used to create new attack vectors and compromise CSRF protection mechanisms. CSRF is often difficult to explain in the first place, so I just wanted to do a post about it and link our <a href="http://hexsec.com/docs/Dynamic_CSRF_rev1.pdf/view">Dynamic CSRF White Paper</a>.</p>
<h3>Static CSRF Attacks</h3>
<p>The current way people are exploiting CSRF issues is pretty static. A link may be crafted and people are tricked in to clicking on it or viewing a page with this link embedded. They may even do something such as create an auto-submitting POST that the user executes when visiting certain content. The moral is that someone crafts this attack for a specific location and chooses a vector for delivering it to users. On it&#8217;s own, this static CSRF attack method can be pretty devastating or perhaps totally innocuous. That&#8217;s just the nature of CSRF. There aren’t too many vulnerabilities that fall in to this category, which may be why it can sometimes be hard to understand.</p>
<p>Let&#8217;s just think about some things that would make CSRF even more dangerous. What if we had visibility in to CSRF tokens or even session identifiers? What if we knew for sure a user was on the site that we wanted to attack? What if we could use a central point to dynamically attack multiple sites? What if we could create a custom payload on the fly to include tokens and session data? What if we could request data in another process and fixate it on to a request that the user executes? CSRF would become much more dangerous. Well, it just did&#8230;.</p>
<h3>Dynamic CSRF Attacks</h3>
<p>With Dynamic CSRF attacks the game changes a bit. Attacks can be adapted based on where requests are originating from. Sensitive information sent in a cross-domain fashion can be packaged in to a customized payload and sent to a location. Disjoined or bolted on components can be queried and fixated on to a user&#8217;s request. This opens up new opportunities for attacks. Dynamic CSRF allows you to run one central system and run attacks for multiple sites and applications with the ability to remove and repackage any leaked session information.</p>
<p><img src="http://farm3.static.flickr.com/2460/3767576054_4cbb0efecb_o.png" alt="Dynamic CSRF" /></p>
<p>Using dynamic methods may allow for the bypass of CSRF protections. Whether these protections are leaked in the referer or if they can be requested by other means and fixated on to the request, bypassing may be possible. This makes requests that were previously not vulnerable to CSRF vulnerable again.</p>
<p>When not limited by static requests a few new attack vectors open up. I just wanted to highlight a couple here.</p>
<h3>Getting Dynamic</h3>
<p>In the next couple of sections I am going to point out some dynamic methods for bypassing CSRF protection mechanisms.</p>
<h4><strong>HTTP Redirect</strong></h4>
<p>A simple redirect attack can be made more devastating with the addition of session related data added to the request. So a user hits a piece of HTML on a web page that sends a GET request containing session data (Session IDs, CSRF Tokens, etc) in the referer. This session data can be taken from the referer and repackaged in to a payload that is sent to the users browser as a location for a 302 redirect.</p>
<p><img src="http://farm4.static.flickr.com/3439/3767576354_0b2e519456_o.png" alt="HTTP Redirect" /></p>
<p>A scenario for this type of attack might be embedding a hidden image tag that links to a location offsite. This image tag may leak session data through referer allowing a tool to repackage that session data and get the user&#8217;s browser to execute it as a payload. This could be used to bypass CSRF protections by using the CSRF tokens from the referer.</p>
<h4><strong>HTML-based Redirect</strong></h4>
<p>For this scenario a hyperlink could point to a page that is created dynamically per-each request. This page contains a hidden GET or POST that could contain session data taken from referer as mentioned previously in the HTTP Redirect. The page would then refresh to a legitimate destination. To a user there would only appear to be a short pause prior to their landing on the legitimate destination, but in the background an attack has happened.</p>
<p>This attack could be made more interesting with URL shortening services. People have become accustomed to URL shorteners due to their use of Twitter and other social networks. Using a URL shortener would mask the location of the dynamic page and may not raise further suspicion.</p>
<p><img src="http://farm4.static.flickr.com/3535/3766778455_4458f654f6_o.png" alt="HTML-based Redirect" /></p>
<p>A scenario for this would be posting a link that is shortened with a URL shortener on a web site that supposedly links to a video on YouTube. When the user clicks the link a hidden action (GET or POST) is executed. After the hidden action takes place, the browser does a refresh to the expected destination (the YouTube video). The victim may get little or no indication that the hidden attack has happened.</p>
<h4><strong>Fixation Based Attacks</strong></h4>
<p>Here is where things get a bit interesting. This attack hinges on the ability to have a valid CSRF token and a valid session identifier, but those two values aren’t associated together from a session perspective. Say you are posting on a message board. This message board issues you a Session ID in a cookie and also issues you a token for use when posting. If these two values aren’t linked from a session perspective, it would allow for any valid token to be added to the request. Since the Session ID is in the cookie value, if a forged request had a valid token appended this would bypass CSRF protections.</p>
<p><img src="http://farm4.static.flickr.com/3430/3832924543_a4e2db504f_o.png" alt="Fixation Attack" /></p>
<p>What makes this fixation attack an interesting scenario is it requires no leaking of any session data in a cross domain fashion. As long as you have some visibility to the token, it can be requested and fixated to the request.</p>
<h3>Other Scenarios</h3>
<p>There are other scenarios as well. It really depends on how much session data gets leaked in a cross-domain fashion. For example, if the full session ID is leaked, there could be some real problems. It could allow for a tool to construct any GET or any POST to the target application.</p>
<h3>MonkeyFist</h3>
<p><a href="http://hexsec.com/misc/monkeyfist">MonkeyFist</a> is a tool I wrote to PoC Dynamic CSRF attacks. The tool runs as a small service on a system listening for all incoming input. When it receives a request it looks in the referer to determine where the request is coming from. It then uses this information to parse a payloads file and look for the specific attack to construct for that domain. You can have multiple entries in the payloads file performing multiple types of attacks. Redirect, POST, Page (GET and POST) and an Experimental Fixation handler are all included in the application. You can learn more about MonkeyFist on the the <a href="http://hexsec.com/labs">Hexsec Labs</a> page. It is not exactly where I would like it to be, but it works. More streamlining and modifications will come soon. I am still recovering from Black Hat and Defcon <img src='http://www.neohaxor.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I have some posts on MonkeyFist that are coming soon as well.</p>
<h3>More Info</h3>
<p>That&#8217;s it for a quick intro to Dynamic CSRF. If you would like more information you can read our white paper which is available <a href="http://hexsec.com/docs/Dynamic_CSRF_rev1.pdf/view">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neohaxor.org/2009/08/11/dynamic-cross-site-request-forgery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

