| 21.2 Combining Features into Policies |
|
|
Security policies add power to the Safe Base interpreter so that a tclet that runs under them is not blind to the outside world. The added power involves access to files, to Web resources, to an electronic mail system, to a Web browser, and to arbitrary TCP/IP connections. These powers have been divided into security features. A feature is a Tcl script that runs in the plugin's master interpreter and customizes the slave that executes a tclet. Tclets cannot execute features directly tclets cause them to be executed by requesting a security policy with the policy command as described below in Writing Tclets. Several features are shipped with version 2.0 of the plugin. These are configured in different ways to create all of the shipped security policies. They can be configured in other ways for new policies. For example, if you want a policy that is something like the home policy but different, then give it a name, POLICY and make a copy of home.cfg named POLICY.cfg. Then edit POLICY.cfg to create the desired policy and plugin.cfg to enable POLICY for the desired tclets. Do not change any of the configuration files for the home, javascript, or trusted policies. The inside and outside policies, however, are not fully configured as shipped. It is expected that you will edit their configuration files. This is discussed at the end of the section. Security policies are configured by declaring which features they use and by configuring those features. Each policy begins with a features section with allow statements that enable the desired features. For example, the home policy begins with the following section.
section features
allow url
allow network
allow persist unless {[string match {UNKNOWN *} [getattr originURL]]}
The final statement enables access to the persist feature only when the
originating URL could be determined.
A feature is configured much like a policy but it is configured in a policy's configuration file. Whereas a tclet can run only one policy per execution, there is no limit on the way features may be combined in one security policy. Here are the features shipped with version 2.0 of the plugin.
PersistTo use the persist feature, a security policy must have allow persist in its features section. To configure this policy, its configuration file must have a section introduced with section persist. Configuration consists of setting some parameters. Here, for example, is the way it is configured in javascript.cfg. # Number of allowed open files constant openFilesLimit 4 # Number of allowed files in the persist storage directory constant storedFilesLimit 6 # Max size of each file (in bytes): here we give 128K per file. constant fileSizeLimit [expr 128*1024] The method for choosing the persistent storage directory is complicated. In the previous section under "Persistent Storage for Tclets", I described it as an injection from the set of pairs of URL paths and policy names without bothering to describe the exact nature of the injection. The directory for persistent storage is changed by altering the input to this injection: the tclet writer has a little flexibility in determining which URL path is used and the system administrator has complete flexibility in determining which policy name is used. This declaration, constant storage NAMEwill cause NAME to be the policy name used when determining the directory for persistent storage. Changing the name of a policy for storage purposes enables a system administrator to permit tclets running under different policies persistent storage. Were I you, I would be quite leery of doing this. Remark
Url
To use the url feature, a security policy must have allow url in its features section. To configure this policy, its configuration file must have a section introduced with section urls. Configuration consists of some enabling statements that define the URLs that a tclet can access. Here is an example. section urls allow *This section (or something very similar) is used to permit tclets running under the home, javascript, and trusted policies to access any URL. Remark
NetworkTo use the network feature, a security policy must have allow network in its features section. To configure this policy, its configuration file must have a section introduced with section hosts ports. Configuration consists of enabling statements that define the hosts and ports that may be used for a TCP/IP connection. The home policy, for example, has this section: # What addresses can be used in a socket command? section hosts ports # Expected format (by the network feature): # allow <hostPattern> <portPattern> allow $originSocketHost >1024 allow $originSocketHost 21This permits access to ftp services at port 21 plus additional nonstandard services that use ports numbered above 1024. Either way, the only host whose ports can be used is $originSocketHost, that is, the host identifier which the plugin has determined you should use in connecting back to the server from which the tclet was fetched. Remark
Other FeaturesThe unsafe feature needs no additional configuration it simply permits everything to be done. The stream feature can be reconfigured but a description of how to do so would take us far from the subject matter of this book into mime types and browser characteristics. There is also a "browser policy" which is misnamed and is really a feature. This feature has been adopted from an earlier version of the plugin to give access to the browser. I do not discuss this feature because the discussion would take us far from the subject matter of this book and also because it would take us into something that seems unfinished and therefore likely to change. The point of these policies is to draw a line between tclets that deal with your organization's internal data and those that deal with the rest of the world. These policies need to be configured by a system administrator. The first step is to partition the world of Internet resources into those internal to your organization, those external to your organization, and those that are forbidden. Make your own decision as to why something should be forbidden. There is no a priori reason why this category should not contain resources that might otherwise be called internal or external. Remember to think in terms of all Internet resources, not just Web resources. If there is too much to think about, then place resources you do not need in the forbidden category. You can reclassify them on a case by case basis later when you have time to think about them. Once you have the world of Internet resources safely partitioned, you can start configuring the inside and outside policies and determining which tclets can run under them. Remark
You determine which Internet resources a policy can use by editing the url and network sections. Those in inside.cfg should be limited to internal resources and those in outside.cfg should be limited to external resources. You determine which tclets can run under a policy by editing policy.cfg. Create a trustedInsideURLs section and authorize only tclets that come from internal resources. Create a trustedOutsideURLs section and authorize only tclets that come from external resources. Of course, you must also change the statements that disallow the inside and outside policies to appropriate allow statements as explained in the previous section.
|
Author's Home Page |
|
Order from Amazon. |