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 />

The primary purpose of calling the Security.allowDomain() method is to grant permission for SWF files in an<br />

outside domain to script the SWF file calling the Security.allowDomain() method. For more information, see<br />

“Cross-scripting” on page 1051.<br />

Specifying an IP address as a parameter to the Security.allowDomain() method does not permit access by all parties<br />

that originate at the specified IP address. Instead, it permits access only by a party that contains the specified IP address<br />

as its URL, rather than a domain name that maps to that IP address. For example, if the domain name<br />

www.example.com maps to the IP address 192.0.34.166, a call to Security.allowDomain("192.0.34.166") does<br />

not grant access to www.example.com.<br />

You can pass the "*" wildcard to the Security.allowDomain() method to allow access from all domains. Because it<br />

grants permission for SWF files from all domains to script the calling SWF file, use the "*" wildcard with care.<br />

ActionScript includes a second permission API, called Security.allowInsecureDomain(). This method does the<br />

same thing as the Security.allowDomain() method, except that, wh<strong>en</strong> called from a SWF file served by a secure<br />

HTTPS connection, it additionally permits access to the calling SWF file by other SWF files that are served from an<br />

insecure protocol, such as HTTP. However, it is not a good security practice to allow scripting betwe<strong>en</strong> files from a<br />

secure protocol (HTTPS) and those from insecure protocols (such as HTTP); doing so can op<strong>en</strong> secure cont<strong>en</strong>t to<br />

snooping and spoofing attacks. Here is how such attacks can work: since the Security.allowInsecureDomain()<br />

method allows access to your secure HTTPS data by SWF files served over HTTP connections, an attacker interposed<br />

betwe<strong>en</strong> your HTTP server and your users could replace your HTTP SWF file with one of their own, which can th<strong>en</strong><br />

access your HTTPS data.<br />

Important: Code executing in the AIR application sandbox is not permitted to call either the allowDomain() or<br />

allowInsecureDomain() methods of the Security class.<br />

Another important security-related method is the Security.loadPolicyFile() method, which causes Flash Player<br />

to check for a policy file at a nonstandard location. For more information, see “Website controls (policy files)” on<br />

page 1040.<br />

Restricting networking APIs<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

Networking APIs can be restricted in two ways. To prev<strong>en</strong>t malicious activity, access to commonly reserved ports is<br />

blocked; you can’t override these blocks in your code. To control a SWF file’s access to network functionality with<br />

regard to other ports, you can use the allowNetworking setting.<br />

Blocked ports<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

Flash Player and Adobe AIR have restrictions on HTTP access to certain ports, as do browsers. HTTP requests are not<br />

permitted to certain standard ports that are conv<strong>en</strong>tionally used for non-HTTP types of servers.<br />

Any API that accesses a network URL is subject to these port blocking restrictions. The only exception is APIs that call<br />

sockets directly, such as Socket.connect() and XMLSocket.connect(), or calls to Security.loadPolicyFile()<br />

in which a socket policy file is being loaded. Socket connections are permitted or d<strong>en</strong>ied through the use of socket<br />

policy files on the target server.<br />

The following list shows the ActionScript 3.0 APIs to which port blocking applies:<br />

Last updated 6/6/2012<br />

1044

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

Saved successfully!

Ooh no, something went wrong!