Friday, May 27, 2011

HTML in AIR: Part 16

Today we will learn a little bit about security when we're loading HTML into AIR.

As you already know, AIR gives a lot of opportunities for the HTML content and Javascript, that is loaded into the application. AIR lets JS refer to the AIR runtime and do things that it couldn't do normally.

Now imagine that someone wrote a JS code that would abuse this AIR feature and use it to pass a virus into the users computer, when he visits a HTML page using an AIR application. If all HTML pages can get so much access to AIR, there will be a lot of problems for the users of your application. This is why AIR has a special security system for this.

All the HTML content we load into AIR is loaded into one of the two security sandboxes, and each has its own rules for what HTML/Javascript content can or can't do with AIR.

The first sandbox is called application sandbox, and this where all the content that is loaded from the application domain goes. The application domain includes all the content that is located in the same directory where the AIR application is installed.

The second sandbox is called nonapplication sandbox, and this is where all the stuff from nonapplication domain goes. This includes HTML pages loaded from the internet.

As I said before, each of the sandbox has its own rules for the HTML/Javascript content for security reasons.

Here are some limitations that take place in the application sandbox:

  • You can't load external JavaScript files that aren't located in the application domain.
  • You can't use URI javascript scheme.
  • You can't analyze script elements using innerHTML and outerHTML properties.
  • You can't use the eval() method with arguments that aren't objects or constants.
  • The setTimerout() and setInterval() methods can only be used for calling functions.

These limitations are needed to provide some security for the users. While it doesn't guarantee 100% safety, it still sets a good security level.

However, files that are loaded from nonapplication domains, have no limitations. This is logical, because they can't get access to AIR API anyway. This means that such file doesn't have to meet all those limitations stated above, but it still can't be a threat to the user as it can't abuse the AIR API.

And that's all for today.

Thank you for reading!


HTML in AIR: Part 1
HTML in AIR: Part 2
HTML in AIR: Part 3
HTML in AIR: Part 4
HTML in AIR: Part 5
HTML in AIR: Part 6
HTML in AIR: Part 7
HTML in AIR: Part 8
HTML in AIR: Part 9
HTML in AIR: Part 10
HTML in AIR: Part 11
HTML in AIR: Part 12
HTML in AIR: Part 13
HTML in AIR: Part 14
HTML in AIR: Part 15
HTML in AIR: Part 17

No comments:

Post a Comment