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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Security<br />

Sandbox bridge example (HTML)<br />

Adobe AIR 1.0 and later<br />

In HTML cont<strong>en</strong>t, the par<strong>en</strong>tSandboxBridge and childSandboxBridge properties are added to the JavaScript<br />

window object of a child docum<strong>en</strong>t. For an example of how to set up bridge functions in HTML cont<strong>en</strong>t, see “Setting<br />

up a sandbox bridge interface” on page 997.<br />

Limiting API exposure<br />

Adobe AIR 1.0 and later<br />

Wh<strong>en</strong> exposing sandbox bridges, it's important to expose high-level APIs that limit the degree to which they can be<br />

abused. Keep in mind that the cont<strong>en</strong>t calling your bridge implem<strong>en</strong>tation may be compromised (for example, via a<br />

code injection). So, for example, exposing a readFile(path:String) method (that reads the cont<strong>en</strong>ts of an arbitrary<br />

file) via a bridge is vulnerable to abuse. It would be better to expose a readApplicationSetting() API that doesn't<br />

take a path and reads a specific file. The more semantic approach limits the damage that an application can do once<br />

part of it is compromised.<br />

More Help topics<br />

“Cross-scripting cont<strong>en</strong>t in differ<strong>en</strong>t security sandboxes” on page 996<br />

“The AIR application sandbox” on page 1034<br />

Writing to disk<br />

Adobe AIR 1.0 and later<br />

Applications running in a web browser have only limited interaction with the user's local file system. Web browsers<br />

implem<strong>en</strong>t security policies that <strong>en</strong>sure that a user's computer cannot be compromised as a result of loading web<br />

cont<strong>en</strong>t. For example, SWF files running through Flash Player in a browser cannot directly interact with files already<br />

on a user's computer. Shared objects and cookies can be writt<strong>en</strong> to a user's computer for the purpose of maintaining<br />

user prefer<strong>en</strong>ces and other data, but this is the limit of file system interaction. Because AIR applications are natively<br />

installed, they have a differ<strong>en</strong>t security contract, one which includes the capability to read and write across the local<br />

file system.<br />

This freedom comes with high responsibility for developers. Accid<strong>en</strong>tal application insecurities jeopardize not only<br />

the functionality of the application, but also the integrity of the user's computer. For this reason, developers should<br />

read “Best security practices for developers” on page 1080.<br />

AIR developers can access and write files to the local file system using several URL scheme conv<strong>en</strong>tions:<br />

URL scheme Description<br />

app:/ An alias to the application directory. Files accessed from this path are assigned the application sandbox and have<br />

the full privileges granted by the runtime.<br />

app-storage:/ An alias to the local storage directory, standardized by the runtime. Files accessed from this path are assigned a<br />

non-application sandbox.<br />

file:/// An alias that repres<strong>en</strong>ts the root of the user's hard disk. A file accessed from this path is assigned an application<br />

sandbox if the file exists in the application directory, and a non-application sandbox otherwise.<br />

Note: AIR applications cannot modify cont<strong>en</strong>t using the app: URL scheme. Also, the application directory may be read<br />

only because of administrator settings.<br />

Last updated 6/6/2012<br />

1078

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

Saved successfully!

Ooh no, something went wrong!