13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Security<br />

A sandbox bridge can provide this functionality. By default, cont<strong>en</strong>t loaded externally into an AIR application at<br />

runtime does not have access to any methods or properties in the main application. With a custom sandbox bridge<br />

implem<strong>en</strong>tation, a developer can provide services to the remote cont<strong>en</strong>t without exposing these methods or properties.<br />

Consider the sandbox bridge as a pathway betwe<strong>en</strong> trusted and untrusted cont<strong>en</strong>t, providing communication betwe<strong>en</strong><br />

loader and loadee cont<strong>en</strong>t without exposing object refer<strong>en</strong>ces.<br />

For more information on how to securely use sandbox bridges, see “Scripting betwe<strong>en</strong> cont<strong>en</strong>t in differ<strong>en</strong>t domains”<br />

on page 1075.<br />

Protection against dynamically g<strong>en</strong>erating unsafe SWF cont<strong>en</strong>t<br />

Adobe AIR 1.0 and later<br />

The Loader.loadBytes() method provides a way for an application to g<strong>en</strong>erate SWF cont<strong>en</strong>t from a byte array.<br />

However, injection attacks on data loaded from remote sources could do severe damage wh<strong>en</strong> loading cont<strong>en</strong>t. This is<br />

especially true wh<strong>en</strong> loading data into the application sandbox, where the g<strong>en</strong>erated SWF cont<strong>en</strong>t can access the full<br />

set of AIR APIs.<br />

There are legitimate uses for using the loadBytes() method without g<strong>en</strong>erating executable SWF code. You can use<br />

the loadBytes() method to g<strong>en</strong>erate an image data to control the timing of image display, for example. There are also<br />

legitimate uses that do rely on executing code, such as dynamic creation of SWF cont<strong>en</strong>t for audio playback. In AIR,<br />

by default the loadBytes() method does not let you load SWF cont<strong>en</strong>t; it only allows you to load image cont<strong>en</strong>t. In<br />

AIR, the loaderContext property of the loadBytes() method has an allowLoadBytesCodeExecution property,<br />

which you can set to true to explicitly allow the application to use loadBytes() to load executable SWF cont<strong>en</strong>t. The<br />

following code shows how to use this feature:<br />

var loader:Loader = new Loader();<br />

var loaderContext:LoaderContext = new LoaderContext();<br />

loaderContext.allowLoadBytesCodeExecution = true;<br />

loader.loadBytes(bytes, loaderContext);<br />

If you call loadBytes() to load SWF cont<strong>en</strong>t and the allowLoadBytesCodeExecution property of the<br />

LoaderContext object is set to false (the default), the Loader object throws a SecurityError exception.<br />

Note: In a future release of Adobe AIR, this API may change. Wh<strong>en</strong> that occurs, you may need to recompile cont<strong>en</strong>t that<br />

uses the allowLoadBytesCodeExecution property of the LoaderContext class.<br />

Best security practices for developers<br />

Adobe AIR 1.0 and later<br />

Although AIR applications are built using web technologies, it is important for developers to note that they are not<br />

working within the browser security sandbox. This means that it is possible to build AIR applications that can do harm<br />

to the local system, either int<strong>en</strong>tionally or unint<strong>en</strong>tionally. AIR attempts to minimize this risk, but there are still ways<br />

where vulnerabilities can be introduced. This topic covers important pot<strong>en</strong>tial insecurities.<br />

Last updated 6/6/2012<br />

1080

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!