Java security (in a nutshell)

Slides:



Advertisements
Similar presentations
Towards Remote Policy Enforcement for Runtime Protection of Mobile Code Using Trusted Computing Xinwen Zhang Francesco Parisi-Presicce Ravi Sandhu
Advertisements

© 2003 School of Computing, University of Leeds SY32 Secure Computing, Lecture 16 Secure Coding in Java and.NET Part 1: Fundamentals.
Mobile Code Security Yurii Kuzmin. What is Mobile Code? Term used to describe general-purpose executables that run in remote locations. Web browsers come.
What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Java Security John Mitchell CS 242 Reading: Chapter 13 (+Slides contain additional material) 2008.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Java Applet Security Diana Dong CS 265 Spring 2004.
Applet Security Gunjan Vohra. What is Applet Security? One of the most important features of Java is its security model. It allows untrusted code, such.
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
Java Security CS-328. JDK 1.0 Security Model Sandbox Java Virtual Machine Local Code Remote Code Local Host System Resources (File System, Sockets, Printers…)
Mobile Code Security Aviel D. Rubin, Daniel E. Geer, Jr. MOBILE CODE SECURITY, IEEE Internet Computing, 1998 Minkyu Lee
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Lab#1 (14/3/1431h) Introduction To java programming cs425
LAB#2 JAVA SECURITY OVERVIEW Prepared by: I.Raniah Alghamdi.
1 Extensible Security Architectures for Java Authors: Dan S.Wallch, Dirk Balfanz Presented by Moonjoo Kim.
Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green.
Introduction to Java Kiyeol Ryu Java Programming Language.
JVM-1 Java Virtual Machine Reading Assignment: Chapter 1: All Chapter 3: Sections.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
JETT 2003 Java.compareTo(C++). JAVA Java Platform consists of 4 parts: –Java Language –Java API –Java class format –Java Virtual Machine.
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
Page 1 Sandboxing & Signed Software Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
Java Security Updated May Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security.
Intro to Java The Java Virtual Machine. What is the JVM  a software emulation of a hypothetical computing machine that runs Java bytecodes (Java compiler.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
1 The Java Virtual Machine Yearly Programming Project.
Security in Java Sunesh Kumra S
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Why Java? A brief introduction to Java and its features Prepared by Mithat Konar.
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
1 22 August 2001 The Security Architecture of the M&M Mobile Agent Framework P. Marques, N. Santos, L. Silva, J. Silva CISUC, University of Coimbra, Portugal.
Java Security Pingping Ma Nov 2 nd, Overview Platform Security Cryptography Authentication and Access Control Public Key Infrastructure (PKI)
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
University of Houston-Clear Lake Proprietary© 1997 Evolution of Programming Languages Basic cycle of improvement –Experience software difficulties –Theory.
Java Security Nathan Moore CS 665. Overview Survey of Java Inherent Security Properties Java Runtime Environment Java Virtual Machine Java Security Model.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
Lecture :2 1.  DEFENTION : Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Java 2 security model Valentina Casola. Components of Java the development environment –development lifecycle –Java language features –class files and.
Java Security Model For Mobile Code Abdo Achkar. Mobile Code A mobile object is a “self contained piece” of executable code. Definition:  Code that can.
1 cs205: engineering software university of virginia fall 2006 Forgiveness and Permissions.
CT1513 Introduction To java © A.AlOsaimi.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1. An Introduction A Programming Language A Technology Java Development Kit Java API One Language: Three Editions Standard Edition Enterprise Edition.
Java: An Overview John R Durrett Texas Tech University.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
Java – in context Main Features From Sun Microsystems ‘White Paper’
Classes, Interfaces and Packages
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
The Execution System1. 2 Introduction Managed code and managed data qualify code or data that executes in cooperation with the execution engine The execution.
Java & The Android Stack: A Security Analysis Pragati Ogal Rai Mobile Technology Evangelist PayPal, eBay Java.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Applications Active Web Documents Active Web Documents.
Object Oriented Programming in
Done By: Ashlee Lizarraga Ricky Usher Jacinto Roches Eli Gomez
What is RMI? Remote Method Invocation
Java security (in a nutshell)
Introduction Enosis Learning.
Topic: Java Security Models
Java Virtual Machine Complete subject details are available at:
Introduction Enosis Learning.
Java Remote Method Invocation
Presentation transcript:

Java security (in a nutshell)

Outline components of Java Java security models main components of the Java security architecture class loaders byte code verification the Security Manager

Components of Java the development environment development lifecycle Java language features class files and bytecode the execution environment the Java Virtual Machine (JVM) interfaces and architectures e.g., Java beans, RMI, JDBC, etc. Components of Java

Development lifecycle Java source code compiler Java bytecode programmer notes Java is a high-level programming language  source code is English-like (syntax is similar to C) Java is compiled and interpreted source code is compiled into bytecode (low-level, platform independent code) bytecode is interpreted (real machine code produced at run time)  fast and portable (“write once run anywhere”) dynamic linking (no link phase at compile time) program consists of class definitions each class is compiled into a separate class file classes may refer to each other, references are resolved at run-time Components of Java / The Development Environment

Java language features object-oriented multi-threaded strongly typed exception handling very similar to C/C++, but cleaner and simpler no more struct and union no more (stand alone) functions no more multiple inheritance no more operator overloading no more pointers garbage collection objects no longer in use are removed automatically from memory Components of Java / The Development Environment

Class files contain magic number (0xCAFEBABE) JVM major and minor version constant pool contains constants (e.g., strings) used by this class names of classes, fields, and methods that are referred to by this class used as a symbol table for linking purposes many bytecode instructions take as arguments numbers which are used as indexes into the constant pool class information (e.g., name, super class, access flags, etc.) description of interfaces, fields, and methods attributes (name of the source file) bytecode Components of Java / The Development Environment

The Java Virtual Machine (JVM) network class loader instance class file verifier heap JIT class area primordial class loader execution engine local untrusted classes trusted classes native method area native method loader Security Manager native methods Components of Java / The Execution Environment operating system native code Java code

JVM cont’d class loaders class file verifier locate and load classes into the JVM primordial class loader loads trusted classes (system classes found on the boot class path) integral part of the JVM class loader instances instances of java.net.URLClassLoader (which extends SecureClassLoader) load untrusted classes from the local file system or from the network and passes them to the class file verifier application developers can implement their own class loaders class file verifier checks untrusted class files size and structure of the class file bytecode integrity (references, illegal operations, …) some run-time characteristics (e.g., stack overflow) a class is accepted only if it passes the test Components of Java / The Execution Environment

JVM cont’d native method loader the heap execution engine native methods are needed to access some of the underlying operating system functions (e.g., graphics and networking features) once loaded, native code is stored in the native method area for easy access the heap memory used to store objects during execution how objects are stored is implementation specific execution engine a virtual processor that executes bytecode has virtual registers, stack, etc. performs memory management, thread management, calls to native methods, etc. Components of Java / The Execution Environment

JVM cont’d Security Manager JIT – Just In Time compiler enforces access control at run-time (e.g., prevents applets from reading or writing to the file system, accessing the network, printing, ...) application developers can implement their own Security Manager or use the policy based SM implementation provided by the JDK JIT – Just In Time compiler performance overhead due to interpreting bytecode translates bytecode into native code on-the-fly works on a method-by-method basis the first time a method is called, it is translated into native code and stored in the class area future calls to the same method run the native code all this happens after the class has been loaded and verified Components of Java / The Execution Environment

Java security models the need for Java security the sandbox (Java 1.0) the concept of trusted code (Java 1.1) fine grained access control (Java 2) Java security models

The need for Java security code mobility can be useful (though not indispensable) may reduce bandwidth requirements improve functionality of web services but downloaded executable content is dangerous the source may be unknown hence untrusted hostile applets may modify or destroy data in your file system hostile applets may read private data from your file system hostile applets may install other hostile code on your system (e.g., virus, back-door, keyboard sniffer, …) hostile applets may try to attack someone else from your system (making you appear as the responsible for the attack) hostile applets may use (up) the resources of your system (DoS) all this may happen without you knowing about it Java security models

The sandbox idea: limit the resources that can be accessed by applets introduced in Java 1.0 local code had unrestricted access to resources downloaded code (applet) was restricted to the sandbox cannot access the local file system cannot access system resources, can establish a network connection only with its originating web server JVM sandbox resources remote code (applets) local code Java security models

The concept of trusted code idea: applets that originate from a trusted source could be trusted introduced in Java 1.1 applets could be digitally signed unsigned applets and applets signed by an untrusted principal were restricted to the sandbox local applications and applets signed by a trusted principal had unrestricted access to resources JVM sandbox resources remote code (applets) local code signed and trusted unsigned, or untrusted Java security models

Fine grained access control idea: every code (remote or local) has access to the system resources based on what is defined in a policy file introduced in Java 2 a protection domain is an association of a code source and the permissions granted the code source consists of a URL and an optional signature permissions granted to a code source are specified in the policy file grant CodeBase “http://java.sun.com”, SignedBy “Sun” { permission java.io.FilePermission “${user.home}${/}*”, “read, write”; permission java.net.SocketPermission “localhost:1024-”, “listen”;}; JVM resources local or remote code (signed or unsigned) class loaders policy file Java security models

The three pillars of Java security the Security Manager class loaders the bytecode verifier Components of the Java security architecture

The Security Manager ensures that the permissions specified in the policy file are not overridden implements a checkPermission() method, which takes a permission object as parameter, and returns a yes or a no (based on the code source and the permissions granted for that code source in the policy file) checkPermission() is called from trusted system classes e.g., if you want to open a socket you need to create a Socket object the Socket class is a trusted system class that always invokes the checkPermission() method this requires that all system resources are accessible only via trusted system classes trusted system classes cannot be overwritten (ensured by the class loading mechanism) Components of the Java security architecture

The Security Manager cont’d the JVM allows only one SM to be active at a time there is a default SM provided by the JDK Java programs (applications, applets, beans, …) can replace the default SM by their own SM only if they have permission to do so two permissions are needed: create an instance of SecurityManager set an SM instance as active example: grant CodeBase “…”, SignedBy “…” { permission java.lang.RuntimePermission “createSecurityManager”; permission java.lang.RuntimePermission “setSecurityManager”;}; invoking the SecurityManager constructor or the setSecurityManager() method will call the checkPermissions() method of the current SM and verify if the caller has the needed permissions Components of the Java security architecture

Class loaders separate name spaces classes loaded by a class loader instance belong to the same name space since classes with the same name may exist on different Web sites, different Web sites are handled by different instances of the applet class loader a class in one name space cannot access a class in another name space  classes from different Web sites cannot access each other establish the protection domain (set of permissions) for a loaded class enforce a search order that prevents trusted system classes from being replaced by classes from less trusted sources see next two slide … Components of the Java security architecture

Class loading process when a class is referenced JVM: invokes the class loader associated with the requesting program class loader: has the class already been loaded? yes: does the program have permission to access the class? yes: return object reference no: security exception no: does the program have permission to create the requested class? first delegate loading task to parent if parent returns success, then return (class is loaded) if parent returned failure, then load class and return Components of the Java security architecture

Class loading task delegation primordial class loader (searches on the boot class path) loads class from boot class path 4a 3 failure 4b a class loader instance started at JVM startup (searches on the class path) loads class from class path 5a 2 success / failure 5b Components of the Java security architecture a class loader instance associated with a URL (searches on the site specified by the URL) loads class from URL 6 1 class request

Byte code verifier performs static analysis of the bytecode syntactic analysis all arguments to flow control instructions must cause branches to the start of a valid instruction all references to local variables must be legal all references to the constant pool must be to an entry of appropriate type all opcodes must have the correct number of arguments exception handlers must start at the beginning of a valid instruction … data flow analysis attempts to reconstruct the behavior of the code at run time without actually running the code keeps track only of types not the actual values in the stack and in local variables it is theoretically impossible to identify all problems that may occur at run time with static analysis Components of the Java security architecture

Comparison with ActiveX ActiveX controls contain native code security is based on the concept of trusted code ActiveX controls are signed if signer is trusted, then the control is trusted too once trusted, the control has full access to resources not suitable to run untrusted code no sandbox mechanism