Java Security Updated May 2007. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security.

Slides:



Advertisements
Similar presentations
© 2003 School of Computing, University of Leeds SY32 Secure Computing, Lecture 16 Secure Coding in Java and.NET Part 1: Fundamentals.
Advertisements

Mobile Code Security Yurii Kuzmin. What is Mobile Code? Term used to describe general-purpose executables that run in remote locations. Web browsers come.
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.
Portability and Safety Mahdi Milani Fard Dec, 2006 Java.
Java Applet Security Diana Dong CS 265 Spring 2004.
Java security (in a nutshell)
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.
1 1 Lecture 14 Java Virtual Machine Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
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
The Java Language. Topics of this Course  Introduction to Java  The Java Language  Object Oriented Programming in Java  Exceptions Handling  Threads.
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Java Security Model Lab#1 I. Omaima Al-Matrafi. Safety features built into the JVM Type-safe reference casting Structured memory access (no pointer arithmetic)
Object Orientated Programming
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.
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
Session 1 CS-240 Data Structures Binghamton University Dick Steflik.
Toba Gregg M. Townsend Executable Code from Java Source.
1 Software Testing and Quality Assurance Lecture 31 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
Introduction to Java.
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.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
Page 1 Sandboxing & Signed Software Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
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.
1 The Java Virtual Machine Yearly Programming Project.
Security in Java Sunesh Kumra S
Implement High-level Program Language on JVM CSCE 531 ZHONGHAO LIU ZHONGHAO LIU XIAO LIN.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
Lecture 10 : Introduction to Java Virtual Machine
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
University of Houston-Clear Lake Proprietary© 1997 Evolution of Programming Languages Basic cycle of improvement –Experience software difficulties –Theory.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
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++
Java 2 security model Valentina Casola. Components of Java the development environment –development lifecycle –Java language features –class files and.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
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.
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
CS 4244: Internet Programming Network Programming in Java 1.0.
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 Security Session 19. Java Security / 2 of 23 Objectives Discuss Java cryptography Explain the Java Security Model Discuss each of the components.
By: Cheryl Mok & Sarah Tan. Java is partially interpreted. 1. Programmer writes a program in textual form 2. Runs the compiler, which converts the textual.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Java – in context Main Features From Sun Microsystems ‘White Paper’
Introduction to Programming 1 1 2Introduction to Java.
RealTimeSystems Lab Jong-Koo, Lim
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Introduction to Operating Systems
Before You Begin Nahla Abuel-ola /WIT.
Java Primer 1: Types, Classes and Operators
Internet and Java Foundations, Programming and Practice
Java security (in a nutshell)
Introduction Enosis Learning.
Topic: Java Security Models
Java Virtual Machine Complete subject details are available at:
Introduction Enosis Learning.
Introduction to Operating Systems
Security in Java Real or Decaf? cs205: engineering software
COSC Assignment 3 - Part 1 Java Security Susan Kovacs 19 April 2019 COSC Assignment 3 - Part 1.
CSCD 303 Essential Computer Security Spring 2013
Presentation transcript:

Java Security Updated May 2007

Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager

Internet Security Needed Nowadays, code is downloaded from the Internet and executed transparently by millions of users. Downloaded software can hide all sorts of hazardous code. Games and music are often Trojan horses, spyware and virus installers. There is a real need for a more security mechanism for mobile code.

Is This Code Planting a Virus?

Writing Secure Code Software developers also have security problems to handle. Programmers unknowingly leave holes in their code that hackers can exploit. Forgetting to deallocate resources. An open socket connection is like an open invitation to a hacker. Memory leaks can be exploited Buffer overflow

The Java Solution Java Virtual Machine creates a sandbox Syntax - insecure operations cannot even be represented Automatic garbage collection prevents memory leaks Security Manager watches for anomalies during execution and can take action

Interpreters and Compilers Most languages are either compiled (C, C++, Pascal) or interpreted (Lisp, Haskell, BASIC). MyFile.cpp MyFile.exe compiler MyFile.l interpreter Source code object code

JVM Java is an interpreted language. Your source code is “compiled” to “bytecode” which is executed on the JVM (interpreted). The Java Virtual Machine (JVM) observes each instruction (bytecode) before it is used. This allows Java to provide the idea of a sandbox, which limits how an untrusted program can affect the system it runs on.

Java and the JVM The.class file contain Java Bytecode which is interpreted by the JVM (which is platform specific) File.java File.class Compiler javac File.class Java (JVM)

Language Level Security No pointers or pointer arithmetic No way to represent unstructured memory Variables, methods and classes can be final Compiler checks variable instantiation and typecasts

No Pointers Pointers and pointer arithmetic allow attackers to access any byte in memory. In C, strings and arrays are essentially unstructured memory. They start with a pointer and operations on the array are done by manipulating the pointer. There is no bounds checking. The Java programmer cannot represent or manipulate pointers.

No Pointers You just can’t write a Java program to do damage like this. void main() { int *randAddress; randAddress = (int *) rand(); *randAddress = rand(); }

No Unstructured Memory Access Unstructured memory access (or unenforced structure) can be exploited. In C and C++, character data can be written to memory allocated as integer. Character or integer data can be read and interpreted as Boolean. Java prevents data of one type from being used as a different type – cannot be expressed in bytecode.

Source / Bytecode Produced This will fail in Java if d was not an int, but a program in C assumes d is in the right format public float add(float c, int d) { return c + d; } Method float add(float, int) fload_1 iload_2 I2f fadd freturn

Data Types All memory and data types include format info A 2 byte integer takes up more than 2 bytes in memory – there is something to indicate that it is an integer so it can’t be used as something else.

Unspecified Memory Layout The JVM stores several types of data to execute a program Runtime stacks – one for each thread Bytecode for methods Dynamic memory heap and garbage collection area The storage layout is not defined for the JVM. Each implementation does it differently.

Other Sources of Error The bytecode instructions for array operations include bounds checking Branching instructions can only branch to instructions in the same method. Only return and invoke allow transfer of control outside a given method.

The Keyword final This keyword can be used to prevent variables, methods and classes from being changed (and potentially exploited). The value of a variable is fixed for the duration of the execution. A method cannot be modified in subclasses (hacker tactic to use permission levels of original method) Class cannot have subclasses (subclass of API would have full system access).

The Compiler The compiler checks code and produces bytecode (intermediate representation interpreted by all JVMs). Checks that: Variables are instantiated before they are used. Type casts are legal (prevents unstructured memory exploits) Methods called by appropriate type objects

Run-time security Java Virtual Machine – the runtime environment Bytecode verifier, class loader, runtime checks Sandbox evolution Security manager

Class Loader, Bytecode Verifier Class loader gets the needed class Bytecode verifier runs first and guards against circumvention of compiler checks with handwritten bytecode. Class loader checks permissions and helps to prevent the loading of “Trojan Horse” methods.

More Checks and Verifications Version number of compiler Number and type of parameters passed to an instruction of method is legal All bytecode has valid opcodes No local variable is used before it is initialized Symbolic reference check

Run Time Checks Bounds checking on arrays (no buffer overflow). Type cast checking Automatic garbage collection (memory leaks can lead to DOS attacks

The Sandbox Idea The original Java release, jdk1.0, provided a system that used the basic sandbox model. Differentiated only between native code (code stored locally, trusted, given full access) and non-native code (applets downloaded, not trusted).

JDK 1.0 Sandbox Trusted code can read, write and delete any file, start and kill threads and open, use and close socket connections without any restrictions. Untrusted code cannot access any files, threads are hidden and only socket connections to the applet’s origin server are allowed.

JDK 1.1: More Flexible Native code is trusted and treated as in JDK1.0 Non-native code can be trusted or non- trusted. If the.jar file has a valid digital signature and comes from a “trusted developer” (list is part of the JVM) code is considered trusted and given same rights as native code. Otherwise, untrusted and restrictions apply.

JDK 1.2 ALL code (even native) is subject to a security policy that can be defined by the user. Permissions are checked against the policy when the class is loaded AND whenever restricted actions are attempted. Promotes Principle of Least Priviledge Performs Complete Mediation

JDK 1.2 Restricted Actions Accept a socket connection Open a socket connection Wait for a connection on a port Create a new process Modify a thread Cause the application to exit Load a dynamic library that contains native methods Access or modify system properties Read from a file Write to a file Delete a file Create a new class loader Load a class from a specified package Add a new class to a specified package

The Security Manager The part of the JVM that performs these run time checks is called the security manager JDK 1.2 or later (a.k.a. Access Manager) In addition the security manager watches other potential security holes and can react if needed.

Possible Problems Security features not automatic if Java program is invoked on the command line And others as yet undiscovered …

Readings