SKITSANOS FOR RIA

Skitsanos

Wednesday, December 22, 2010

No Callbacks Required: StratifiedJS Returns Sequential Programming to JavaScript

JavaScript is fundamentally single threaded, no parallel threads in sight. Asynchronous programming is necessary for any task that might block; JavaScript programming usually involves creating and passing around a lot of callbacks, essentially forcing the developer to manually translate sequential code into continuation passing style.

One solution was introduced at the Emerging Languages Camp at OSCON 2010: StratifiedJS. The language is essentially JavaScript with a few more keywords and concurrency constructs which permit the developer to write sequential code. Yet it all still runs on normal JavaScript engines that come in todays browsers.

How's that possible? InfoQ talked to Alexander Fritze, CTO of Onilabs, to find out. Onilabs is behind Apollo, a free and MIT licensed, browser based implementation of StratifiedJS.

More at http://www.infoq.com/articles/stratifiedjs

Sunday, September 19, 2010

ASP.NET Security Vulnerability

Source: ScottGu’s Blog
few hours ago we released a Microsoft Security Advisory about a security vulnerability in ASP.NET.  This vulnerability exists in all versions of ASP.NET.

This vulnerability was publically disclosed late Friday at a security conference.  We recommend that all customers immediately apply a workaround (described below) to prevent attackers from using this vulnerability against your ASP.NET applications.

What does the vulnerability enable?
An attacker using this vulnerability can request and download files within an ASP.NET Application like the web.config file (which often contains sensitive data).
At attacker exploiting this vulnerability can also decrypt data sent to the client in an encrypted state (like ViewState data within a page).
How the Vulnerability Works
To understand how this vulnerability works, you need to know about cryptographic oracles. An oracle in the context of cryptography is a system which provides hints as you ask it questions. In this case, there is a vulnerability in ASP.NET which acts as a padding oracle. This allows an attacker to send cipher text to the web server and learn if it was decrypted properly by examining which error code was returned by the web server.  By making many such requests (and watching what errors are returned) the attacker can learn enough to successfully decrypt the rest of the cipher text.
How to Workaround The Vulnerability
A workaround you can use to prevent this vulnerability is to enable the <customErrors> feature of ASP.NET, and explicitly configure your applications to always return the same error page - regardless of the error encountered on the server. By mapping all error pages to a single error page, you prevent a hacker from distinguishing between the different types of errors that occur on a server.
Important: It is not enough to simply turn on CustomErrors or have it set to RemoteOnly. You also need to make sure that all errors are configured to return the same error page.  This requires you to explicitly set the “defaultRedirect” attribute on the <customErrors> section and ensure that no per-status codes are set.
Enabling the Workaround on ASP.NET V1.0 to V3.5
If you are using ASP.NET 1.0, ASP.NET 1.1, ASP.NET 2.0, or ASP.NET 3.5 then you should follow the below steps to enable <customErrors> and map all errors to a single error page:
1) Edit your ASP.NET Application’s root Web.Config file.  If the file doesn’t exist, then create one in the root directory of the application.
2) Create or modify the <customErrors> section of the web.config file to have the below settings:
<configuration>        

<system.web>

<customErrors mode="On" defaultRedirect="~/error.html" />

</system.web>        

</configuration>
3) You can then add an error.html file to your application that contains an appropriate error page of your choosing (containing whatever content you like).  This file will be displayed anytime an error occurs within the web application.

Notes: The important things to note above is that customErrors is set to “on”, and that all errors are handled by the defaultRedirect error page.  There are not any per-status code error pages defined – which means that there are no <error> sub-elements within the <customErrors> section.  This avoids an attacker being able to differentiate why an error occurred on the server, and prevents information disclosure
Enabling the Workaround on ASP.NET V3.5 SP1 and ASP.NET 4.0
If you are using ASP.NET 3.5 SP1 or ASP.NET 4.0 then you should follow the below steps to enable <customErrors> and map all errors to a single error page:

1) Edit your ASP.NET Application’s root Web.Config file.  If the file doesn’t exist, then create one in the root directory of the application.

2) Create or modify the <customErrors> section of the web.config file to have the below settings.  Note the use of redirectMode=”ResponseRewrite” with .NET 3.5 SP1 and .NET 4.0:
<configuration>

<system.web>

<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/error.aspx" />

</system.web>

</configuration>

3) You can then add an Error.aspx to your application that contains an appropriate error page of your choosing (containing whatever content you like).  This file will be displayed anytime an error occurs within the web application.

4) We recommend adding the below code to the Page_Load() server event handler within the Error.aspx file to add a random, small sleep delay. This will help to further obfuscate errors.

VB Version

Below is a VB version of an Error.aspx file that you can use, and which has a random, small sleep delay in it.  You do not need to compile this into an application – you can optionally just save this Error.aspx file into the application directory on your web-server:
<%@ Page Language="VB" AutoEventWireup="true" %>
<%@ Import Namespace="System.Security.Cryptography" %>
<%@ Import Namespace="System.Threading" %>

<script runat="server">
Sub Page_Load()
Dim delay As Byte() = New Byte(0) {}
Dim prng As RandomNumberGenerator = New RNGCryptoServiceProvider()

prng.GetBytes(delay)
Thread.Sleep(CType(delay(0), Integer))

Dim disposable As IDisposable = TryCast(prng, IDisposable)
If Not disposable Is Nothing Then
disposable.Dispose()
End If
End Sub
</script>

<html>
<head runat="server">
<title>Error</title>
</head>
<body>
<div>
Sorry - an error occured
</div>
</body>
</html>

C# Version

Below is a C# version of an Error.aspx file that you can use, and which has a random, small sleep delay in it.  You do not need to compile this into an application – you can optionally just save it into the application directory on your web-server:
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Security.Cryptography" %>
<%@ Import Namespace="System.Threading" %>

<script runat="server">
void Page_Load() {
byte[] delay = new byte[1];
RandomNumberGenerator prng = new RNGCryptoServiceProvider();

prng.GetBytes(delay);
Thread.Sleep((int)delay[0]);

IDisposable disposable = prng as IDisposable;
if (disposable != null) { disposable.Dispose(); }
}
</script>

<html>
<head runat="server">
<title>Error</title>
</head>
<body>
<div>
An error occurred while processing your request.
</div>
</body>
</html>
How to Verify if the Workaround is Enabled
Once you have applied the above workaround, you can test to make sure the <customErrors> section is correctly configured by requesting a URL like this from your site: http://mysite.com/pagethatdoesnotexist.aspx

If you see the custom error page appear (because the file you requested doesn’t exist) then your configuration should be setup correctly.  If you see a standard ASP.NET error then it is likely that you missed one of the steps above.  To see more information about what might be the cause of the problem, you can try setting <customErrors mode=”remoteOnly”/> – which will enable you to see the error message if you are connecting to the site from a local browser.
How to Find Vulnerable ASP.NET Applications on Your Web Server
We have published a .vbs script that you can save and run on your web-server to determine if there are ASP.NET applications installed on it that either have <customErrors> turned off, or which differentiate error messages depending on status codes.

You can download the .vbs script here.  Simply copy/paste the script into a text file called “DetectCustomErrors.vbs” and save it to disk.  Then launch a command window that is elevated as admin and run “cscript DetectCustomErrors.vbs” to run it against your local web-server.  It will enumerate all of the applications within your web server and verify that the correct <customErrors> configuration has been specified.

command[1]


It will flag any application where it finds that an application’s web.config file doesn’t have the <customErrors> section (in which case you need to add it), or doesn’t have it set correctly to workaround this attack (in which case you need to update it).  It will print “ok” for each application web.config file it finds that is fine.  This should hopefully make it easier to locate issues.

Note: We have developed this detection script over the last few hours, and will be refining it further in the future.  I will post an update in this section each time we make a change to it.
How to Find More Information about this Vulnerability
You can learn more about this vulnerability from:
Forum for Questions
We have setup a dedicated forum on the www.asp.net site to help answer questions about this vulnerability.

Post questions here to ask questions and get help about this vulnerability.
Summary
We will post more details as we learn more, and will also be releasing a patch that can be used to correct the root cause of the issue (and avoid the need for the above workaround).

Until then, please apply the above workaround to all of your ASP.NET applications to prevent attackers from exploiting it.

Turning HTML Tables Into Advanced Editable Components

EditableGrid is an open source Javascript library aimed at turning HTML tables into advanced editable components. It focuses on simplicity: only a few lines of code are required to get your first table up and running.

It loads grid from XML or attach to an existing HTML table. Built-in validators for columns of type integer, double, url, email and date. Sort columns accordingly to their types, by clicking on the column header. Open Flash Chart integration to render charts from the grid data. Callbacks for all events: load, edition, sorting, etc.

editable-grid

Requirements: Javascript Enabled
Demo: http://www.webismymind.be/editablegrid/
License: GPL License

Easy To Use jQuery Plugin For Radical Web Typography

Web Typography is exploding all over the web. In many instances we would need to style individual letters. We need a system to keep our markup maintainable. Something agile enough that a text change wouldn’t ruin us.

The solution was to call upon the power of Javascript to insert some easy to remember span tags. Here we haveLettering.JS which is a lightweight, easy to use jQuery plugin for radical Web Typography.

lettering-js

Requirements: jQuery Framework
Demo: http://daverupert.com/2010/09/lettering-js/
License: WTFPL License

Saturday, September 18, 2010

jQuery UI 1.8.5

The fifth maintenance release for jQuery UI 1.8 is out. This update brings bug fixes for jQuery UI Core, the Widget Factory and the Position utility as well as the Autocomplete, Button, Datepicker Dialog, and Tabs widgets. For the full list of changes, see the changelog. You can download it here:

Download

File Downloads

Svn (CONTAINS FINAL FILES AS THEY ARE IN THE ZIP, WITH @VERSION REPLACED WITH 1.8.5, ALL THEMES)

Git (CONTAINS PRE-BUILD FILES, WITH @VERSION NOT YET REPLACED WITH 1.8.5, BASE THEME ONLY)

Google Ajax Libraries API (CDN)

Microsoft Ajax CDN (CDN)

Custom Download Builder

New CDN

We’re pleased to announce that Microsoft is now hosting jQuery UI on the Microsoft Ajax CDN. Microsoft is hosting uncompressed and compressed versions as well as all of our pre-built themes. For more information check out Stephen Walther’s announcement from Microsoft.

New Features

In this release, we’ve added jQuery.support.minHeight which detects whether the browser supports the minHeight style.

DIALOG

You can now pass an object containing specific properties to set in the buttons option.

Changelog

See the 1.8.5 Upgrade Guide for a list of changes that may affect you when upgrading from 1.8.4. For full details on what’s included in this release see the 1.8.5 Changelog.

Saturday, September 11, 2010

WDK.API.CouchDb for upcoming SiteAdmin CMS

SiteAdmin CMS on CouchDBAs you probably heard already about our plans to drop completely support for SQL Server and run away from from this ugly monster, so after all we decided to move new SiteAdmin CMS build entirely on Apache CouchDB (http://couchdb.apache.org/ for more details). CouchDB has too many benefits to ignore, plus for content management i i couldn’t think of better option for the moment. for past few years SiteAdmin CMS content objects were serialized into XML and stored into XML fields in SQL Server, which is not exactly the best way of doing things.

So, in order to move existing content objects into CouchDB we actually needed some database client that allows us to connect to CouchDb and do the job quickly without overloading us and our users with complex syntax. Initially i went through bunch of .NET implementations of CouchDB clients, like Divan, SharpCouch and God knows what else it was, yea some of them were quite interesting and complete, but problem mainly with them that they are too complex. (Come on guys why you have to write things in ugly ways? Just because you learned some how-to-be-MVP bullshit in a book last night or been sitting you ass down in university for 5 years and had nothing better to do? What about keeping thing just simple?)

As i was saying, we need something simple that does the job right and quickly, so here we go: WDK. API.CouchDb library for SiteAdmin CMS (well, actually you can use it outside of SiteAdmin CMS, as any other libraries from Skitsanos WDK.* set).

Some of the features available at this moment:

  • Get database server version;
  • Get list of databases
  • Check if database exists
  • Create database
  • Count documents in database
  • Get documents
  • Create document
  • Create design document
  • Get document by ID
  • Get design view
  • Delete document

Couple of code examples in VB.NET:

Dim db As New WDK.API.CouchDb("localhost", 5984)

'- get database server version 
Debug.WriteLine(db.Version)

Dim dbs As List(Of String) = db.getDatabases 
Debug.WriteLine(dbs.Count)

'- Get list of databases 
db.getDatabases()

'- Check if database exists
Debug.WriteLine(db.databaseExists("siteadmincms2"))

'- Create a Database 
db.createDatabase("siteadmincms")

'- Count documents in the database 
db.countDocuments("siteadmincms")

'- Get All documents 
Dim docs As List(Of DocumentInfo) = db.getAllDocuments("siteadmincms")

'- create document 
Dim entry As New LogEntryType 
entry.content = "testing... (" + Now.ToString + ")" 
db.createDocument("siteadmincms", entry)

'- create design document 
db.createDesignDocument("siteadmincms", "ApplicationLog", "showAll", "function(doc){if (doc.type && doc.type == 'LogEntryType') emit(doc.createdOn, doc);}")

'- Get document by ID 
Debug.WriteLine(db.getDocumentAsJson("siteadmincms", "_design/ApplicationLog")) 
Debug.WriteLine(db.getDocumentAsJson("siteadmincms", "4ac4e0e0f94b1e73e40403d1b3008628")) 
Dim entry As LogEntryType = db.getDocument(Of LogEntryType)("siteadmincms", "4ac4e0e0f94b1e73e40403d1b3008628") 
Debug.WriteLine(entry.content)

'- delete document by id 
db.deleteDocument("siteadmincms", "4ac4e0e0f94b1e73e40403d1b3008628")

'-get all documents via design view 
Dim di As Object = db.getDesignView(Of LogEntryType)("siteadmincms", "ApplicationLog", "showAll")

Hope this help you anyhow.

Friday, September 10, 2010

jQuery Powered Full Page Scrollable Image Gallery

Codrops is sharing a stunning Full Page Image Gallery with scrollable thumbnails and a scrollable full screen preview.

It has a thumbnails bar at the bottom of the page that scrolls automatically when user moves the mouse. When a thumbnail is clicked, it moves to the center of the page and the full screen image is loaded in the background.

jQuery Powered Full Page Scrollable Image Gallery

The demo is best viewed in Webkit browsers like Google Chrome or Apple Safari because this full page image gallery is using CSS3 Webkit properties to enhance the look and jQuery for the functionality.

The image gallery comes with a handy tutorial that is very easy to understand and follow.

Website: http://tympanus.net/codrops/2010/09/08/full-page-image-gallery/

Webware development dedicated blog by Skitsanos R&D Labs. ASP.NET, XML, RIA, Adobe Flex, ActionScript 3, AIR, AJAX, Web 2.0, Backbase, CGI development with RealBasic and other web development issues.
News
Downloads