views:

504

answers:

9

Real world, how many here undergo in-depth security code reviews? Those that do, how often - once a quarter, once a version, once a blue moon? Those that don't - why not? (Not referring to small or hobby programmers - not that I'm trivializing them, its just I don't expect them to ;-) ).

As a security consultant, I'm usually the one called in to do the security reviews, however this is usually only either for very security-sensitive organizations (e.g. large banks, software vendors, military, etc), or as a result of regulatory requirements (e.g. PCI-DSS).
Now, few groups (except those in the biggest companies such as Microsoft, Intel, RSA, etc) really enjoy the review, even though it really should be a positive experience. It seems to me that this is mostly because of the perceived high investment - of resources, time, and of course cash to bring in the consultants.

Okay, so it's not just perceived, it's real enough: it's commonly accepted that a single reviewer can cover between 50-100 LoC per hour. Though we've managed to multiply that - since we're only looking for specific security issues (and the clients are pressing hard for lower costs) and we can minimize the scope according to the risk - we can max out at around 1000 LoC per hour. For any medium-to-large system, this is still hundreds of costly consultant hours, not trivial at all.

The common suggested alternative is automatic source code scanners, ala Fortify, ounce labs, etc. However, besides the licensing costs, this is far from efficient - typically we find these tools to produce results in the 100 thousands, with a very high (70-90%) rate of false positives (and duplicates). So you're still spending large chunks of time going over the results, AND these tools do not cover a substantial set of potential vulnerabilities (e.g. logic flaws, business logic, etc)

That said, (and a big DISCLAIMER should go here:) I've been working the past few months with one of the tool vendors to develop a service that would do this very efficiently - e.g. be able to cover 500K LoC in just around a single week of work, and yet provide actual, real accurate and complete results - virtually ZERO false positives and nearly no missed false negatives.

Those of you who should be doing SCR, but aren't - would this be enough to convince you otherwise? or is there something else holding you back? Or is it just not an issue for you?


To clarify, I'm not trying to promote myself or my service, just trying to get some real-world perspective beyond my own security-evangelistic agenda. I'd like to see the issues as other programmers see them...

Further clarification, I am NOT asking HOW to perform code reviews, what options there are, etc. I have much expertise in this field, and it is this expertise that I sell to my clients. My question is IF code reviews are as unpopular as they seem, WHY this specific activity is not as popular as it should be, and HOW we can go about changing this. (Irrelevant of choice of methodology, tool, etc.)


Furthermore, as Corneliu and others pointed out, security code reviews should NOT be taken alone as the sole protection and verification of a system's security, rather should be one element of a complete, holistic SDLC (secure development lifecycle) framework. However, neither should it be forgotten. So my question is really focusing on that one element, whether in the context of the full SDLC or alone as a step forward from penetrate-and-patch.

+1  A: 

To be honest, rarely if ever have them.

As much as the business is aware that security is important it is always one of those things (much like testing) that ends up taking a hit in favour of getting in new features, changes etc.

Whilst everyone knows this is the wrong way to go about things I doubt much will change until the application gets bitten badly by a security vulnerability. Sorry for being so cynical.

Andy Rose
Thanks for the input, Andy. Would this change if it was drastically cheaper AND easier (easier also includes easier to process the output and get resolution)?
AviD
+3  A: 

Hi AviD,

I'm from Australia and I have to say that security reviews are (maybe) more popular here.
In the last two projects I've worked we had formal security reviews. I have one more review aligned in the close future but from my perspective a "security review" is wrong by design.

People who do security reviews just look for a cheap silver-bullet to tell them the code is not completely busted and that the chance for an application attack is slightly lower than "it will happen in the first 10 hours of production".

I think a security review starts with:

  • an Architectural Review from a Security Perspective when the architecture is put in place.
  • Then you work with the architect + business on Threat Modelling and understanding the potential issues to be faced and mitigations that can be put in place.
  • Then you build an approach for putting these mitigations in place preferably at an architecture level and try to isolate business-level developers from as much of the security code as possible.
  • Next I would do the full Security Development Life-cycle with the team and teach them proper secure-coding guidelines. Show them all the types of attacks that can happen on their application based on the Threat Model that you built before. Show them how to code and protect.
  • Teach the team about defence in depth and how to secure each piece of their puzzle
  • Teach them how to deploy securely, how to design isolated pieces with a minimum required security on them and so on.
  • Teach them how to do security code reviews of their own code and provoke them to provoke each-other in writing better code.

This would take you a good two weeks I'd say. Maybe three.

Then, you come back regularly and do partial reviews, update the threat-model, and provide more guidance on potential issues that they might introduce.

With this you have a better chance at the end of the project to do a final code review and have a good trust that what you have is good and secure.

Oh, and you can sell this to a business much better than "I need a month to look at your code base and I'll let you know how busted your app is". You can go in holidays for a month and come back and tell them all is good mate and they have no idea what you did.

My 2 cents,

Corneliu.

Corneliu
Thanks, Corneliu, but thats not really what I meant... I mean, yes, you're absolutely correct, and I know all this - we do a lot of this for our clients, and I dont even think that code reviews are necessarily the most important, or the one to start with...
AviD
But unfortunately most organizations are not "mature" enough to implement everything, starting with a full-blown SDLC framework. A lot of companies are still stuck on penetrate-and-patch mode, contrary to EVERYbody's advice! That said, a large number are moving to better testing, ie. code reviews...
AviD
However (and sorry for the lengthy comments) code review still remains the single activity with the highest price tag, even after the first few times. I am working to make it efficient enough to do repeatedly, even down to "regression testing" at a source code level.
AviD
Oh, and thanks for the input on Australia :D. That IS what I was looking for (still not so common in Europe...)
AviD
+1 for being real clear on the context, since we don't want to misguide others with this question/conversation :)
eglasius
+1  A: 

It's dependent upon how important the org and the app is.

You may want to check out Veracode and Fortify (contrasting styles) that automate the process. Both decent outfits and both with a decent client list.

This would be used in conjunction with an Application Security Pen Test. If you're presenting a logon to a protected resource over the Internet then you probably want to run through the code making up the Auth Module. You do need to automate it somewhat - small applications can contain 100K lines of code and more. Would you manually sit through all of this? It sounds pretty boring?

You also need to consider their value add. If you're infrastructure is appallingly open then theres little point in running a Code Review. Why check the windows to the house when all doors are open?

At a bank I worked with (in a Security Consulting /Architect /general dogs) as part of their Project lifecycle, each Project would make up the cost of their Code Review Tool (Fortify in this particular instance). However some of their applications were been broken and owned in less than 5 minutes because of poor IIS configuration.

Code Reviews - at what point in the Dev cycle would this be done? It becomes a little more interesting from an Agile perspective.

Noelie Dunne

Noelie Dunne
I am quite familiar with the products you mentioned, and their "services". I even referenced them in my post... the results are just staggeringly bad. And it still remains prohibitively expensive - in direct cost and time needed to review the massive results.
AviD
+2  A: 

Running Fortify (or similar tool) against any Enterprise App will always find a shed load of vulnerabilities. How many of these are theoretical, how many of these are real business impacting risks? How do you categorize what's important and what’s not & cutting out the false positives? What do you run Fortify against?

This is the approach I generally take from a Security perspective in Enterprise wide Application’s /Architecture …. First understand the ‘use’ cases for the application and the interfaces/components/coupling into and out of your application. Break this down into the user & system interfaces User - you're looking at the use cases for the App i.e. browser /thick client, levels of privilege System - things like MQ, Tibco interfaces, any Management /Admin, Oracle TNS listener, ODBC, ADO, proprietary interfaces and so on.

If you’re a Trading Application dealing in bonds/options then what are you’re interested in?

1) The ability for an anonymous user to access any private application data 2) The ability for an authorised user to exceed permissions within their profile 3) The ability for an authorised user to access a different user’s data 4) The ability for an authorised user to access different users processing results 5) The ability for an authorised user to gain any level of access to any components of the application or internal architecture

So this will be driven the by the logon module and the components that the module calls following successful auth. You’re primarily interested in performing input validation & code checks around this.

There’s absolutely no value code checking components, dlls that have you are not accessible directly or indirectly through another component.

And this assumes that the platform infrastructure is on the money.

Noelie Dunne
Thanks for your answers, Noelie, but again I'm not asking as to how to properly perform CR - this I know - but rather why they're not popular. However I do agree with much of what you wrote....
AviD
Though I take very strongly what you wrote about running automated tools such as fortify - which is why we always (usually) recommend a *manual* CR, though this is order of magnitude more costly.
AviD
Popularity? Hmm - I think it's profile /perception. This comes down to the approach in both cases and organisations been burnt in terms of business value add. You have Firewall Engineers /Pen Testers now calling themselves Security Consultants /Architects.
Noelie Dunne
+1  A: 

I'm not sure if this is the type of answer you were looking for, but hopefully it might be helpful to you.

I have a couple thoughts. First, I value security highly and think security code reviews are a good idea, but I can see why they might not be popular in all cases, depending on the industry. This is pure speculation, but a lot of companies do public betas and so they rely on the feedback received from those sessions. They may view security as something that should be iteratively improved and so they place less emphasis on it at the beginning, confident that a few smart testers will find the bugs and that the beta label will protect them from any liability. Obviously that isn't all companies, but a few might be thinking along similar lines.

If you really want to expand your market, you might consider pitching it in a different light. In addition to highlighting security reviews as potential risk management, they could be viewed of in terms of cost-savings over time in regards to technical debt, salary, reputation, and legal issues.

For example, I'd rather pay a lawyer up front to write a bullet-proof contract than to represent me in a court of law over a contract dispute. It's a form of risk-management, but I also view it as an investment and an enormous savings over time. Not only am I more secure legally, but there are also intangibles such as a defined relationship between myself and a client, where there are set boundaries and expectations to be met by both parties. With those boundaries in place, you are actually freer to concentrate on the things you need to focus on.

If you can present security in a similar fashion, in terms of savings and peace of mind, you may find that the people (read management) who make decisions about hiring security consultants will be more open to your services because you are affecting their bottom line in a positive way. Present it in such a way that you save them far more than you cost.

VirtuosiMedia
Excellent answer! Though we already do (or try to do) exactly what you are saying... I'd be further interested in what other *actual* (read: technical) changes need to happen for SCR to catch on more, and not just how to market it.
AviD
+2  A: 

Since you are doing a market-research, I'd like to contribute.

I'm doing so much SCR for other companies (generally as you said, banks, big e-commerce apps, critical components and other financial stuff). False-positive and money-wise don't use big guys : Fortify, Ounce Labs.

If you are planning to bring a new tool in that market with low false positive and a decent price tag (because Fortify and Ounce are being ridiculous -since they dominant the market-) I and so many other people can get it. MS is digging the same market in VS.NET area, so some developers might go that way and MS can crush any other opponent in there (at the same time can bring some public attention to the market). You should be careful about that.

Not a direct answer to your question, but I hope it helps and if you release it keep me posted.

dr. evil
Agreed, thanks (tho this is pretty much identical to my PoV, and I was hoping to hear something different :)). The problem with MS products (e.g. CodeAnalysis, FxCop, PreFAST, etc) - besides not supporting non-MS technology - its very low level, and leaves a LOT of false negatives on the table.
AviD
And btw, will be releasing very shortly, but I can't really post that here... (or can I?). But anyway, its not actually a tool, but a service, based on some internal development. Hope you dont see this as competition ;-), and if you're in EU I hope we'll be able to help you.
AviD
I think it's OK to send your link in comments. What about security/trust of the service? I think veracode is doing something similar, do you think SaaS is going to affect bad or good?Because people do not even trust me directly on source code reviews, sending it an online service might put them off.
dr. evil
Got that, thanks :). As far as S(ecurity)aaS goes, I think that would make an excellent SO question ;-), but yes, it would be an issue, however we are trying to cover those bases too - or we'll just have to suffice with those clients that are happy with that setup.
AviD
Veracode - not so different in concept, just different in fact (different review model, more (hopefully) accurate and indepth, etc). Also, this would not be an "anonymous" service, as a large consulting company, we'd still be personally consulting them (if required).
AviD
Well, the service was launched - www.codefend.com - and so far its a technical success, at least... :-)
AviD
A: 

Security professionals shouldn't be reviewing code 100% manually. I hope that you have a copy of Ounce Labs or equivalent and are only reviewing to eliminate false-positives, tuning rules, etc.

jm04469
Security professionals don't consider ounce labs or equivalent being a complete code review. These can find MAYBE 40% of total security bugs (if that), usually not the more interesting ones, and always at the price of *MANY* false positives, duplicates, etc. No matter HOW well tuned the rules are.
AviD
No one ever said that using Ounce Labs as the sole source is proper...
jm04469
+1  A: 

Your point about time and cost of an external code review is key. My company contracted Cigital a couple of years ago to do a detailed tool-assisted code review. The security analyst used Fortify and spent weeks completing the manual code review. The time and cost, and the time taken to support the analysis, answering questions and interpreting results, was more than we could sustain on a regular basis. We do our own code reviews, using security guidelines from OWASP and checklists prepared by Cigital. And we use static analysis tools (Coverity, Findbugs) in our continuous integration environment, each release is checked with IBM Watchfire Appscan (or whatever IBM calls it today) and we schedule regular pen tests with Foundstone. The pen tests are a good use of money, and the static analysis tools help ensure high code quality.

If there was a cheap, fast and effective security code review offering, yes there would be a market. I build financial software: my customers aren't crazy for the idea of sending software overseas for analysis by Veracode or similar tho.

Thanks for your input... and just FYI, our CODEFEND service (www.codefend.com) is just that - cheap, fast, and VERY effective. As for overseas - depending where you are, we have local offices in several countries, including the UK (no US office yet). In any event, we have policies around protection of our customers' IP, since others have raised the issue in the past.
AviD
BTW, congrats on being user #100,000!
Kyle Cronin
+2  A: 

I participate in an open source project called Gallery. When we hit release candidate 1 for any given release, we hire an external team to do a security review. The goal is to get a fresh set of highly trained eyes who and focus them on any latent security issues that have crept into the product. In any typical release, we have found that the security review (while expensive) turns up issues and classes of vulnerabilities that our typical developers would not have uncovered. Even though we are a reasonably security conscious development team, there are always new attack vectors that we are unaware of that we have to address.

Thus far we've had 3 full security review for the Gallery 2.x products, and 1 security review for the Gallery 3.x product (in that case we did the review while was in alpha because we wanted feedback about vulnerabilities as soon as possible).

Automated (read: static analysis) tools would be nice. Automated pen-testing tools are also nice. But we believe that there is a great deal of value in having a human in the process to investigate the code and look for the subtle vulnerabilities that trip us up.

bharat
Thanks, this is an interesting point... and just FYI, our recently released CODEFEND service absolutely approaches that issue, since we have also seen that completely automated tools just don't cut it. For more info our methodology, and how we combine both manual and automated testing - see www.codefend.com
AviD