Monday, 22 October 2012

First working PoC of Tablet/Mobile site using JQueryMobile and Woody template

After Buying a mobile site-template from ThemeForest , I'm spending some time using/refactoring the Woody theme for a Tablet/Mobile version of TeamMentor (and learning how jQueryMobile works).

I just reached a key milestone, where I created a PoC that shows the most important technical challenge that I had: The dynamic creation of GUI elements from TM WebServices calls.

In the image below, the important parts are the 2 'Available Libraries'  List Items. They are dynamically created via AJAX calls to the TM's GetLibraries WebServices method:


You can try it in action at http://tm-mobile-test.apphb.com (automatic AppHarbor deployment via GitHub), but at the moment the Libraries links open the 'About' page and the other Items (Blog, Portfolio and Contact) still show the original Woody template content.

Pixlr - Great Online Image Editor

Finally I found what It looks like an easy and fast online site to manipulate images.

I was able to upload a psd (photoshop file) to Pixlr.com:


And in less that one minute I had what I wanted: a smaller version of the TM logo in a transparent background:


Very cool on Pixlr.com to make it so easy (I'm sure there is a cost of using this service, but for now, I got what I needed, so I can go back to coding)

Sunday, 21 October 2012

You will not have your best ideas when you are in a position of Power

Here is a simple idea that should explain why I'm blogging so much these days (i.e. I'm trying to find a place to store my ideas (good and bad)).

Statistically it doesn't make sense to think that you will have your best ideas when you are in a position of power. 

This could also be said as "You will not have 'Simple Solutions' when you are in Power"

By 'Power' I don't mean that you can just 'order' others what to do, it could be just as well that your opinion and ideas are wanted, and you happen to be so well respected that your ideas will be executed/implemented. I mean 'Power' to have your ideas implemented

By 'Simple Solutions' I mean, solutions that have gone though multiple refactoring of good and bad ideas and 'are just right' (there is nothing more to add or remove)

I actually think that what happens, is that where you are in a position of power, the amount of time available to 'think' and come up with the best/innovative solutions is very small.

It also doesn't help if all ideas are executed since there is a finite amount of energy and resources, and sometimes it is very damaging to spend to much time on a bad (or half-baked idea).

Handling content changes made on hosted site created by Git clone (with auto Git commits and pushes?)

Here is the next interesting TeamMentor (TM) and GitHub problem to solve:

"How to deal with content changes made using TM's online editing capabilities"

Let's make this happen: "Investing in Developing Software Security Talent"

Mark posted yesterday an 'draft' idea which I think is GREAT!

Please read it at Investing in Developing Software Security Talent 

Although I think that Mark is on a great path, one that is consistent with his views of bringing developers to security (not security to developers), I have a couple comments on is proposed model :)

Here are my key proposed changes:

  • Separate the 'creating security talent' from Seconauts (ie 'separate code from data', or using a git analogy 'fork the main repository')
  • Expand the concept to include current Developers and Security Professionals
  • Create a financial model that is easy to implement, transparent and morally effective


This is how I would slice it:

Master version (the 'code'): "Developing Software Security Talent" Programme:" - Improving the Software Security Talent of a  new Generation of Software developers and 'code fixers'.

The focus of this program is to help Developers or Security Professionals who want to write secure code or fix security vulnerabilities. The model proposed is one based on Internships and Mentorships.

  • The key objective is to create the next generation of developers who will:
    • know how to write secure code, 
    • work with the multiple SDL parties in the multiple secure coding/architecture activities and 
    • fix security vulnerabilities
  • The program will measure its success by the number of 'conversions' made over a period of time:
    • # of students that are now focus on secure coding
    • # of real-world developers who have added 'secure coding' to their skill set
    • # of developers (and job applications) that have 'secure coding' on its job spec
    • # of Application Security professionals who have acquired 'secure coding' skills and can talk with developers (in the developer's language) and are able (when requested) to sit down and fix code
  • A desired site-effect is the creation of an open community and 'high-quality body of work', that supports the millions of developers who need to write secure code worldwide, and ask 'secure coding questions' everyday.
  • How these 'conversions' are made, is not an important detail:
    • The 'Seconauts model' (descibed below) is just one way to achieve this goal

Fork #1 (the 'data) "Seconauts participation in "Developing Software Security Talent" Programme:

Seconauts will:

  • Find the sponsors and mentors
  • Handle the logistics (from payments, to selections, to contacts, to introductions, to public reporting, etc..)
  • Define the selection criteria, select the candidates and allocated them to the mentors
  • Define the Seconauts projects that will be worked on (by the candidates) and ensure that there is enough high-quality reviewers at hand to help with task allocation and questions raised (by the candidates)
  • Help and brief the Mentors (with clear definitions of what are the expectations and responsibilities of each party)
  • ...see mark's post for a specific details (like the number of mentors, what each one should do, etc...)

Fork #2: XYZ Company ....

Fork #3: XYZ University ....

Fork #4: UK Government ....

Fork #5: OWASP ....

etc...

Remember that the objective is to develop Security Talent, so it doesn't really matter how it is done, as long as it happens.

It is also important to take into account that some companies or organisations have a 'Not invented here' syndrome, and it is important to present them with ideas that they can consume, re-brand and execute

Rough/Draf notes

Since Mark's original post was in a 'Draf' mode', here are a bunch of semi-related notes and ideas that I had when reading and thinking about this.

Starting with some comments on the proposed model, I'm going to use SI (Security Innovation) as an example of a company that could participate on the mentoring and hiring activities (note that I have not spoken with the SI guys about this, it is just easier to have a specific example in mind):

  • I think that the amount paid to the 'candidate' should 'be defined' by the 'contracting party', in this case SI. Since SI would want to get the best talent, it can chose to pay more (this will also depend on the geographical location of the candidate)
    • Although I'm a big believer of openness, in this case, the 'financial arrangement' should be a private matter between SI and the candiate
  • I like the ideas to give the candidate some money, but this should ONLY be used to cover expenses (computer equipment, travel, hosting services, software, etc). In a similar way that I wrote on Why OWASP can't pay OWASP Leaders the moment the sponsorship money is used as 'payment to the candidate' the social contract between the organisation, the mentors and its participants is broken:
    • See previous point on how I'm NOT saying that the candidate should NOT be paid
    • I'm saying that the candidate SHOULD be paid, just not by this program (whose funds should only be used for 'expenses')
      • With this in mind, the candidate should be given $4000, where HE/SHE decides where to spend that money (and in time there would be a good number of documented examples of where others spent it)
      • Like I wrote in the problem of paying OWASP leaders and in the OWASP GSD Project (GSD = Get Stuff Done) proposal, the concept is one where the candidate cannot NOT pay himself, or any company/individual he/she is associated with (this is a great self-regulated system, and it would dramatically reduce the management, monitoring and 'expense approval' requirements / overhead)
  • This can be easily executed on a worldwide basis as long as the pieces are in place
  • I don't think that the 'need for the candidate to go everyday' to an office is a critical one.
    • It raises the bar and complexity of the arrangement
    • It goes against the model of the 'distributed' development environment that we have today in the 'GitHub' generation
    • Development is sometimes better done in isolation than in groups
    • Again, not saying that it shouldn't happen, just that it shouldn't be a big criteria
    • For example I have no idea of where some of my good colleagues at SI are (even when I talk to them by voice, email, github, code everyday). They could be somewhere in Europe , in the Boston or Seattle offices or in the middle of the US)
    • So I would change this requirement to be 'the candidate must have a physical connection with the mentors every week, which could range from hours to 5 days'
  • If the cost allocated to each candidate is $4000, then the sponsorship packages should be multiples of that:
    • $4k pays for 1
    • $8k pays for 2
    • $12k pays for 3
    • $20k pays for 5 .... etc...
  • This could be set-up on a recurring basis so that the sponsoring companies could view it as a recurring subscriptions.
  • I think that there should be NO requirement on either party regarding the next contracts (i.e. namely no obligation for the candidate to work 18 months for the mentoring company).
    • For example I would expect that if a candidate did a successful internship at SI, and he liked SI that he wanted to join the company, and SI liked his/her work so much that it would offer a job:
      • there would be no need for a 'mandatory 18 months contract'
      • the contract offerend by SI should be competitive and fair , 
      • such '18 months requirement to work for SI' would dramatically change the negotiation dynamics (putting a lot of power in the hands of SI) and would most likely leave a bitter taste in everybody involved
  • The focus should be on writing secure code and fixing existing code at Open Source projects, BUT we shouldn't have very high hopes that the code created will be of a very high standard since by definition these are inexperience 'secure development' developers (which will take more than 6 months to change)

And here is a brain dump of 'stuff' that needs some more thinking: 

  • it is going to be hard to find a significant number of mentors (which is a catch 22 ,since once the model is proven, they will be easier to find)
    • I would say that this is the hard part. At OWASP's Projects (see links below) we had a simpler workflow (which was project leader working with 2 reviewers) and it was REALLY hard to get good reviews created (it does take a lot of time to review something properly). I don't think it should be underestimated how much effort it will take from the mentors and helpers 
    • There is usually a great difference between the amount of people who will put their hand up and say 'I can do it, I can review that or mentor him/her' to the ones who will actually be able to do it (and sometimes it is not that the reviewer/mentor are not good enough, it is just that it takes a lot of time and effort to do it properly)
  • Creating a selection criteria and executing it will be hard, and the best way is to do it 100% in the open (learn from the OWASP seasons of code experience (see links below))
  • Expand the target audience (it should also be focused on current professional developers that want to get into application security). We need this NOW for developers that are coding today:
    • In fact most companies that write a lot of software need this TODAY for a number of their current dev teams
    • I don't like the word 'intern' is sounds like it is for a somebody leaving school (or university). This is why I used the word 'candidate' on this post. 
      • ex-students should be only one of the target audiences
  • The work created by the 'candidates' is most likely NOT going to be production quality (since by default they will be amateurs at it). Only experienced developers (with security awareness/knowledge) are able to create that. So let's not raise the expectations bar too high
  • Mark's maths are wrong:
    • $4000 will be barely enough to buy: a decent laptop, airfare expenses, hotels, hosting, software,etc... (over a period of 6 months). It will help if outside the US/UK, but we are talking about 800 USD per month (which is less than you get flipping burgers)
    • It also doesn't take into account all the back-office admin costs that it will take to make this happen (which I agree that shouldn't be paid from the $4000 sponsorship money)
  • I like this idea as a good way to get talent to work on Seconauts (but i can see some critics saying that this is just a cheap way to kickstart a community)
  • This is very similar to what happens on a number of companies, and it is called 'Interns' :)
    • in fact a number of OWASP members have such programs at their companies (which could be leveraged to kickstart this idea)
  • This will not work without operational support/staff, in fact the first thing to do should be to hire / appoint a project manager to run this (Mark is currently doing that role, but he will soon run out of time/energy)
  • There is already lot of mentoring happening at OWASP and I am personally involved in a couple of mentoring cases (not within an explicit framework, but achieving the same goals). So some of those efforts could be recycled to kickstart this idea
    • There are already a good number of targets for mentorship at OWASP, namely some newer OWASP leaders who are still getting their heads around WebAppSec
    • The irony is that OWASP would be the perfect place to do this, since it has the infrastructure, the funds, the community, the brand, etc...
    • That said, I think the concept is great, and since Mark is focused on it (and nobody is at OWASP), I will ask the Owasp community to support it and commit to at least 10k. I also will raise this idea at SI and see if they would like to participate


Bottom line: Good luck Mark

More Secure Coding talent is something we desperately need, so I hope that this idea really comes into life and I'm happy to help as much as I can.



Why I have experience in making this comments 

(originally I had this at the beginning of the post, but I figured out, that this will only be relevant to the readers that are reading it all the way to the end):

-----------------------------------------------------------------------------


I'm going to comment on this as somebody who as already implemented a similar program at OWASP namely the OWASPs Seasons of code who had a similar number of moving parts and activities:



I was also very involved with Paulo Coimbra and the GPC on the management of OWASP projects, where we did a lot of thinking about this:

For reference, before Paulo Coimbra left OWASP, we were really close to implementing a similar program at OWASP (the idea was to start with getting reviewers involved into projects (in a 'Season of Quality') and then evolve it into mentorships).

And has Paulo's departure showed, without such back-office support it is impossible to do this. 

Btw, to give you an idea of the amazing work Paulo was doing on OWASP projects, take a look at https://www.owasp.org/index.php/OWASP_Projects_Dashboard_2.0 (you will be amazed). The good news is that we now have Samantha (Owasp new project manager) who is going to bring things back on track



Saturday, 20 October 2012

Using Git Branches to deal with the multi-config variations of TeamMentor

Here is an interesting problem that afects TeamMentor (TM)  and just about every other app:

"How to deal with the specialised versions of an application that are created via Config changes"

Keeping this simple, and only dealing with the config changes that can be made by modifying the TmConfig.config file, TM already (today) has the following scenarios to support:

The need to create forks/clones for TeamMentor.net website

(Here is an email I sent earlier today at SI, that covers a number of interesting challenges that we're now having with TeamMentor, and how Git/GitHub can help)

One of the scenarios/problems that is starting to happen is 'how to manage the specific requirements for deployed sites like Teammentor.net who need custom changes?'

So here is a description of 'the problem':

Why do others think that I'm "hard to deal with" and that "I don't listen"

Here is a bit of self-analysis for you :)

One of the common complains that I've heard about me, is that I'm "hard to deal with" and that I "don't listen" (to others opinions).

Apart from the fact that I can also complain about that myself (I don't always listen to me too, and my 'instinct opinion' does usually takes over), I think that it is important to analyse the root causes and see if there are solutions to improve it.

Is there a way to get email alerts on Reddit activity

I really like reddit and its threaded discusion model, but what I'm really missing is an email alert every time there is a post or comment on a couple subreddits that I follow.

I know that there are a bunch of ways the reddit data can be consumed (for example http://www.reddit.com/r/owasp/.json ), but I find that at the moment I miss a number of threads and replies that I care about, due to the lack of an email alert (even if once a day)

For example, the GitHub issues is working really well for TeamMentor (https://github.com/TeamMentor/Master/issues) because:

  • I get an email on new issues or comments
  • If I reply to the email, the message is posted to the correct issue and
  • Users that add issues comments, receive the email updates on the issues submitted (if they 'watch' the thread)
  • I can manage my emails faster than I can manage my reddit subscriptions
If only I could achieve the same with Redit, Reddit's value and usability (to me) would increase dramatically.

Btw, the reddit 'message' center is already a good help (although it only seems to show the comments on threads I start or comments I made), so maybe there is a way to expand its coverage and enable auto-emailing.

Friday, 19 October 2012

Using O2 FluentSharp REPL in VisualStudio on a WinForms C# application


1) Start VisualStudio 2010

2) Create a new Project of Type 'Windows Forms Application'

Quickly starting 3 websites on 3 local folders

One of the O2 Platform Tools that I use all the time is the Util - Start .NET WebServer on Local Folder v1.0.exe (752kb) which makes any local folder into an website (via starting Cassini in the background).

So after Buying 3 mobile site-template from ThemeForest and downloading them, I had the need to quickly start a webserver for each one and see that they look like (we can't just open the html pages in a browser since there are *.js and *.css web references that need to be served from a  webserver).

So I started the Util - Start .NET WebServer on Local Folder v1.0.exe  tool locally:


Which looks like this:


Dropped the folder into the top-left box to start the webservice:


Note: if you get this error from Cassini, it probably is because the virtual path is too long (which Cassini doesn't like and you can change in the VPath TextBox)



In this case I set the VPath to / and clicked on 'Restart WebServer', and we now have a local WebServer running on port 56342 on the dropped path (note that if you close the O2 tool, the webserver process will bt terminated):



Now if you look at the unzipped files, the folder we want as the web root is not the main unzipped one, but the one where the index.html file is (which is different on each of the 3 themes I downloaded).

Here is what each one of theme looks like:

EyeCandy:


Woody:


Spina:



Viewing Woody's Doc's site (which also need a local webserver to be viewed properly):



Buying a mobile site-template from ThemeForest

I have a couple hours today to see if I can create a simple TeamMentor Mobile site, and turned to ThemeForest for help.

This not the first time I use this site (see here) and I have to say that I really like it. It is smooth, fast, to the point, very efficient and with decent prices.

For example I just bough these three themes (to see which one works best)


And this is how easy it was to buy them:

1) find the theme to buy and click Purchase




2) chose payment mode (since I was buying a couple I loaded some 'Prepaid Credit' using Paypal )


3) Download Theme


Thursday, 18 October 2012

First two 'official' TeamMentor 3.2 videos

Tom Bain from SI just published these two videos about TeamMentor which are part of the 3.2 release marketing efforts.

  • What do you think?
  • Do they make sense?
  • Too much 'marketing'?
  • Any spectacular BS comment that we should remove? :)
  • How could we make them better?
  • How could we make them worse? :)

Video #1: What is TeamMentor? 





Creating an Offline-Version of O2

If you are going to use O2 in a location without a good network connection or if you have some corporate proxy that prevents the download of some of O2 external dependencies (that happen on first use/compile of some O2 Scripts), the best thing to do is to create an Offline Copy of O2

Note: You can download the latest version of the O2 Offline folder (created by the workflow described below) from here:  O2_Offline v4.3.zip

Here are the steps required to create an Offline copy of O2 Platform:

1) Download the latest version from http://tiny.cc/O2Platform


2) Copy the O2 Platform - Main O2 Gui v4.3.exe to a local folder:


At this stage there should only be one file in that folder

3) Open the O2 Platform 


After first run there will now be a couple extra folders (for example the O2.Platform.Scripts repository (embedded as a zip in the original exe) was unzipped into the O2.Platform.Scripts folder)


 3) Execute the 'Compile All Scripts' menu item (from Debug Menu) 


This is actually the 'Compile All Local O2 Scripts.h2' O2 script which will compile all current 700 scripts (in  O2.Platform.Scripts folder), and will have the (desired) side effect of downloading all dependencies (it will also create a cached version of the compiled scripts, making them start faster):


The main DataGridView will give you feedback on failed compilations, and if you also want to see the scripts that are compiling OK, tick the 'Show Ok' checkbox:


While the script is executing, if you look in the _ToolsOrApis folder, you will see a number of tools already downloaded:
\

And in the _ReferencesDownloaded you will see another set of dependencies:


The _ReferencesDownloaded  folder contains files downloaded directly from the O2_Platform_ReferencedAssemblies repository

The _ToolsOrApis folder contains files created by downloaded installers or MSI extractions (with the download happening from the tool creator's website)

The _EmbeddedAssemblies folder contains the assemblies that where embedded with the original 20Mb O2 download

4) Review compilation failures - to see if the script you want is in there


With the current 4.3 release there about 17 scripts that failed to compile. Some of these are due to the fact that they need to compiled with O2 running as a 32bit app (for example the Chrome ones).

For reference, the 'Compiler Mode #1' is the snippet compiler (for the *.h2 scripts) and the 'Compiler Mode #2' is the normal .Net compiler (for the *.cs files). This is why you will see some *.cs files with a green false mapping in the  'Compiler Mode #1 column and *.h2 files with a green false mapping on the  'Compiler Mode #2 column

4) Create a zip of the folder created and put in a place you can get it later (web or usb stick).

In this case I copied the  114Mb file to a public DropBox location:  O2_Offline v4.3.zip


Couple XSS issues and XSS-By-Design (in TeamMentor)

The security review of TeamMentor (TM) has raised a couple XSS issues which seem (so far) to require user-intervention, where the user (or admin) are required to inject the payload in order to trigger it (i.e. they are attacking themselves).

Here is a small description of the issues and how to reproduce them (this really should be a script):

Wednesday, 17 October 2012

Deploying TeamMentor to AppHarbor (.NET Cloud) using Git push

Now that AppHarbor supports git publishing (i.e. they create a git repository for an 'AppHarbor Application'), it is very easy and fast to deploy a new version of TeamMentor.

First step is to go to AppHarbor.com and create an application (for this example I'm calling it 'Testing-AppHarbor'):

Approving a GitHub Pull Request Workflow

I just received a GitHub's Pull Request from Roman for some new content that he added to TeamMentor's Documentation Site.

Here is the workflow I used to approve this request using GitHub's web-based workflow:

Taking a snapshot of my blog stats

Currently Blogger stats are like a yo-yo (either here or gone) so in case they disappear for good in the future, here they are (note that this doesn't include RSS readers):

All Time:
Monthly:

Weekly:

Michael's LinkedIn profile as O2 Collaborator

Just noticed today that Michael Hidalgo (who wrote the Exploiting Microsoft MVC vulnerabilities using OWASP O2 Platform at CodeProject.com and a number of articles at O2's blog http://o2platform.wordpress.com/author/michaelhidalgo/) has updated his LinkedIn profile to say that he is a Collaborator OWASP O2 Project at OWASP



This is very cool and Thanks Michael for doing this.

His description about the O2 Platform and what he is focused on, is also quite nice :)



Tuesday, 16 October 2012

Change Website version using Git checkout (after a CSRF fix broke a GUI component)

We had an issue yesterday with TeamMentor.net where a version 3.2.1 was pushed into production with a CSRF fix (see TeamMentor Vulnerability Disclosures: CSRF , ClickJacking and Get Password Hash from Browser Memory) that broke some of the user functionality (see issue:  When ShowContentToAnonymousUsers is set to false, users are asked to re-login when opening articles)

I was able to create a fix and push it to TeamMentor/Master but the reality is that we shouldn't had moved the TeamMentor.net into 3.2.1 version (from 3.2) without a full QA round.

So the solution was to revert the live sites to the 3.2 version (from 3.2.1) and then move it to 3.2.2 after QA signs it off.

But how do we do that?

Well since TeamMentor is Git based, there is a very easy solution for it, just checkout the version we want :)

It is actually impressive how quick and effective it is:

Here is the what the 3.2.2 version of TM looks like (note the top-right 3.2.2 version):


Now lets look at what the commit list looks like from Git Bash using the $ git log --online -n 15 command:


The one we want is the 89dbd47 commit (7th down).

We can now change the local files from the current version (master), into the 89dbd47 version, by executing $ git checkout 89dbd47


After that, just refreshing the browser will show that we are now in the 3.2 version


What is really powerful here is that we had a different file structure changed in seconds

To see this in action, lets open a file that was changed in VisualStudio (note the TM.tmVersion value of TM 3.2 at the top left):


Next, we will revert back our file system to the 3.2.2 version (ie. the current master version) using $ git checkout master


VisualStudio will detect the file change:


And after reloading the file we will back to version 3.2.2



Finally, since TeamMentor has an Admin interface that allows the execution of Git commands, we can do these checkouts (i.e. 'version changes') directly from the web :)

Just go to the admin panel, click on the 'Advanced Admin Tools' and the 'GitHub Sync' links:


Enter the checkout -f 89dbd47 value in the TextBox and click on 'Execute Git Command'  (note: I used the -f option to force the checkout, because as you can see by the screenshot above the TeamMentor.CoreLib.dll had changed)


And we're back into the 3.2 version:


This post actually gave me an idea for a real cool feature to add in the future: Admin option: Gui to select which commit to use 

Security as TAX

Finally, remember that all of this happened because a security fix had a nasty side effect, which makes it a good example of the TAX we (developers) have to pay when adding security to our apps (remember that the CSRF fix added NO value to the app since it didn't improve its user-value, it just prevented an abuse case from happening)

OWASP Board Election: Why I voted 'Abstain' and why you should go on the record with your vote

(as sent to the owasp-leaders list)

I actually wanted to write a long email about his, but since I'm running out of time, here is the short version:

I just voted Abstain on the Board Election because I think that OWASP needs a new structure and the sooner we replace the current Board, Committees, etc.. with something that works, the better.

Monday, 15 October 2012

If you need to send me a big file, use YouSendIt

Here is the link: https://dropbox.yousendit.com/DinisCruz

Posting this here, after spending another 10m trying to find this link :)

Gravizapa - a Taint Tracking System

Meder Kydyraliev presentation on HITB 2012 on the Defibrilating Web Security (pdf) talks about the powerful concept of Taint Tracking (see from slide 31)

He details about two PoCs he wrote (in Java and Ruby) which he calls Gravizapa, although I can't seem to find any references on those PoCs in the Interweb! Any idea if has been published?

Seeing how he hooked the JVM does make me wish the CLR allowed similar techniques (at run-time).

One think he missed with Trait Tracking is how that needs to be supported by SAST/Rules-analysis tools, since we will need to codify the app's behaviour (in order to deliver meaningful results)

Web C# REPL now supports Snippet Save (and better logging)

Just added a couple features to the Web C# REPL:
This is what the default page looks like:

Sunday, 14 October 2012

FluenSharp Script - Create a form with 4 Sides (TreeViews)

Here is a simple O2/FluentSharp that creates a simple Form with 4 side-panels (each with a TreeView inside)



Code as Gist: