1. /*
  2. * @(#)RuntimePermission.java 1.34 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.lang;
  8. import java.security.*;
  9. import java.util.Enumeration;
  10. import java.util.Hashtable;
  11. import java.util.StringTokenizer;
  12. /**
  13. * This class is for runtime permissions. A RuntimePermission
  14. * contains a name (also referred to as a "target name") but
  15. * no actions list; you either have the named permission
  16. * or you don't.
  17. *
  18. * <P>
  19. * The target name is the name of the runtime permission (see below). The
  20. * naming convention follows the hierarchical property naming convention.
  21. * Also, an asterisk
  22. * may appear at the end of the name, following a ".", or by itself, to
  23. * signify a wildcard match. For example: "loadLibrary.*" or "*" is valid,
  24. * "*loadLibrary" or "a*b" is not valid.
  25. * <P>
  26. * The following table lists all the possible RuntimePermission target names,
  27. * and for each provides a description of what the permission allows
  28. * and a discussion of the risks of granting code the permission.
  29. * <P>
  30. *
  31. * <table border=1 cellpadding=5>
  32. * <tr>
  33. * <th>Permission Target Name</th>
  34. * <th>What the Permission Allows</th>
  35. * <th>Risks of Allowing this Permission</th>
  36. * </tr>
  37. *
  38. * <tr>
  39. * <td>createClassLoader</td>
  40. * <td>Creation of a class loader</td>
  41. * <td>This is an extremely dangerous permission to grant.
  42. * Malicious applications that can instantiate their own class
  43. * loaders could then load their own rogue classes into the system.
  44. * These newly loaded classes could be placed into any protection
  45. * domain by the class loader, thereby automatically granting the
  46. * classes the permissions for that domain.</td>
  47. * </tr>
  48. *
  49. * <tr>
  50. * <td>getClassLoader</td>
  51. * <td>Retrieval of a class loader (e.g., the class loader for the calling
  52. * class)</td>
  53. * <td>This would grant an attacker permission to get the
  54. * class loader for a particular class. This is dangerous because
  55. * having access to a class's class loader allows the attacker to
  56. * load other classes available to that class loader. The attacker
  57. * would typically otherwise not have access to those classes.</td>
  58. * </tr>
  59. *
  60. * <tr>
  61. * <td>setContextClassLoader</td>
  62. * <td>Setting of the context class loader used by a thread</td>
  63. * <td>The context class loader is used by system code and extensions
  64. * when they need to lookup resources that might not exist in the system
  65. * class loader. Granting setContextClassLoader permission would allow
  66. * code to change which context class loader is used
  67. * for a particular thread, including system threads.</td>
  68. * </tr>
  69. *
  70. * <tr>
  71. * <td>setSecurityManager</td>
  72. * <td>Setting of the security manager (possibly replacing an existing one)
  73. * </td>
  74. * <td>The security manager is a class that allows
  75. * applications to implement a security policy. Granting the setSecurityManager
  76. * permission would allow code to change which security manager is used by
  77. * installing a different, possibly less restrictive security manager,
  78. * thereby bypassing checks that would have been enforced by the original
  79. * security manager.</td>
  80. * </tr>
  81. *
  82. * <tr>
  83. * <td>createSecurityManager</td>
  84. * <td>Creation of a new security manager</td>
  85. * <td>This gives code access to protected, sensitive methods that may
  86. * disclose information about other classes or the execution stack.</td>
  87. * </tr>
  88. *
  89. * <tr>
  90. * <td>exitVM</td>
  91. * <td>Halting of the Java Virtual Machine</td>
  92. * <td>This allows an attacker to mount a denial-of-service attack
  93. * by automatically forcing the virtual machine to halt.</td>
  94. * </tr>
  95. *
  96. * <tr>
  97. * <td>setFactory</td>
  98. * <td>Setting of the socket factory used by ServerSocket or Socket,
  99. * or of the stream handler factory used by URL</td>
  100. * <td>This allows code to set the actual implementation
  101. * for the socket, server socket, stream handler, or RMI socket factory.
  102. * An attacker may set a faulty implementation which mangles the data
  103. * stream.</td>
  104. * </tr>
  105. *
  106. * <tr>
  107. * <td>setIO</td>
  108. * <td>Setting of System.out, System.in, and System.err</td>
  109. * <td>This allows changing the value of the standard system streams.
  110. * An attacker may change System.in to monitor and
  111. * steal user input, or may set System.err to a "null" OutputSteam,
  112. * which would hide any error messages sent to System.err. </td>
  113. * </tr>
  114. *
  115. * <tr>
  116. * <td>modifyThread</td>
  117. * <td>Modification of threads, e.g., via calls to Thread <code>stop</code>,
  118. * <code>suspend</code>, <code>resume</code>, <code>setPriority</code>,
  119. * and <code>setName</code> methods</td>
  120. * <td>This allows an attacker to start or suspend any thread
  121. * in the system.</td>
  122. * </tr>
  123. *
  124. * <tr>
  125. * <td>stopThread</td>
  126. * <td>Stopping of threads via calls to the Thread <code>stop</code>
  127. * method</td>
  128. * <td>This allows code to stop any thread in the system provided that it is
  129. * already granted permission to access that thread.
  130. * This poses as a threat, because that code may corrupt the system by
  131. * killing existing threads.</td>
  132. * </tr>
  133. *
  134. * <tr>
  135. * <td>modifyThreadGroup</td>
  136. * <td>modification of thread groups, e.g., via calls to ThreadGroup
  137. * <code>destroy</code>, <code>resume</code>, <code>setDaemon</code>,
  138. * <code>setMaxPriority</code>, <code>stop</code>, and <code>suspend</code>
  139. * methods</td>
  140. * <td>This allows an attacker to create thread groups and
  141. * set their run priority.</td>
  142. * </tr>
  143. *
  144. * <tr>
  145. * <td>getProtectionDomain</td>
  146. * <td>Retrieval of the ProtectionDomain for a class</td>
  147. * <td>This allows code to obtain policy information
  148. * for a particular code source. While obtaining policy information
  149. * does not compromise the security of the system, it does give
  150. * attackers additional information, such as local file names for
  151. * example, to better aim an attack.</td>
  152. * </tr>
  153. *
  154. * <tr>
  155. * <td>readFileDescriptor</td>
  156. * <td>Reading of file descriptors</td>
  157. * <td>This would allow code to read the particular file associated
  158. with the file descriptor read. This is dangerous if the file contains
  159. confidential data.</td>
  160. * </tr>
  161. *
  162. * <tr>
  163. * <td>writeFileDescriptor</td>
  164. * <td>Writing to file descriptors</td>
  165. * <td>This allows code to write to a particular file associated
  166. with the descriptor. This is dangerous because it may allow malicous
  167. code to plant viruses or at the very least, fill up your entire disk.</td>
  168. * </tr>
  169. *
  170. * <tr>
  171. * <td>loadLibrary.{library name}</td>
  172. * <td>Dynamic linking of the specified library</td>
  173. * <td>It is dangerous to allow an applet permission to load native code
  174. * libraries, because the Java security architecture is not designed to and
  175. * does not prevent malicious behavior at the level of native code.</td>
  176. * </tr>
  177. *
  178. * <tr>
  179. * <td>accessClassInPackage.{package name}</td>
  180. * <td>Access to the specified package via a class loader's
  181. * <code>loadClass</code> method when that class loader calls
  182. * the SecurityManager <code>checkPackageAcesss</code> method</td>
  183. * <td>This gives code access to classes in packages
  184. * to which it normally does not have access. Malicious code
  185. * may use these classes to help in its attempt to compromise
  186. * security in the system.</td>
  187. * </tr>
  188. *
  189. * <tr>
  190. * <td>defineClassInPackage.{package name}</td>
  191. * <td>Definition of classes in the specified package, via a class
  192. * loader's <code>defineClass</code> method when that class loader calls
  193. * the SecurityManager <code>checkPackageDefinition</code> method.</td>
  194. * <td>This grants code permission to define a class
  195. * in a particular package. This is dangerous because malicious
  196. * code with this permission may define rogue classes in
  197. * trusted packages like <code>java.security</code> or <code>java.lang</code>,
  198. * for example.</td>
  199. * </tr>
  200. *
  201. * <tr>
  202. * <td>accessDeclaredMembers</td>
  203. * <td>Access to the declared members of a class</td>
  204. * <td>This grants code permission to query a class for its public,
  205. * protected, default (package) access, and private fields and/or
  206. * methods. Although the code would have
  207. * access to the private and protected field and method names, it would not
  208. * have access to the private/protected field data and would not be able
  209. * to invoke any private methods. Nevertheless, malicious code
  210. * may use this information to better aim an attack.
  211. * Additionally, it may invoke any public methods and/or access public fields
  212. * in the class. This could be dangerous if
  213. * the code would normally not be able to invoke those methods and/or
  214. * access the fields because
  215. * it can't cast the object to the class/interface with those methods
  216. * and fields.
  217. </td>
  218. * </tr>
  219. * <tr>
  220. * <td>queuePrintJob</td>
  221. * <td>Initiation of a print job request</td>
  222. * <td>This could print sensitive information to a printer,
  223. * or simply waste paper.</td>
  224. * </tr>
  225. *
  226. * </table>
  227. *
  228. * @see java.security.BasicPermission
  229. * @see java.security.Permission
  230. * @see java.security.Permissions
  231. * @see java.security.PermissionCollection
  232. * @see java.lang.SecurityManager
  233. *
  234. * @version 1.34 01/11/29
  235. *
  236. * @author Marianne Mueller
  237. * @author Roland Schemers
  238. */
  239. public final class RuntimePermission extends BasicPermission {
  240. /**
  241. * Creates a new RuntimePermission with the specified name.
  242. * The name is the symbolic name of the RuntimePermission, such as
  243. * "exit", "setFactory", etc. An asterisk
  244. * may appear at the end of the name, following a ".", or by itself, to
  245. * signify a wildcard match.
  246. *
  247. * @param name the name of the RuntimePermission.
  248. */
  249. public RuntimePermission(String name)
  250. {
  251. super(name);
  252. }
  253. /**
  254. * Creates a new RuntimePermission object with the specified name.
  255. * The name is the symbolic name of the RuntimePermission, and the
  256. * actions String is currently unused and should be null. This
  257. * constructor exists for use by the <code>Policy</code> object
  258. * to instantiate new Permission objects.
  259. *
  260. * @param name the name of the RuntimePermission.
  261. * @param actions should be null.
  262. */
  263. public RuntimePermission(String name, String actions)
  264. {
  265. super(name, actions);
  266. }
  267. }