Monday, 29 October 2012

Nice Java real world app with real world complexity

Just found the caTissue Suite java application which is part of the  Tissue-Biospecimen Banking and Technology Tools Knowledge Center which seems to be a nice complex project (with an open license)

Here is the 400m download file: Download caTissue Suite v1.2 Installation Files

The main wiki is at  https://wiki.nci.nih.gov/display/caTissuedoc/caTissue+Documentation+Wiki and this project seams to have run out of initial funding:



What I like about it, is that it looks like a good example of the type of real-world apps that we need our security tools to support.

Sunday, 28 October 2012

Starting to use the O2 Spring MVC viewer on ThreadFix

Using the Tool - O2 Cmd SpringMVC v1.0.exe  (see more details on this post: Tool - O2 Cmd SpringMVC v1.0.exe - as standalone exe) here is how to start using it on ThreadFix  from Denim Group ("ThreadFix is a software vulnerability aggregation and management system that helps organizations aggregate vulnerability data, generate virtual patches, and interact with software defect tracking systems.")

I downloaded the ThreadFix binaries from the download page : ThreadFix_1_0_1.zip
And since I couldn't find a download for the source code, I used git by executing: $ git clone https://code.google.com/p/threadfix/

Amazing presentation on integrating security into the SDL

Nick Galbreath  (@NGalbreath)  has published the great presentation he delivered at OWASP's AppSec USA last week.

You can read it on his Rebooting (secure) (web) software development with Continuous Deployment blog entry or use the embedded  slide-share viewer below:



There are lots of great ideas and concepts in there, but for me the slide that really describes what we are trying to do (and how we have to solve the 'software security problem') is this one:

"If we want to fix Security .... we have to fix Development" 
"If we want to fix Security .... we have to fix Development" 
"If we want to fix Security .... we have to fix Development" 
.... (write/say 100x until internalized)
"If we want to fix Security .... we have to fix Development" 

One of the reasons why driving security changes and making code-fixes is so hard, is because security doesn't live in isolation and it is 100% depended on the development process that exists on the other side.

What I like about Nick's pragmatic approach is that he is showing (with real examples) that when there is a slick, fast and effective SDL (with daily pushes to production), security is much easier to embed and there is a much better architecture to 'inject security' into the SDL (and to understand the side effects of those security changes)

The good news is that we 'the security dudes' have such a good reputation with developers, and they trust us so much, that we are the best guys to drive this change.............

.... I can just hear the developers calling the security teams and say "....Hey we want to change how we develop our applications/websites, can't you come over and tell us what to do?  ... Since you've been trying to 'tell us what to do' forever ...  you must have good solutions for how to create the type of Development environment that Nick is talking about'..."

....yeah ..... right :(


Related posts:

SecDDev - Security Driven Development

I was thinking today about the areas where security (and secure development) can add value to the SDL and hit on the concept of Security-Driven-Development (SecDDev)

SecDDev is security coding activities driven by security focused developers (which is much more productive than the current security as TAX model we have today)

The way I got into this idea was that I was thinking about one of the TeamMentor (TM) refactorings that I would like to see happening, namely the need to create a 'read-only' version of TeamMentor for sites like TeamMentor.net

This would be a version of TM that has no ability to change the Libraries and Article's content, which is a great way to achieve security, since it is harder to exploit a feature when the code is not there :)

What is interesting on this scenario ('Read-Only TM') is that the business requirement ('have a rock-solid version of TM hosted in TeamMentor.net that can be sold to customers') doesn't NEED this isolation! It possible (and easier) to deploy a version that has the full (very powerful) TM editing capabilities and hope that those features are not exploited, or that none of the editors and admin users delete anything (see missing iOS Library incident). This lack of business requirement,  means that unless there is an additional driver to create this 'read-only' version, it won't happen (which explains why we end-up with the bloated 'security-vulns-rich' applications we have today).

Now there is a good business case for 'application isolation and robustness' but those tend to be fuzzy concepts which are hard to measure. For example, in this kind of activities, there is a massive lack of external recognisable metrics, where the site looks and behaves the same before and after the refactoring (until it is able to sustain an exploit/mistake or massive traffic spike). In fact these changes tend to introduce massive side effects (see 'About' page broken due to ClickJacking protection)

And this is where the idea of SecDDev occurred to me where I was thinking 'if only I had a security focused development guy/team that would help me in doing this refactoring'.

Since that person (the Security-Driven-Developer) would have has as part of his job spec the "improvement of TM's security" (where that is just one of the (many) roles and responsibilities that I have in TM's SDL) he/she would be much more focused into making it happen.

Creating a read-only version of TM, which in practice means the isolation of the read-code and the edit-code into separate sites/areas which can be easily removed, is a good example of an important-but-not-urgent activity that would make a massive difference in TM's overal security architecture.

To complicate matter worse, it is hard to make this type of code changes. Even after all my efforts to develop TM in a modular architecture, the technologies and frameworks used (Html, Javascript, jquery, .Net) promote/reward tight integration and inter-dependencies (for example it would be 'security by obscurity' to remove the edit-code from the front-end, but leave it all on the webservices back-end).

This is why when you look at most apps, the code is always in 'development activities blocks' instead of 'security focused blocks'

Another area that SecDDev would have to focus a lot is on UnitTests, since they would struggle to make/propose any meaningful change without the support and cushion of a solid Unit/Integration test suite.  And anybody that gives me a working UnitTest for TM, is somebody that is adding value to me as a developer! (in fact, SI will even pay for those Unit Test :) )

Another interesting 'political' problem happens when the product managers/owners have a lot of power and want to 'lock-in the customer' into a product's technology. For example, a real secure way to create a 'read-only' version of TeamMentor, would be to remove 99% of its code (on both client and server sides) and built a flat-file version (i.e. pure HTML) protected by a simple OAuth-based authentication/authorisation layer (which could even be done as an external service). But this would mean that the 'TeamMentor' product would 'disappear' and all that would be left would be the Content. The good news (for TeamMentor) is that since SI's center of gravity is on the 'Content + Services side' there are no problems in following what is the best engineering route, but when you look at why some applications/websites are so bloated (and don't like to allow the exporting of its data), you will usually find that it happens due to political/strategic decisions instead of engineering ones)

Finally, where are we going to get those SecDDevs from? Well Mark has a good idea for that, see: Let's make this happen: "Investing in Developing Software Security Talent"

Solving the missing iOS library in teammentor.net

Here is a document containing 'draft' notes about an issue I had to deal last week, where the iOS Library disappeared from the hosted version of TeamMentor at http://teammentor.net


Creating the final TeamMentor with SI Library repository via multiple Git pulls and pushs

This is going to be a long one, so if you are interested in seeing Git and GitHub in action in a real-world application, grab a coffee/tee/beer and read on :)

This is the scenario at the start:
  • We need to create the final TeamMentor 3.2.3 package for release
  • The TeamMentor_SI_Library repository is at version 3.2
  • The TeamMentor/Master repository is at version 3.2.3 
  • The Library_SI has a couple content changes since the last pull
  • We need to do a pull of both TeamMentor/Master and Library_SI into TeamMentor_SI_Library and push the final result to GitHub

Saturday, 27 October 2012

Adding Tags to TeamMentor Master repository

With 3.2 out, its time to add some Git Tags to the main TeamMentor/Master repository (which at the moment has none):

New GitHub structure for the multiple TeamMentor development and deployment scenarios

After a lot of internal debate we finally arrived at the following GitHub architecture (the text below is based on Jason's last email):

Current set-up and logical Divisions:

  • TM code and app are free, we can give anyone access
  • Tool integrations (like CX or CAT.NET) are free and delivered separately
  • OWASP content is free (released under a CC license), we can give anyone access
  • Top Vulns library is used by the services team and is free
  • For each of the other libraries SI Customers have to pay for and they can be delivered as a combination or one at a time.
  • There are internal tools, such as PowerTools and Unit Tests that aren't normally delivered to customers, but can be given for free

For that reason we use a repo for the TM code, a repo for internal tools and unit tests, a repo for each tool integration and then a repo for each library.:TM code,  TM Docs Library, Tm4tm library, Top Vulns Library and OWASP Library are public, the rest are private.

Customer Purchase:
When a customer purchases TM they need their own source tree to work within and to customize. It should not be visible to anyone else since it'll contain content that is their internal IP. We give each customer a repo that contains the code we delivered to them and then each time we ship a new version we'll push to that repo and merge changes.


GitHub Organization:

  • SecurityInnovation Organisation: 
    • Contains what's there now minus TeamMentor
  • TeamMentor Organization (the 'Code' repos) 
    • Main TeamMentor codebase, but no content. 
    • Includes unit tests, power tools, tool integrations
    • Example of repositories:
      • Master , Unit Tests, Cat.NET, Power Tools
  • TMContent  Organisation (the 'Content' repos)
    • All TeamMentor content libraries (there should be no code in these repos)
    • Example of repositories (each a TM Library):
      • OWASP (with CC License)
      • TM Docs (public)
      • Tm4tm Library (public) - Tm4tm = TeamMentor for TeamMentor
      • Top Vulns (public)
      • SI Library (private)
      •  .NET 2.0 , .NET 3.5 , .NET 4.0
      • Android and iOs
      • C++
      • Java
      • PHP
      • CWE and PCI
      • etc...
  • TMClients Organisation (the 'Content + Data' repositories): 
    • Repos containing both TM source code and TM Library (in order to make it easier to track deployments and custom changes)
    • Repos for each TeamMentor 'client; (which includes SI sites like the teammentor.net fork) 
      • TM + OWASP Library (the 'eval' version)
      • TM + SI Library
      • TeamMentor.net version
      • demos.teammentor.net 
      • Customer A
      • Customer B
      • Customer C , etc..

One of the core ideas/objectives of this structure was to have a clean separation between Code and Data (i.e. TM Source code and TM Libraries). We arrived at a solution based on multiple GitHub Organisations because their website works better that way.

It also helps in the separation of duties/focus since the TeamMentor GitHub organisation is for developers, the TMContent is for content writers/editors and the TMClients is for TM Consumers (and DevOps). Each has its own timings, dynamics and workflow.

Interestingly there is another type of data that we will be soon creating a lot of, which is 'User specific' information. For example if we were to have detailed logs of user's activities, or allowed the user to perform particular actions to an article (see First pass at creating ‘user activities’ (to be removed from 3.0 release) ) where would we store that information?

CheckMarx Queries in TeamMentor with some Landing Pages

Here is a pretty cool PoC (still in draft mode) of the integration of TeamMentor (TM) with Checkmarx content

You can see it at http://checkmarx.teammentor.net/Library/CheckMarx_Queries (which should only open the CheckMarx_Queries library in your browser)

Here the main features/capabilities:
  • there is a TM Library that holds the CheckMarx's Query's data (created from the data retrieved from this WebMethod)
  • there is a TM Folder per language type  - also mapped to the TM Article's Technology field
  • there is a TM View per query type - also mapped to the TM Article's Phase field
  • the Type field indicates if there is a TeamMentor Landing Page for a particular Query
  • the Category field contains the CWE Id (good to see the cases when the same CWE is applied to multiple queries)
  • The Article html content is made of:
    • IFrame with TM Landing Page content (if there is a TM Landing Page) 
    • IFrame with CWE content (if CWE ID > 0) 
    • Query rule's Metadata
    • Query rule's source (in Checkmarx meta C# language)

Friday, 26 October 2012

Get Html transformations of CWE Html from Checkmarx WebService

Next on the CheckMarx+TeamMentor path, I was curious to see if Checkmarx had rules for all the CWE entries on their database (which are about 865), so now that I have a nice way to get a dump of all their rules  I was able to run a quick quick C# LINQ query to calculate the unique CWE ids and then download the current HTML (gist is here):


Util - CheckMarx Rule and Guidance Viewer (with C# SAST Rules and CWE data)

The more I look at Checkmarx the more I like it, for example here is a simple Rules and Guidance viewer that was created by just visualising the 2Mbs of data retrieved from the GetQueryCollection WebMethod

The code is here (Gist) and the standalone exe is at Util - CheckMarx Rule and Guidance Viewer v1.0.exe




Tool - O2 Cmd SpringMVC v1.0.exe - as standalone exe

I just had a request  for the O2's Spring MVC module (developed ages ago), and It was was a good opportunity to test the latest version of the 'O2 Standalone tool builder', since it now supports the embedding of the tools installed via an O2 Script (usually stored in the _ToolsOrApis folder).

You can download the Tool - O2 Cmd SpringMVC v1.0.exe (or build it using O2) which is the stand alone exe of the old O2_Cmd_SpringMvc.msi tool (See at the end of this post for details on how this exe was created)

Windows 8 Sandboxing - some links

I've always been a big fan of Application sandboxing because I really believe that is one of the best way to enforce application security (and to create an ecosystem that rewards secure coding and secure applications). As you can see on Past research on Sandboxing and Code Access Security (CAS)  I have done quite a lot of thinking and research about it ... until I gave up because nobody really cared (and FullTrust .Net apps are still the norm).

Now Microsoft seems to be re-inventing the Sanboxing model (again) and giving it another go with Windows 8 RT (RT = RunTime).

I don't know a lot about how it all works, but here are some quick links about it that I found:

At quick glance I haven't see a lot about policy's or permission's management/visualisation/code-analysis (am I missing it?)

Interesting preview of Blackberry 10 (now can they execute?)

Just saw this BBC Blackberry 10: Thorsten Heins's plan to revive RIM video interview of Blackberry CEO and it is amazing how I reacted to his new ideas vs how I reacted to Windows 8 Metro (which I still have not used since I can't see the point).

Thorsten seems to be a guy who undertands (in his own words) that 'Quality Matters' and if you get a platform right, you will gain traction.

Take for example his/Blackberry ideas on app multitasking and the hub/messaging central. THAT is big, they are moving from the App centric world (which Apple's App Store took to the next level) and are starting to think about how the user can interact with the Apps capabilities.

The idea that you can reply to something on Twitter (or Reddit, or TeamMentor) without having the application open is HUGE. That will require a whole new level of APIs and standards which will help our apps to work much better (for us)

So good on Blackberry, although I have never coded for it, they definitely seemed to be on the right direction.

See, the Metro stuff (or what ever they will call the tiles duffer in Windows 8) fells and smells like a Microsoft's typical 'lets create something different' activity, where this Blackberry 10 stuff fells like 'here are a bunch of problems that we/you have, and here are some new ideas to address it'. I liked this presentation because it focused on the WHY, not the WHAT

They still need to pull it off, and it will be very interesting to see how open this platform is.

Taking a look at Checkmarx VistaDB database

Following from the VistaDB viewer I developed a while back I just updated it to work on x64.

It was mainly a case of fixing the references to VistaDB.Net20.dll and Checkmarx's CxDB.vdb3 file, like for example:



Thursday, 25 October 2012

Going back in time using Git's checkout

I'm still amazed at Git's speed in moving back and forwards in time. For example I was trying to find a particular GUI that we created for TeamMentor and was able to use git checkout to look at previous versions:

Updating Checkmarx license

I just updated the server-side Checkmarx  license on SI's test server.

Before the update, it looked like this (note the 10000 LOC limitation):

Nice list of 20 online coding tools

There is definitely a lot of innovation happening in this space, check out the list at The top 20 online coding tools from .Net magazine.

And if we want to enable the next generation of developers to code securely we need to integrate our knowledge into their IDEs (like these ones). Humm .... I wonder how hard it will be to add TeamMentor integration to these IDEs?

Note that this is on a mainstream developer magazine and (predictably) a search for 'security' or 'owasp' has 0 hits on that page:


Consuming CheckMarx WebServices

Checkmarx exposes three WebServices (one as ASMX and two as WCF) which are used by their clients tools, for example the VisualStudio Add-in (that can be downloaded from here)

CxWebInterface

Which is the main external interface to their engine and can be accessed at public URL like for example http://checkmarx.teammentor.net/CxWebInterface/ (the Checkmarx server used on their web trials is at https://www.cxprivatecloud.com/CxWebInterface/ )

Making TeamMentor run on UltiDev server

Since Checkmarx runs on UltiDev's web server, it makes sense to also host TeamMentor on it (vs IIS which might not be installed on the target server).

The installation process was quite easy:
  1. downloaded the eval copy of TeamMentor (which is the full engine with the OWASP Library) 
  2. added a website in UltiDev's gui
  3. configured the site to be an ASP.NET and pointed it to the TM_Website folder
  4. didn't use any virtual dir, since Checkmarx wasn't using it and TeamMentor likes it that way :)
  5. that was it

'About' page broken due to ClickJacking protection

We're just about to release TeamMentor 3.2 when a final round of QA noticed that the About page was not working:


As you can see by the screenshot and the issue opened (Fix about page which was broken due to ClickJacking protection) this was caused by the fixed applied to the ClickJacking vulnerability reported in TeamMentor.

So here is another nice example the TAX we developers have to pay due to security changes (the app was working great before the fix).

Also, note how the 'security vulnerability' information that I received made no reference to the problems that would be caused by applying the fixes!  

Saying 'Enable the X-Frame-Options' is much easier than saying 'Enable the X-Frame-Options and here are the site effects on YOUR app of that change' 

And this is the key message that I try to give to security professionals in my "Making Security Invisible by Becoming the Developer's Best Friends" presentations. 

Providing information about a security vulnerability and some pointers on how to fix it, is not good enough!!!! Since that is JUST a small part of what is needed to fix that issue. 

Usually more important is 'What are the side effects of applying that fix'

For another similar example see the Couple XSS issues and XSS-By-Design (in TeamMentor) post. 

Security #Fail UX Wifi Connection

So I'm on a local cafe and to access the wifi I have to enter a 13 UpperCase+LowerCase+Number password (given to me from the counter)

This means that it takes me an additional minute and 500% more brain power to login than I would want (and was expecting to). That minute might not sound a lot (and extra use of the brain), but when you are in the zone and with a good mojo, it can be the difference between an idea being implemented and being lost.

This is what the login (and password) looks like (at least they had the common sense to NOT mask the password):

Using Scripted (JS Editor from VMWare) to build Mobile Site

When I was creating the First working version of TeamMentor Mobile I gave scripted a test drive and I quite like it.

You can read more at Scripted: A Javascript Editor from vmware and this is what my GUI looked like:

Since the scripted stuff on the bin folder wasn't working (on Windows), to start scripted, I added the node.exe file to the server directory and launched scripted from there using node scripted.js


I really like the real-time feedback on JS Errors and it is nice to code on an IDE that understands Javascript.

What I really want to learn more is the use of Annotated JavaScript for the Closure Compiler (see https://developers.google.com/closure/compiler/docs/js-for-compiler) since this could be a great way to add type information to Javascript. Note how in the TM_Mobile.js file (screenshot above), it starts with /* global ... */ which tells the compiler to accept those variables as globals

One feature that I would like to see was an auto-preview of the code changes (in a browser window)

Tuesday, 23 October 2012

First working version of TeamMentor Mobile

After the  First working PoC of Tablet/Mobile site using JQueryMobile and Woody template I now got a fully working version of TeamMentor working on a mobile/Tablet design.

I have to say that JQuery Mobile was really nice to use, and I fell I just scratched the surface of what can be done with it.

You can try the latest version at http://tm-mobile-test.apphb.com/ (looks really nice on my IPhone and IPad)

And here it is in action:

Home page:

 Folder(s):
 View(s):
 Article(s):
 Article Content:
Article with Code Sample (formated):


Article with content written in WikiText:



Monday, 22 October 2012

Sometimes the best response is just say 'YES'

One of the most damaging things that can be done to somebody who is playing around with new idea (and have asked for some) support is to not say YES immediately!

Ideas are very fragile, and just like Jonathan Ive said about Jobs "...just as Steve loved ideas, and loved making stuff, he treated the process of creativity with a rare and a wonderful reverence. You see, I think he better than anyone understood that while ideas ultimately can be so powerful, they begin as fragile, barely formed thoughts, so easily missed, so easily compromised, so easily just squished...."

This means that when somebody asks for an opinion or some financial support (like Mark did with Investing in Developing Software Security Talent ), if we believe in the 'core values of the idea',  our default answer should be YES!!!

If anything, throw a couple more ideas to the mix and try to evolve the thinking behind the core idea, like I did with Let's make this happen: "Investing in Developing Software Security Talent" (this could backfire since it is important for the person with the idea not to fully realize how complex and hard it will be, but I also believe that one should capture the ideas/thinking that we have (even if an raw state since usually there are some really good nuggets in there))

Now of course that ideas at this stage are still in a very raw state, and in 99.9% of the cases the final model (the one that actually works) will be very different (from an operational/implementation point of view).

Another very important thing is that the person with the idea is going to be in a powerful 'self delusion state' which is actually VERY important. When I look back at my best ideas (i.e. the ones that actually created something), there were always a moment that my faith, focus and value-analysis of that idea was WAY off the chart. BUT if I wasn't for that 'delusion state', the idea would had never happened (for example the O2 Platform or the  2008 and 2011 OWASP Summits). I now know that 'self delusion states' are very important (and even something that can be practiced, improved and managed)

It is  at the early stages of the idea (when the 'self delusion state' is on maximum effect) that putting any roadblocks can be very damaging.

And if somebody says "Hey!!  I have an idea, would you be able to support it with 1k, 5k or 10k", if the money is kinda available, then the right answer is "YES, sure, in principle count me in". This is the best of the both worlds , since it will give support to the original idea while asking the author to clarify its view and come up with an operational model. Note that no money is going to be spend NOW, this is just a promise of future support.

When I was an OWASP board member, for a while it used to drive me crazy how nobody couldn't do quick decisions for amounts less than 1 USD to 5k USD (they still can't :) ). So at for a while there was an item on the budget that said 'Board Funds' which was an amount that any Board Member could commit at any time for anything. In practice this meant that I was able to provide 'theoretical' financial support to a number of OWASP initiatives (namely chapters, conferences and educational activities). It usually went sometime like "...Hey Dinis, we would like to do XYZ, and at the moment we have a shortfall of $xyz USD, can you give us cover for that amount, in case we don't get $abc USD in sponsors/revenue..". And since a lot of these ideas/activities are Self-fulfiling Prophecies , in most cases the amount needed (if any at all) was much smaller than the one originally asked for.

This is why my default answer to ideas (that make sense to me) and people with energy is YES, Go and Do it!

If they pull-it-off, great!

If they don't, we will be a step closer.

And sometimes we have to do this, even when we know that the idea is wrong and will not work. See, sometimes it is better to just have some movement (even if not 100% on the right direction) then to have no movement at all. This actually means that we also have to be careful when providing (too much) feedback at the early stages, since that might reduce the energy of the other side (an important part of the 'self delusion state' is to be able to ignore the real complexity of the problem at hand, which if fully understood too early, will in most cases be very demoralizing (i.e. it is easy to climb a big mountain in small milestones, without looking too much at how far the top is)

Another myth that also happens is that there is this feeling that 'if supported this will succeed very fast'. Nah, in the real world, the cases where something happens very fast are very small. What I found is that even when there are 'none or very small roadblocks/procedures' (for example with budgets pre-approved), it still takes a lot of effort to make something happen. It also helps to have a culture of proactive-encouragement and an operational machine to support it (the like the OWASP OpsTeam)

Finally, when Ofer Shezar in his The Science in Ideation blog post makes the point that we have to be careful in supporting 'ideas' like the one Mark had, he misses the points that I've tried to make on this post. Because if Ofer also believes that we need more 'developers with security knowledge' (like I do) then he should realize that Mark's idea is a step in that direction.

Now I happen to agree that Mark is not addressing the root cause of the problem, BUT, that is not relevant to this thread :)

And unless we (me and Ofer in this case) are prepared to spend some time on what we think are the 'root causes of the problem' , then we should support the ones that are going on the right direction, like Mark :)