JAVA Security
JAVA Security
David A. Wheeler
[email protected]
(703) 845-6662
Developer
– Libraries
• Can use only VM or language Class files
• Developed by Sun
User
• Not related to “Javascript” Libraries
• Cross-Platform (WORA) Virtual Machine
October 15, 2008 (C) 1999-2000 David A. Wheeler 3
Java Modes of Use
• Applets: Auto-run when view web page
• Applications: Traditional program (performance?)
• Beans: Component (like OLE object)
• Servlets: Server-side applications
• Aglets: Intelligent Agents
• Doclets: Configurable doc generator
• Embedded Systems
• Smart Cards (“JavaCard”)
October 15, 2008 (C) 1999-2000 David A. Wheeler 4
Java Language
• Modern object-oriented (OO) language
– OO with single inheritance + multiple “interfaces”
– Classes grouped into hierarchical packages
– Strong static typing (no arbitrary pointers)
– Automatic garbage collection
– Exceptions
– Multithreaded
• Lacks enumerations and templates (generics)
• Syntax ~C++, semantics ~Ada95/Smalltalk
October 15, 2008 (C) 1999-2000 David A. Wheeler 5
Java Virtual Machine (VM) and
Class File Format
• Class file defines names/types/values of class
variables, constants, & methods
• Methods stored as instructions to stack-based VM
– Very similar to UCSD p-code
• VM executes class files (inc. collections of them)
– By interpretation, run-time compilation, or
combination; performance is a significant issue
• Before execution, VM usually runs “bytecode
verifier” to check legality of class file
October 15, 2008 (C) 1999-2000 David A. Wheeler 6
Java Libraries
• Set of built-in APIs, including:
– GUIs
– Networking
– Computation
• Growth area
• Several classes are security-related
– This presentation will skim ordinary crypto functions
such as ones for encryption/decryption, certificate
management, etc., since they are not essentially unique
October 15, 2008 (C) 1999-2000 David A. Wheeler 7
Class and Method
Access Control Modifiers
Access Control Class or Interface Member (Field or Method)
Modifier Accessibility Accessibility
Public All All if class or interface is
accessible; interface members
always public
Protected N/A Same package OR subclass
Instance1 1 1 Instance2
Asks
ClassLoader1 Policy
requesting getObject()
GuardedObject object-to-guard
class 1
3 2 checkGuard()
reply with
object-to- Guard
guard
October 15, 2008 (C) 1999-2000 David A. Wheeler 42
GuardedObject (2 of 3)
• GuardedObject class encapsulates object-to-guard
– asks “Guard” interface to determine if access ok
– Permission implements Guard by calling
SecurityManager. checkPermission(self)
– PermissionCollection doesn’t implement (I’ve reported)
• Provider of object-to-guard does the following:
– Instantiates new Guard (e.g., a Permission)
– Instantiates GuardedObject, using object-to-guard and
the guard
– Gives GuardedObject’s reference to requestors
October 15, 2008 (C) 1999-2000 David A. Wheeler 43
GuardedObject (3 of 3)
• Clients who wish to use object-to-guard call
GuardedObject’s getObject()
– GuardedObject instance calls its Guard’s checkGuard()
– if ok, object-to-guard’s reference returned
– if not ok, security exception thrown