<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.communities.hp.com/securitysoftware/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Following the White Rabbit Blog : security</title><link>http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/security/default.aspx</link><description>Tags: security</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>Is Anybody Listening?</title><link>http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/2009/10/15/is-anybody-listening.aspx</link><pubDate>Thu, 15 Oct 2009 16:22:00 GMT</pubDate><guid isPermaLink="false">94bda21f-7d63-4095-85de-7c2a68fb172c:108403</guid><dc:creator>RafalLos</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Greetings, I am finally back home after an exhausting trip which had me speaking at 2 conferences back-to-back in separate countries and on opposite side of the coast! &amp;nbsp;I did learn some valuable lessons from speaking at these two wildly different conferences thought, so I thought I would share them with you here for your benefit too.&lt;/p&gt;
&lt;p&gt;First off, the Information Security conference I attended on Tuesday in Toronto called &amp;quot;&lt;a target="_blank" title="SecTor Presentations" href="http://www.sector.ca/presentations"&gt;SecTor&lt;/a&gt;&amp;quot; was brilliantly run and targeted towards Canadian-based information security professionals and wanna-be security professionals. &amp;nbsp;It&amp;#39;s OK to say it, there are plenty of people that attend these conferences who are looking to break into the business and want to learn about information security enough to get a grounding of what the industry is about... so they attend these conferences. &amp;nbsp;My talk &amp;quot;When Web 2.0 Attacks&amp;quot; was well-attended and I even had some big names in my audience (thanks to RSnake, Hoff and a few others that wandered in and out) and I think the overall impression was that the stuff I presented was relevant to people&amp;#39;s daily lives in Information Security. &amp;nbsp;That&amp;#39;s kind of the problem though...&lt;/p&gt;
&lt;p&gt;You see, while I ordinarily wouldn&amp;#39;t think twice about educating those in my field ... someone that&amp;#39;s been doing this for a while longer than I reminded me a while back that this is what we would call &amp;quot;preaching to the choir&amp;quot;. &amp;nbsp;Sure, I tend to agree that even within Information Security not enough people understand Web App Sec well enough to build a program and actually reduce any real risks - but those folks have been hearing this talk for years upon years right? &amp;nbsp;At some point I&amp;#39;m bound to hit the law of diminishing returns; and furthermore, people who didn&amp;#39;t agree with me 6 months ago aren&amp;#39;t likely to agree with me today. &amp;nbsp;Great conference, great mind-share but it&amp;#39;s definitely time to reach a broader audience.&lt;/p&gt;
&lt;p&gt;That&amp;#39;s where the next conference I spoke at comes in. &amp;nbsp;Wednesday morning, at 4:00am Central time (yea, AM) while some of my colleagues were stumbling into their hotel rooms in downtown Toronto I was hopping into a car and being driven to the airport to head out west. &amp;nbsp;My destination was Anaheim, CA where I would speak at StarWest later that day. &amp;nbsp;I&amp;#39;m still not sure how through the delayed flight, sickness, and almost-missed connection I made it out to the West Coast by 2pm, but I did... and Star West was awesome.&lt;/p&gt;
&lt;p&gt;StarWest (run by the SQE folks (&lt;a target="_blank" title="SQE Homepage" href="http://www.sqe.com"&gt;www.SQE.com&lt;/a&gt;) is nicely put together and serves an entirely new audience of people. &amp;nbsp;Here at StarWest (although I did find it strange that we were in the heart of DisneyLand!) the audience was almost entirely composed of software test engineers, managers and those related to the field. &amp;nbsp;This was a completely different set of ears than what I&amp;#39;m used to ... this was a good thing.&lt;/p&gt;
&lt;p&gt;The first thing I heard when I put my welcome slide up was &amp;quot;Hey, isn&amp;#39;t security supposed to be done by the security people?&amp;quot; &amp;nbsp;Love it. &amp;nbsp;This is exactly the mentality and walls I was there to break down. &amp;nbsp;I think as we went through the hour-long session on &amp;quot;Detective Work for Testers...&amp;quot; I managed to convince a few people in the audience that their jobs were closely tied to mine in Information Security. &amp;nbsp;Maybe, maybe not. &amp;nbsp;The bottom line is that there were many great folks who came up to me and talked afterwards and through the end of the conference about the absolutely missing component in their SDL that was security. &amp;nbsp;I had one lady in the audience (although she fled before I could get more out of her, and had to track her down myself later on the show floor) tell me that her security team &lt;strong&gt;is&lt;/strong&gt;&amp;nbsp;the developers and that because they tell the bosses that they don&amp;#39;t have security issues no one ever tests the code. &amp;nbsp;I wish I could recall where she worked, hopefully no place important like a bank or anything ...&lt;/p&gt;
&lt;p&gt;The point is - this was the right audience. &amp;nbsp;If you were there and came to my talk, awesome! &amp;nbsp;If you missed it, slides are posted and we can talk about it whenever you have some time.&lt;/p&gt;
&lt;p&gt;Do you believe that Information Security and Software Quality testing is one and the same? &amp;nbsp;Do you believe that a quality defect may as well be a security defect? &amp;nbsp;Can you successfully explain the difference between a security and quality bug?&lt;/p&gt;
&lt;p&gt;... I&amp;#39;m fairly sure I have my target audience for the next&amp;nbsp;foreseeable&amp;nbsp;future. &amp;nbsp;Listen up quality testers - I&amp;#39;m coming to a conference near you!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.communities.hp.com/securitysoftware/aggbug.aspx?PostID=108403" width="1" height="1"&gt;</description><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/security/default.aspx">security</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/conferences/default.aspx">conferences</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/software+quality/default.aspx">software quality</category></item><item><title>Static Code Analysis Failures</title><link>http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/2008/05/06/Static-Code-Analysis-Failures.aspx</link><pubDate>Tue, 06 May 2008 17:32:00 GMT</pubDate><guid isPermaLink="false">94bda21f-7d63-4095-85de-7c2a68fb172c:77056</guid><dc:creator>Rafal Los</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.communities.hp.com/securitysoftware/blogs/rafal/rsscomments.aspx?PostID=77056</wfw:commentRss><comments>http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/2008/05/06/Static-Code-Analysis-Failures.aspx#comments</comments><description>&lt;p&gt;Static code analysis failures are costing enterprises money and reputation.&lt;/p&gt;&lt;p&gt;White-box security testing is inherently a flawed proposition for many reasons -but it all comes down to a very simple concept:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &lt;strong&gt;Machines do not execute source code, they execute machine code (compiled code). --Paul Anderson (&lt;a href="http://www.grammatech.com" title="GrammaTech website"&gt;GrammaTech&lt;/a&gt;)&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; If you think this through for a minute you realize that there are a few specific reasons why the above statement fundamentally changes the way that people look at white-box testing, and why this is a losing proposition.&amp;nbsp; Let&amp;#39;s analyze this in the context of a web application project for a mythical online bank.&amp;nbsp; Consider that the use-case here is that we are dealing with a bank that has an online presence (currently being analyzed) which will be integrated with a series of existing legacy applications, partners, and external 3rd party components.&amp;nbsp; Given this information let&amp;#39;s analyze why white-box analysis (or static source-code analysis) is doomed to fail this project with respect to security.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;&lt;strong&gt;Compiler Optimizers Break Things&lt;/strong&gt; - Think of it this way, compilers are designed to make machine code from your source code.&amp;nbsp; That compiler&amp;#39;s sole purpose (in most cases) is to create machine code that will be optimized, extremely fast-executing, but not necessarily secure.&amp;nbsp; Often times security functions that people build into source code can be removed by compiler optimizers and most often without our knowledge.&amp;nbsp; These actions often undo many of the advanced security features that developers may consciously insert into their code.&amp;nbsp; Consider the following example:&lt;/div&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;Developer is paranoid about data-persistence in memory space, and wants to be doubly-sure that variables are expired and destroyed&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Developer writes a routine whereby the variable will have a null value written to it&amp;nbsp;before the memory is freed&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Compiler optimizer sees this as a double-work scenario, and removes the null-value portion and simply opts to free memory&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;A potential security vulnerability is created with variable persistence in freed memory space&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;p&gt;This example ideally demonstrates how a security vulnerability can be inserted in spite of the developer&amp;#39;s best efforts to write secure code.&amp;nbsp; Standard static-code analysis tools which are used to &amp;quot;scan code&amp;quot; at the static-file level will fail to catch this vulnerability.&amp;nbsp; Quite simply - static code analysis fails if it is not supplemented with dynamic analysis.&lt;/p&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;&lt;div&gt;&lt;strong&gt;3rd Party Library Integrations&lt;/strong&gt; - There is another threat to developing and scanning static code in a white-box format.&amp;nbsp; Inevitably, 3rd party libraries are used to complement features or functionality that are not natively provided by the local development effort.&amp;nbsp; After all, no one re-invents the whole wheel everytime - we simply build what we cannot reuse from someone else&amp;#39;s work, then use the publicly available libraries from 3rd parties to fill in the functionality and features that have already been written and (hopefully) tested before.&amp;nbsp; White-box testing (or static code analysis) will absolutely fail in finding flaws when it comes to pulling in 3rd party libraries.&amp;nbsp; By the definition of this type of issue, 3rd party libraries rarely provide you the source to be scanned and checked for weaknesses that will affect your application.&amp;nbsp; What you&amp;#39;re left with is someone else&amp;#39;s code (in machine-compiled format!) which will be interacting with your application.&amp;nbsp; Would you trust that model?&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;&lt;strong&gt;Static Code Analysis Rarely Understands&amp;nbsp;Data-Flow&amp;nbsp;Modeling&amp;nbsp;(Data Tracing)&lt;/strong&gt; - If you&amp;#39;re scanning your application with a source-code-only analysis tool, you&amp;#39;re going to not only miss things that will almost certainly come back to haunt you - but you may also be over-working yourself without a real purpose.&amp;nbsp; Consider the following example to illustrate my point.&amp;nbsp; Before I get into that example though, allow me to explain this idea of &amp;quot;data-flow modeling&amp;quot; for those that are not familiar with this idea.Data-flow modeling seeks to understand how data moves through your application, not just how the application code is written.&amp;nbsp; After all, that&amp;#39;s the whole pointn of the application, to work with data.&amp;nbsp; Vulnerabilities lie in manipulating data either to or from the end users or the server(s).&amp;nbsp; Data-flow modeling maps out the data in your appliaction from it&amp;#39;s instantiation (maybe when the user types it in) to its resting state (maybe when it&amp;#39;s finally written to a database, or handed off to another application or service for additional work).&amp;nbsp; That being said let&amp;#39;s consider a web application that has 1,000 forms across 100 pages written in the language of your choice, built to be AJAX.&amp;nbsp; While each page does nothing individually to validate user input (the data source) all variables (data) are filtered through a central validation module deep within the application logic.&amp;nbsp; A standard source-code analysis tool (I have evaluated this and can honestly say this is a real use-case but will not mention the tool) will flag on each and every input that is not validated (within the page) as vulnerable to hudreds of vulnerabilities ranging from XSS (Cross-Site Scripting) to SQL Injection and other attack types.&amp;nbsp; What you are left with is a very lengthy report with hundreds of critical and high vulnerabilities that you now obviously must address... unless you do some dynamic analysis on the code and realize that *none* of those theoretical vulnerabilities are exploitable due to the fact that the application filters all data through the central validator/scrubber.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;So, there you have it.&amp;nbsp; Static code analysis is inherently doomed to fail.&amp;nbsp; White-box testing of source-only is flawed.&amp;nbsp; The sky is falling, global warming will kill us all.&amp;nbsp; In my next installment of this column, I&amp;#39;ll&amp;nbsp;give you what you need to know to avoid&amp;nbsp;failing in your security initiatives at the development step of the SDLC&amp;nbsp;- remember, knowing is half the battle.&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;nbsp;Stay tuned!&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;font size="1"&gt;If this information disturbs you, and you would like to talk about it directly please don&amp;#39;t hesitate to email me directly.&amp;nbsp; I am not a sensationalist, and pride myself on presenting practical solutions to real-world problems which are realistically attainable.&amp;nbsp; Thanks for reading.&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.communities.hp.com/securitysoftware/aggbug.aspx?PostID=77056" width="1" height="1"&gt;</description><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/security/default.aspx">security</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/testing/default.aspx">testing</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/static+code+analysis/default.aspx">static code analysis</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/whitebox/default.aspx">whitebox</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/data-flow+analysis/default.aspx">data-flow analysis</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/hybrid+analysis/default.aspx">hybrid analysis</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/dynamic+analysis/default.aspx">dynamic analysis</category></item><item><title>Security and Compliance - Strange Bedfellows Indeed</title><link>http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/2008/05/01/Security-and-Compliance-_2D00_-Strange-Bedfellows-Indeed.aspx</link><pubDate>Thu, 01 May 2008 14:24:00 GMT</pubDate><guid isPermaLink="false">94bda21f-7d63-4095-85de-7c2a68fb172c:76973</guid><dc:creator>Rafal Los</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.communities.hp.com/securitysoftware/blogs/rafal/rsscomments.aspx?PostID=76973</wfw:commentRss><comments>http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/2008/05/01/Security-and-Compliance-_2D00_-Strange-Bedfellows-Indeed.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp; It&amp;#39;s a classic problem of which came first... the chicken or the egg?&amp;nbsp; politics or corruption?&amp;nbsp; security or compliance?&amp;nbsp; While I admit, it&amp;#39;s not such a strange thing to see the two groups working together these days... I would like to point of some of the issues that I&amp;#39;ve come across between these two very important groups in today&amp;#39;s enterprises.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;The issue of compliance is much like the issue of legal counsel.&amp;nbsp; All large enterprises, and even most small business have someone that&amp;#39;s responsible for compliance - occasionally you&amp;#39;ll see an entire department dedicated to the daunting task of keeping up with regulations, compliance policies, and the ever-changing landscape of procedural accountability.&amp;nbsp; Oddly enough, there is not a one-to-one relationship between the&amp;nbsp;compliance department and a security department.&amp;nbsp; I&amp;#39;ve spent a large portion of my IT career in situations just like this and I would like to share some of my understanding with you.&lt;/p&gt;&lt;p&gt;&amp;nbsp; Compliance, while not always a necessity in private businesses, is almost always present in larger, pubilc enterprises.&amp;nbsp; The compliance department is responsible for making sure the business is in-line with self-imposed corporate regulations and policies, industry-consortium regulatory guidance, government oversight and policy even international laws too!&amp;nbsp; It&amp;#39;s amazing these groups can even keep this stuff straight, right?&amp;nbsp; What&amp;#39;s equally amazing is how often compliance relies on IT Security for guidance and implementation of compliance components. This of course begs the question - would IT Security exist in some organizations if there was no compliance stipulation for such groups?&amp;nbsp; On the flipside of that... in a perfectly secure world where no one is ever malicious - what would be the need for the compliance group?&amp;nbsp; So while it may be a stretch to say that one group cannot function properly without the other (I will concede that they can, albeit poorly) each is heavily dependant on the other for its very existence within a business.&amp;nbsp; This is where I find some strange... interactions.&lt;/p&gt;&lt;p&gt;&amp;nbsp; As I&amp;#39;ve stated, the security team often carries out part of compliance policy or regulations; or performs audits to ensure that the same regulations are being followed - but I feel like even in these cases the synergies between these groups are under-utilized.&amp;nbsp; I can&amp;#39;t count the number of times I&amp;#39;ve been turned down for an IT Security initiative (which made perfect business sense, by the way - but was simply under-funded) only to push that same initiative through under the guise of a compliance regulation - through the compliance team.&amp;nbsp; In return... the compliance teams I&amp;#39;ve had the pleasure to work with have repeatedly called upon my security resources to be the &amp;quot;muscle&amp;quot; behind their policies.&lt;/p&gt;&lt;p&gt;&amp;nbsp; As I travel and talk to different groups about Application Security, I am agaff at the number of times that I get an entirely blank stare when I try to explain how leveraging compliance is a sure-fire way to get security initiatives done.&amp;nbsp; Here&amp;#39;s my reasoning... see if you disagree...&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Compliance is a &amp;quot;necessary evil&amp;quot; which exists to keep the business in good legal and regulatory standing&lt;/li&gt;&lt;li&gt;IT Security exists to keep the balance of risk/reward within the business IT as balanced as possible&lt;/li&gt;&lt;li&gt;IT Security should be looking to enact initiatives which work to support the business&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&amp;nbsp; If you take all 3 points above as truth (and I firmly believe they are) then it&amp;#39;s a logical next-step to say that IT Security initiatives and Compliance initiatives will greatly overlap.&amp;nbsp; An overlap within two very necessary units of the enterprise will always, without fail, lend more credibility to their efforts and causes.&amp;nbsp; If both the security and compliance teams are pushing the same agenda, it becomes very difficult for a business owner to simply dismiss that agenda as unnecessary or frivolous.&lt;/p&gt;&lt;p&gt;&amp;nbsp; So a lesson-learned here - if you&amp;#39;re not already doing this... here are some very simple yet extremely effective (based on personal experience and first-hand accounts) techniques for getting things &amp;quot;done&amp;quot;.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Open a regular dialogue with your complaince team.&amp;nbsp; Meet once a quarter, once a month, or once a week as permissable to discuss what you&amp;#39;re independently working on&lt;/li&gt;&lt;li&gt;Find overlaps in your goals from a non-technical perspective&lt;/li&gt;&lt;li&gt;Create a joint strategy for compliance and technical implementation of initiatives previously agreed upon&lt;/li&gt;&lt;li&gt;Review business requirements jointly - ensure that both groups understand each other&amp;#39;s point-of-view&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Given these very simple, and probably obvious, steps - I can virtually guarantee a more successful IT Security goal achievement.&amp;nbsp; You&amp;#39;ll work less uphill, you&amp;#39;ll &amp;quot;win&amp;quot; more often, and you&amp;#39;ll do a much better job not only understanding but supporting your business - that makes everyone happy.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.communities.hp.com/securitysoftware/aggbug.aspx?PostID=76973" width="1" height="1"&gt;</description><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/security/default.aspx">security</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/politics/default.aspx">politics</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/compliance/default.aspx">compliance</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/technology+strategy/default.aspx">technology strategy</category></item><item><title>In "cyberspace"... no one can hear your database scream</title><link>http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/2008/04/09/In-_2200_cyberspace_2200__2E00__2E00_.-no-one-can-hear-your-database-scream.aspx</link><pubDate>Wed, 09 Apr 2008 12:01:00 GMT</pubDate><guid isPermaLink="false">94bda21f-7d63-4095-85de-7c2a68fb172c:76158</guid><dc:creator>Rafal Los</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.communities.hp.com/securitysoftware/blogs/rafal/rsscomments.aspx?PostID=76158</wfw:commentRss><comments>http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/2008/04/09/In-_2200_cyberspace_2200__2E00__2E00_.-no-one-can-hear-your-database-scream.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; It&amp;#39;s 2:34am, local time.&amp;nbsp; You&amp;#39;re snoring up a storm after a hard day at the office.&amp;nbsp; You&amp;#39;ve patched all your servers, your lockdown scripts have been verified, and your IDS is humming along perfectly.&amp;nbsp; Oh, and by the way, someone named &amp;quot;R0kk1t&amp;quot; just stole your customer database.&amp;nbsp; A quick check of the &amp;quot;Security Dashboard&amp;quot; when you get in at 8:00am will show everything is green...&amp;nbsp; You have a serious problem.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sound like anyone you know?&amp;nbsp; This is a serious concern, and the problem is - it&amp;#39;s pervasive.&amp;nbsp; It&amp;#39;s scarry that 7 out of every 10 people I talk to about Web Application Security don&amp;#39;t have any defenses.&amp;nbsp; When I ask what their defenses are they mention things like firewalls, IDSes, and patch policies - all have absolutely nothing to do with (and will do little for) Web Application Security.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Houston - we have a problem.&amp;nbsp; Even if you&amp;#39;re trying to build a program geared towards protecting your web apps - how are you going to justify it?&amp;nbsp; Inevitably someone is going to ask you the daunting question - &amp;quot;So, have we been attacked?&amp;nbsp; How many times?&amp;quot;&amp;nbsp; Odds are you&amp;#39;re going to have no idea.&amp;nbsp; All hope is *not* lost though... I have some suggestions from years of this happening to me.&amp;nbsp; Here are some tips on building self-defense mechanisms into your web applications - and how to use them as rudimentary alerting triggers...&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Kick out the troublemakers&lt;/strong&gt;&amp;nbsp;- A well-built web application has to know when someone is just being stupid.&amp;nbsp; If your&amp;#39;re tracking logged-in users it&amp;#39;s even easier.&amp;nbsp; Track the per-user incidence of &amp;quot;bad data&amp;quot; and if it reaches a specific threshold - expire the session and send that user to a page warning them that they&amp;#39;ve been bad and must re-login.&amp;nbsp; It&amp;#39;s basic, and not hard to do - but rarely implemented.&amp;nbsp; Of course, you&amp;#39;ll have to figure out those thresholds and what &amp;quot;bad data&amp;quot; is - but at least you have a start here.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Whitelist &lt;/strong&gt;-&amp;nbsp;In&amp;nbsp;the point&amp;nbsp;above&amp;nbsp;I said you should track&amp;nbsp;&amp;quot;bad data&amp;quot; or bad user-supplied input but how do you know what is good versus bad?&amp;nbsp; Simple, you first have to define what you should expect from the user.&amp;nbsp; An application should, on a per-page and per-input basis, know exactly what input is allowed and what data sets are in play.&amp;nbsp; You can use regular expressions to validate these lists!&amp;nbsp; For example, if you&amp;#39;ve got a field that expects social security numbers (don&amp;#39;t we all) then you can have&amp;nbsp;this simple bit of JavaScript to validate (obviously you&amp;#39;ll want to do this on the server side!)&lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;&lt;em&gt;&lt;span class="Keyword"&gt;function&lt;/span&gt; isValidSSN(value) { &lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="Keyword"&gt;var&lt;/span&gt; re = &lt;span class="Constant"&gt;/^([0-6]\d{2}|7[0-6]\d|77[0-2])([ \-]?)(\d{2})\2(\d{4})$/&lt;/span&gt;; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="Keyword"&gt;if&lt;/span&gt; (!re.test(value)) { &lt;span class="Keyword"&gt;return false&lt;/span&gt;; } &lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="Keyword"&gt;var&lt;/span&gt; temp = value; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="Keyword"&gt;if&lt;/span&gt; (value.indexOf(&lt;span class="Constant"&gt;&amp;quot;-&amp;quot;&lt;/span&gt;) != &lt;span class="Constant"&gt;-1&lt;/span&gt;) { temp = (value.split(&lt;span class="Constant"&gt;&amp;quot;-&amp;quot;&lt;/span&gt;)).join(&lt;span class="Constant"&gt;&amp;quot;&amp;quot;&lt;/span&gt;); } &lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="Keyword"&gt;if&lt;/span&gt; (value.indexOf(&lt;span class="Constant"&gt;&amp;quot; &amp;quot;&lt;/span&gt;) != &lt;span class="Constant"&gt;-1&lt;/span&gt;) { temp = (value.split(&lt;span class="Constant"&gt;&amp;quot; &amp;quot;&lt;/span&gt;)).join(&lt;span class="Constant"&gt;&amp;quot;&amp;quot;&lt;/span&gt;); } &lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="Keyword"&gt;if&lt;/span&gt; (temp.substring(&lt;span class="Constant"&gt;0&lt;/span&gt;, &lt;span class="Constant"&gt;3&lt;/span&gt;) == &lt;span class="Constant"&gt;&amp;quot;000&amp;quot;&lt;/span&gt;) { &lt;span class="Keyword"&gt;return false&lt;/span&gt;; } &lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="Keyword"&gt;if&lt;/span&gt; (temp.substring(&lt;span class="Constant"&gt;3&lt;/span&gt;, &lt;span class="Constant"&gt;5&lt;/span&gt;) == &lt;span class="Constant"&gt;&amp;quot;00&amp;quot;&lt;/span&gt;) { &lt;span class="Keyword"&gt;return false&lt;/span&gt;; } &lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="Keyword"&gt;if&lt;/span&gt; (temp.substring(&lt;span class="Constant"&gt;5&lt;/span&gt;, &lt;span class="Constant"&gt;9&lt;/span&gt;) == &lt;span class="Constant"&gt;&amp;quot;0000&amp;quot;&lt;/span&gt;) { &lt;span class="Keyword"&gt;return false&lt;/span&gt;; } &lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class="Keyword"&gt;return true&lt;/span&gt;; &lt;br /&gt;}&lt;/em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Log, Log, Log&lt;/strong&gt; - Your web applications should always have a separate log file for &amp;quot;unexpected input&amp;quot;.&amp;nbsp; In fact, where I&amp;#39;ve had input into the development process I&amp;#39;ve required there to be at least 2 log files.&amp;nbsp; First log file logs all &amp;quot;unexpected actions&amp;quot; in a web application, the time/date, the logged-in user, the source, user-agent and all other pertinent details of the &amp;quot;unexpected action&amp;quot; whether it be an exception, a crash, or whatever.&amp;nbsp; The second log file is just a dump of all the weird input people submit - some malicious, some not, to better help write regular expressions to filter the garbage.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Fire Alerts&lt;/strong&gt; - All the things I&amp;#39;ve mentioned previously are great - but if no one looks at them, or gets an alert when they fire - they&amp;#39;re worthless.&amp;nbsp; Make sure you create actionable alerts from with your application framework.&amp;nbsp; Combine all the loggins, white-listing, and self-defense into something that you can understand.&amp;nbsp; Be careful of the information Monster though... if you&amp;#39;re not careful in the way you set this up you&amp;#39;ll end up with 10,000 emails/hour and won&amp;#39;t be any more effective than having nothing.&amp;nbsp; It&amp;#39;s a difficult balance but with practice you&amp;#39;ll be one step closer.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Well - I hope you find those useful.&amp;nbsp; If you&amp;#39;re willing to share, I would love to hear of some other methods that YOU are using in the real-world!&amp;nbsp; Leave them as a comment here, share with the community - remember we&amp;#39;re all smarter when we share information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.communities.hp.com/securitysoftware/aggbug.aspx?PostID=76158" width="1" height="1"&gt;</description><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/security/default.aspx">security</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/hacked/default.aspx">hacked</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/web+application/default.aspx">web application</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/defense/default.aspx">defense</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/alerting/default.aspx">alerting</category></item><item><title>"Security Vulnerability" != "Defect"  ; why?</title><link>http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/2008/04/01/Security-vulnerabilities-as-quality-defects_3F00_.aspx</link><pubDate>Tue, 01 Apr 2008 11:18:00 GMT</pubDate><guid isPermaLink="false">94bda21f-7d63-4095-85de-7c2a68fb172c:75801</guid><dc:creator>Rafal Los</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.communities.hp.com/securitysoftware/blogs/rafal/rsscomments.aspx?PostID=75801</wfw:commentRss><comments>http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/2008/04/01/Security-vulnerabilities-as-quality-defects_3F00_.aspx#comments</comments><description>&lt;p&gt;It&amp;#39;s one of those obvious things.&amp;nbsp; A defect is a defect, right?&amp;nbsp; Whether the airbag is faulty, or the gas cap doesn&amp;#39;t hold pressure... a defect is a defect.&amp;nbsp; The strange thing is - it hasn&amp;#39;t been that way, and still isn&amp;#39;t that way, in most of the IT shops I&amp;#39;ve been in.&amp;nbsp; Why?&lt;/p&gt;&lt;p&gt;The reason is simple.&amp;nbsp; Historically, &lt;em&gt;security vulnerabilities&lt;/em&gt;&lt;strong&gt; &lt;/strong&gt;have been in a class all their own.&amp;nbsp; In an attempt to put some urgency to the matter, security professionals have labeled defects in the security of their projects (in this case I&amp;#39;m talking about web applications) as an entirely different thing than a functional defect.&amp;nbsp; What we didn&amp;#39;t realize is that we were actually doing a dis-service to ourselves and the security cause.&amp;nbsp; You may not agree with me right now - but I&amp;#39;ll explain this more clearly, and I think you&amp;#39;ll be on board with my thought process.&lt;/p&gt;&lt;p&gt;Let&amp;#39;s talk about defects, in general and then apply it to the matter at hand.&amp;nbsp; First, let&amp;#39;s identify what a defect is...&amp;nbsp; A defect is, in the dictionary sense (cut from &lt;a href="http://dictionary.reference.com/browse/defect" target="_blank"&gt;dictionary.com)&lt;/a&gt;:&lt;/p&gt;&lt;p&gt;&lt;span class="me"&gt;&lt;strong&gt;de&amp;middot;fect&lt;/strong&gt;&lt;/span&gt; &lt;span class="pronset"&gt;&lt;font color="#116699"&gt;&amp;nbsp;&lt;img border="0" height="15" src="http://cache.lexico.com/g/d/premium.gif" width="16" /&gt;&amp;nbsp; &lt;img border="0" class="luna-Img" height="4" src="http://cache.lexico.com/dictionary/graphics/luna/thinsp.png" width="2" /&gt;&lt;/font&gt;&lt;a href="https://secure.reference.com/premium/login.html?rd=2&amp;amp;u=http%3A%2F%2Fdictionary.reference.com%2Fbrowse%2Fdefect"&gt;&lt;font color="#116699"&gt;&lt;img border="0" height="18" src="http://cache.lexico.com/g/d/speaker.gif" width="17" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;font color="#116699"&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;span class="show_ipapr" style="display:none;"&gt;&lt;span class="prondelim"&gt;&lt;font color="#880000" face="Arial Unicode MS"&gt;/&lt;/font&gt;&lt;/span&gt;&lt;span class="pg"&gt;&lt;em&gt;&lt;font color="#558811"&gt;n. &lt;/font&gt;&lt;/em&gt;&lt;/span&gt;&lt;font size="3"&gt;&lt;font color="#880000"&gt;&lt;span class="pron"&gt;ˈdi&lt;img border="0" class="luna-Img" height="4" src="http://cache.lexico.com/dictionary/graphics/luna/thinsp.png" width="2" /&gt;fɛkt, &lt;/span&gt;&lt;span class="pron"&gt;dɪˈfɛkt; &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span class="pg"&gt;&lt;em&gt;&lt;font color="#558811"&gt;v. &lt;/font&gt;&lt;/em&gt;&lt;/span&gt;&lt;font color="#880000"&gt;&lt;span class="pron"&gt;dɪˈfɛkt&lt;/span&gt;&lt;span class="prondelim"&gt;&lt;font face="Arial Unicode MS"&gt;/&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#116699"&gt; &lt;/font&gt;&lt;a class="pronlink" title="Click for pronunciation key"&gt;&lt;u&gt;&lt;font color="#116699"&gt;Pronunciation Key&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;span class="pron_toggle" style="display:inline;"&gt;&lt;span class="prondelim"&gt;&lt;font color="#880000" face="Arial Unicode MS"&gt; - &lt;/font&gt;&lt;/span&gt;&lt;a class="pronlink" title="Click to show spelled pronunciation"&gt;&lt;u&gt;&lt;font color="#116699"&gt;Show Spelled Pronunciation&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="show_spellpr" style="display:inline;"&gt;&lt;span class="prondelim"&gt;&lt;font color="#880000" face="Arial Unicode MS"&gt;[&lt;/font&gt;&lt;/span&gt;&lt;span class="pg"&gt;&lt;em&gt;&lt;font color="#558811"&gt;n. &lt;/font&gt;&lt;/em&gt;&lt;/span&gt;&lt;font color="#880000"&gt;&lt;font face="Verdana"&gt;&lt;span class="pron"&gt;&lt;strong&gt;dee&lt;/strong&gt;-fekt, &lt;/span&gt;&lt;span class="pron"&gt;di-&lt;strong&gt;fekt&lt;/strong&gt;; &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span class="pg"&gt;&lt;em&gt;&lt;font color="#558811"&gt;v. &lt;/font&gt;&lt;/em&gt;&lt;/span&gt;&lt;font color="#880000"&gt;&lt;span class="pron"&gt;&lt;font face="Verdana"&gt;di-&lt;strong&gt;fekt&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;span class="prondelim"&gt;&lt;font face="Arial Unicode MS"&gt;]&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#116699"&gt; &lt;/font&gt;&lt;a class="pronlink" title="Click for pronunciation key"&gt;&lt;u&gt;&lt;font color="#116699"&gt;Pronunciation Key&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;span class="pron_toggle" style="display:inline;"&gt;&lt;span class="prondelim"&gt;&lt;font color="#880000" face="Arial Unicode MS"&gt; - &lt;/font&gt;&lt;/span&gt;&lt;a class="pronlink" title="Click to show IPA pronunciation"&gt;&lt;u&gt;&lt;font color="#116699"&gt;Show IPA Pronunciation&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;font color="#116699"&gt; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="body"&gt;&lt;span class="pg"&gt;&lt;em&gt;&lt;font color="#558811"&gt;&amp;ndash;noun &lt;/font&gt;&lt;/em&gt;&lt;/span&gt;&lt;table class="luna-Ent"&gt;&lt;tr&gt;&lt;td class="dn"&gt;1.&lt;/td&gt;&lt;td&gt;a shortcoming, fault, or imperfection: &lt;span class="ital-inline"&gt;&lt;em&gt;a defect in an argument; a defect in a machine. &lt;/em&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;table class="luna-Ent"&gt;&lt;tr&gt;&lt;td class="dn"&gt;2.&lt;/td&gt;&lt;td&gt;lack or want, esp. of something essential to perfection or completeness; deficiency: &lt;span class="ital-inline"&gt;&lt;em&gt;a defect in hearing. &lt;/em&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;OK, easy enough right?&amp;nbsp; So the first meaning is clear; a defect is a shortcoming, fault, or imperfection.&amp;nbsp; It is reasoned that a defect in a web-based application results when functionality X doesn&amp;#39;t work as required.&amp;nbsp; Say you have a button, and the &lt;em&gt;functional specification&lt;/em&gt; (we&amp;#39;ll get back to this gem in a minute) calls for the button to perform some action, A.&amp;nbsp; During the testing phase of the application, before release to production, a tester or tool is utilized to test the functionality of that button, but instead of action A happening, some other action B happens.&amp;nbsp; This is a defect.&amp;nbsp; There is no doubt in anyone&amp;#39;s mind that this immediately gets classified as a defect, put into the defect tracking system and sent back to the developer for remediation.&amp;nbsp; The defect is classified as a higher-priority defect if the function happens to be one that is showcased, or important to the overall functionality of the application.&amp;nbsp; Those of you that already use the HP Quality Center tools know exactly what I&amp;#39;m talking about, and know how this process works.&amp;nbsp; Here&amp;#39;s the strange twist though - why is quality testing only done with &lt;em&gt;good data&lt;/em&gt;?&amp;nbsp; I understand that you want to make sure that the test cases work properly - but why are the testing options limited?&amp;nbsp; The issue at hand here is a very narrow view of defects, and defect testing.&lt;/p&gt;&lt;p&gt;Back in college, I took very basic programming class and had to write a program that was a calculator.&amp;nbsp; It would ask for two inputs of numbers, and then give you an option to perform either an addition, subtraction, multiplication or division of the inputs.&amp;nbsp; Generally, it was assumed that these would be numbers, but what if they weren&amp;#39;t numbers?&amp;nbsp; Most of the students in the class, myself included, never thought about ... &amp;quot;What if someone enters a letter or some other unexpected input?&amp;quot;&amp;nbsp; Well, luckily, the professor chose my application, put it up on the screen for the whole class to see, and promptly entered a and b for the two inputs and tried to add them.&amp;nbsp; When my application core dumped, he explained to the class why I had gotten my first F on a project.&amp;nbsp; I learned a very valuable lesson that day - developers must brace their applications for unexpected input.&amp;nbsp; &amp;quot;Why would anyone want to enter something other than numbers?&amp;quot; wasn&amp;#39;t a good enough answer to explain why my application failed.&amp;nbsp; Let&amp;#39;s apply this lesson I learned back in college to today&amp;#39;s application programmers and functional testers.&lt;/p&gt;&lt;p&gt;Here are the reasons why I think security &lt;em&gt;vulnerabilities&lt;/em&gt; aren&amp;#39;t seen as &amp;quot;defects&amp;quot; in general...&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Security professionals have insisted that a vulnerability is its own separate category&lt;/strong&gt; - While it is true, some security vulnerabilities are a whole new level of &amp;quot;bad&amp;quot; they should be considered just like any other defect in the application for the sake of tracking and remediation.&amp;nbsp; Web platform managers are generally concerned with meeting the demands of their customers and producing code that is defect-free - and it&amp;#39;s our own fault that &amp;quot;vulnerabilities&amp;quot; of the security variety have become some ethereal, magical issue for security nerds to worry about.&amp;nbsp; This matter can only be fixed by changing the naming back... a vulnerability is a defect, period.&amp;nbsp; &lt;em&gt;Security vulnerabilities must be explained as &amp;quot;high-criticality defects&amp;quot; to developers, managers and customers otherwise this situation will never change.&lt;/em&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Functional specifications rarely, if ever - call for for security validation&lt;/strong&gt; - Functional specifications aren&amp;#39;t written by security professionals, generally.&amp;nbsp; At best, security professionals have a chance to review the functional specification way too late into the process, while the code is being written and readied for production.&amp;nbsp; This is, once again, our own fault most of the time.&amp;nbsp; The answer to this dilemma is a two-pronged attack.&amp;nbsp; &lt;em&gt;We as security professionals must educate those that write functional specifications, and enlighten them to the need for security features.&amp;nbsp; At the same time, we must work hard to have an active input in the writing and release of functional specification documents.&amp;nbsp;&lt;/em&gt; These two vectors are critical to getting secure code as an end-product.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Programmers don&amp;#39;t typically think about malicious users&lt;/strong&gt; - While it would be great to think that one day all developers will inherently write secure code because they will have &amp;quot;learned&amp;quot; what security is, and how important it is to the application - the fact is that it&amp;#39;s a pipe dream.&amp;nbsp; Developers care about one thing... meeting functional specifications in the least amount of time possible, and moving on to the next project.&amp;nbsp; Developers like to write optimized code that accomplishes the required tasks in as little time as possible.&amp;nbsp; Solving #2 above will also partly solve this problem.&amp;nbsp; In addition, &lt;em&gt;developers must be given the tools (such as static and dynamic code analysis tools as plug-ins to their IDEs) to make their jobs easier&lt;/em&gt;.&amp;nbsp; It is not reasonable to expect developers to be security experts in all aspects, so we must arm them with the tools to be experts, without having to do too much extra work or they won&amp;#39;t use those tools.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;So what have we learned today?&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Security vulnerabilities must be re-classified as easily-understandable &amp;quot;functional defects&amp;quot;&lt;/li&gt;&lt;li&gt;Funcitonal specifications must be written to include provisions for security validation&lt;/li&gt;&lt;li&gt;Quality professionals must be given the tools to test for &amp;quot;security defects&amp;quot; in web applications to close the loop in the lifecycle&lt;/li&gt;&lt;li&gt;Developers must be educated and also given the tools to write more secure code with minimal additional effort&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;-- I welcome your comments!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.communities.hp.com/securitysoftware/aggbug.aspx?PostID=75801" width="1" height="1"&gt;</description><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/defects/default.aspx">defects</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/vulnerabilities/default.aspx">vulnerabilities</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/security/default.aspx">security</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/functional+specification/default.aspx">functional specification</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/quality/default.aspx">quality</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/testing/default.aspx">testing</category><category domain="http://www.communities.hp.com/securitysoftware/blogs/rafal/archive/tags/development/default.aspx">development</category></item></channel></rss>