|
All applets and any applications invoked with a security manager must be granted explicit permission to access local system resources apart from read access to the directory and its subdirectories where the program is invoked. The Java platform provides permissions to allow various levels of access to different types of local information. Because permissions let an applet or application override the default security policy, you should be very careful when you assign permissions to not create an opening for malicious code to attack your system. This appendix describes the available permissions and explains how each permission can create an opening for malicious attacks. One way to use this information is to help you limit what permissions a given applet or application might need to successfully execute. Another way to use this information is to educate yourself on the ways in which a particular permission can be exploited by malicious code. As a safeguard, never trust an unknown applet or application. Always check the code carefully against the information in this appendix to be sure you are not giving malicious code permission to cause serious problems on the local system.
Overview Permissions are granted to a program with a policy file. A policy file contains permissions for specific access. A permission consists of the permission name, a target, and in some cases, a comma-separated list of actions.
For example, the following policy file entry specifies a
grant {
permission java.io.FilePermission
"${user.home}/text2.txt", "read";
};
There is one policy file for Java platform installation (system)
and an optional policy
file for each user. The system policy file is in
To run an application with the security manager and a policy file
named java -Djava.security.main -DJava.security.policy=polfile FileIO
To run an applet in appletviewer with a policy file named
appletviewer -J-Djava.security.policy=polfile fileIO.html When running an applet in a browser, the browser looks for the user and system policy files to find the permissions the applet needs to access local system resources on behalf of the user who downloaded the applet. Knowing Which Permissions When you run an applet or invoke an application with a security manager that needs permissions, you will get a stack trace if you did not provide a policy file with all the needed permissions. The stack trace contains the information you need to add the permission to the policy file that caused the stack trace. If the program needs additional permissions, you will keep getting stack traces until all the required permissions are added to the policy file. The only drawback to this approach is you have to try every possible code path in your application. Another way to determine which permission your program needs is to browse Appendix B: Methods and Permissions. This appendix tells you which Java 2 platform software methods are prevented from executing without the listed permission. The information in Appendix B is also useful for developers who want to write their own security manager to customize the verifications and approvals needed in a program.
Here is a short example to show you how to translate the first
couple of lines in a stack trace to a policy file entry. The first
line tells you access is denied. This means this stack trace was
generated because the program tried to access a system resource
without the proper permission. The second line means you need a
java.security.AccessControlException: access denied
(java.net.SocketPermission
129.144.176.176:1521 connect,resolve)
To turn this into a policy file entry, list the permission name,
a target, and an action list as follows where
grant {
permission java.net.SocketPermission
"129.144.176.176:1521", "connect,resolve";
};
AllPermission
grant {
permission java.security.AllPermission;
};
AWTPermission
accessClipboard: This target grants permission to post information to and retrieve information from the AWT clipboard. Granting this permission could allow malicious code to share potentially sensitive or confidential information. accessEventQueue: This target grants permission to access the AWT event queue. Granting this permission could allow malicious code to peek at and remove existing events from the system, or post bogus events that could cause the application or applet to perform malicious actions. listenToAllAWTEvents: This target grants permission to listen to all AWT events throughout the system. Granting this permission could allow malicious code to read and exploit confidential user input such as passwords.
Each AWT event listener is called from within the context of
that event queue's
readDisplayPixels:
This target grants permission to read pixels back from the
display screen. Granting this permission could allow
interfaces such as showWindowWithoutWarningBanner: This target grants permission to display a window without also displaying a banner warning that the window was created by an applet. Without this warning, an applet might pop up windows without the user knowing they belong to an applet. This could be a problem in environments where users make security-sensitive decisions based on whether the window belongs to an applet or an application. For example, disabling the banner warning might trick the end user into entering sensitive user name and password information. FilePermission
This policy file grants read, write, delete, and execute permission to all files.
grant {
permission java.io.FilePermission
"<<ALL FILES>>", "read, write, delete, execute";
};
This policy file grants read and write permission to
grant {
permission java.io.FilePermission
"${user.home}/text.txt", "read, write";
};
You can use the following wild cards to specify the target pathname.
The actions are specified in a list of comma-separated keywords and have the following meanings:
When granting file permissions, always think about the implications
of granting read and especially write access to various files and
directories. The NetPermission
setDefaultAuthenticator: This target grants permission to set the way authentication information is retrieved when a proxy or HTTP server asks for authentication. Granting this permission could mean malicious code can set an authenticator that monitors and steals user authentication input as it retrieves the input from the user. requestPasswordAuthentication: This target grants permission to ask the authenticator registered with the system for a password. Granting this permission could mean malicious code might steal the password. specifyStreamHandler: This target grants permission to specify a stream handler when constructing a Uniform Resource Locator (URL). Granting this permission could mean malicious code might create a URL with resources to which it would not normally have access, or specify a stream handler that gets the actual bytes from somewhere to which it does have access. This means the malicious code could trick the system into creating a ProtectionDomain/CodeSource for a class even though the class really did not come from that location. PropertyPermission
The target list contains the name of the property;
for example, The actions are specified in a list of comma-separated keywords, and have the following meanings:
Granting property permissions can leave your system open
to intrusion. For example, granting permission to access the
ReflectPermission
grant {
permission java.lang.reflect.ReflectPermission
"suppressAccessChecks";
};
suppressAccessChecks: This target grants permission to access fields and invoke methods in a class. This includes public, protected, and private fields and methods. Granting this permission could reveal confidential information and make normally unavailable methods accessible to malicious code. RuntimePermission
The naming convention for target information where a library,
package, or class name is added follows the hierarchical
property naming convention, and includes wild cards. An asterisk at
the end of the target name, after a dot ( createClassLoader: This target grants permission to create a class loader. Granting this permission might allow a malicious application to instantiate its own class loader and load harmful classes into the system. Once loaded, the class loader could place these classes into any protection domain and give them full permissions for that domain. getClassLoader: This target grants permission to retrieve the class loader for the calling class. Granting this permission could enable malicious code to get the class loader for a particular class and load additional classes. setContextClassLoader: This target grants permission to set the context class loader used by a thread. System code and extensions use the context class loader to look up resources that might not exist in the system class loader. Granting this permission allows code to change which context class loader is used for a particular thread, including system threads. This can cause problems if the context class loader has malicious code. setSecurityManager: This target grants permission to set or replace the security manager. The security manager is a class that allows applications to implement a security policy. Granting this permission could enable malicious code to install a less restrictive manager, and thereby, bypass checks that would have been enforced by the original security manager. createSecurityManager: This target grants permission to create a new security manager. Granting this permission could give malicious code access to protected and sensitive methods that might disclose information about other classes or the execution stack. It could also allow the introduction of a weakened security manager. exitVM: This target grants permission to halt the Java VM. Granting this permission could allow malicious code to mount a denial-of-service attack by automatically forcing the VM to stop.
setFactory:
This target grants permission to set the socket factory used by
the
setIO:
This target grants permission to change the value of the
modifyThread:
This target grants permission to modify threads by calls
to the stopThread: This target grants permission to stop threads. Granting this permission allows code to stop any thread in the system provided the code already has permission to access that thread. Malicious code could corrupt the system by killing existing threads.
modifyThreadGroup:
This target grants permission to modify threads by calls to the
getProtectionDomain
This target grants permission to retrieve the readFileDescriptor: This target grants permission to read file descriptors. Granting this permission allows code to read the particular file associated with the file descriptor, which is dangerous if the file contains confidential data. writeFileDescriptor: This target grants permission to write file descriptors. Granting this permission allows code to write to the file associated with the descriptor, which is dangerous if the file descriptor points to a local file.
loadLibrary.{library name}:
This target grants permission to dynamically link the specified library.
Granting this permission could be dangerous because the security
architecture is not designed to and does not extend to native
code loaded by way of the
accessClassInPackage.{package name}
This target grants permission to access the specified package
by way of a class loader's
defineClassInPackage.{package name}:
This target grants permission to define classes in the
specified package by way of a class loader's accessDeclaredMembers: This target grants permission to access the declared members of a class. Granting this permission allows code to query a class for its public, protected, default (package), and private fields and methods. Although the code would have access to the private and protected field and method names, it would not have access to the private and protected field data and would not be able to invoke any private methods. Nevertheless, malicious code may use this information to better aim an attack. Additionally, malicious code might invoke any public methods or access public fields in the class, which could be dangerous if the code would normally not be able to invoke those methods or access the fields because it cannot cast the object to the class or interface with those methods and fields. queuePrintJob: This target grants permission to initiate a print job request. Granting this permission could allow code to print sensitive information to a printer or maliciously waste paper. SecurityPermission
getPolicy: This target grants permission to retrieve the system-wide security policy. Granting this permission discloses which permissions would be granted to a given application or applet. While revealing the policy does not compromise the security of the system, it does provide malicious code with additional information it could use to better aim an attack. setPolicy: This target grants permission to set the system-wide security policy. Granting this permission could allow malicious code to grant itself all the necessary permissions to successfully mount an attack an attack on the system.
getProperty.{key}:
This target grants permission to retrieve the security property
specified by
setProperty.{key}:
This target grants permission to set the security property
specified by
insertProvider.{provider name}:
This target grants permission to add the new security provider specified
by
removeProvider.{provider name}:
This target grants permission to remove the provider specified by
setSystemScope: This target grants permission to set the system identity scope. Granting this permission could allow an attacker to configure the system identity scope with certificates that should not be trusted. This could grant code signed with those certificates privileges that would be denied by the original identity scope.
setIdentityPublicKey:
This target grants permission to set the public key for
an
SetIdentityInfo:
This target grants permission to set a general information string
for an
addIdentityCertificate:
This target grants permission to add a certificate for an
removeIdentityCertificate:
This target grants permission to remove a certificate for
an printIdentity: This target grants permission to print out the name of a principal, the scope in which the principal is used, and whether the principal is considered trusted in that scope. The printed scope could be a filename, in which case it might convey local system information. For example, here is a sample printout of an identity named carol, who is marked not trusted in the user's identity database: carol[/home/luehe/identitydb.obj][not trusted].
clearProviderProperties.{provider name}
This target grants permission to clear a putProviderProperty.{provider name}: This target grants permission to set properties for the specified provider. The provider properties each specify the name and location of a particular service implemented by the provider. Granting this permission allows code to replace the service specification with another one with a different implementation and could be dangerous if the new implementation has malicaious code.
removeProviderProperty.{provider name}:
This target grants permission to remove properties from the
specified provider. Granting this permission disables the lookup
of services implemented by the provider making them inaccessible.
Granting this permission to malicious code could allow the
malicious code to change the behavior or disable execution
of other parts of the program that would normally utilize the
getSignerPrivateKey:
This target grants permission to retrieve the private key of a
setSignerKeyPair:
This target grants permission to set the public and private key pair
for a SerializablePermission
enableSubclassImplementation:
This target grants permission to implement a subclass of
enableSubstitution: This target grants permission to substitute one object for another during serialization or deserialization. Granting this permission could allow malicious code to replace the actual object with one that has incorrect or malignant data. SocketPermission
The
This policy file entry allows
a connection to and accepts connections on port 7777 on
the host
This policy file entry allows connections to, accepts connections on, and listens on any port between 1024 and 65535 on the local host.
The host is expressed with the following syntax
as a DNS name, as a numerical IP address,
or as host = (hostname | IPaddress)[:portrange] portrange = portnumber | -portnumber | portnumber-[portnumber]
The port or port range is optional. A port specification of the
form
The Granting code permission to accept or make connections to remote hosts may be dangerous because malevolent code can more easily transfer and share confidential data among parties that might not otherwise have access to the data.
[TOP]
_______ | |||||||||||||||
|
| ||||||||||||