Lecture 18: Java™ Decaffeinated CS551: Security and Privacy

Slides:



Advertisements
Similar presentations
Mobile Code Security Yurii Kuzmin. What is Mobile Code? Term used to describe general-purpose executables that run in remote locations. Web browsers come.
Advertisements

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.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
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.
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.
Class 20: Verifying Bytecodes Fall 2010 UVa David Evans cs2220: Engineering Software Image: Joseph Featherston.
Lab#1 (14/3/1431h) Introduction To java programming cs425
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
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.
Java Security Updated May Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 18: 0xCAFEBABE (Java Byte Codes)
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.
Security Exploiting Overflows. Introduction r See the following link for more info: operating-systems-and-applications-in-
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 19: Security in Java Real or.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
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.
Java Security Nathan Moore CS 665. Overview Survey of Java Inherent Security Properties Java Runtime Environment Java Virtual Machine Java Security Model.
Lecture :2 1.  DEFENTION : Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed.
Java 2 security model Valentina Casola. Components of Java the development environment –development lifecycle –Java language features –class files and.
Introduction to java Prepared By:-Pragnesh Patel Lect. In Computer Dept. NSIT,Jetalpur 1.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
1 Introduction to Java. 2 What is Java? A programming language. A platform –A virtual machine (JVM) definition. –Runtime environments in diverse hardware.
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.
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
Policy-Directed Code Safety David Evans April 1999 Software Devices and Systems MIT Lab for Computer Science.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 18: Code Safety and Virtual Machines
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 9: Designing Exceptionally.
David Evans CS588: Security and Privacy University of Virginia Computer Science Lecture 18: Malcode Countermeasures.
David Evans CS588: Cryptography University of Virginia Computer Science Lecture 21: Countering Malicious Code.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Lecture 4 Page 1 CS 111 Online Modularity and Memory Clearly, programs must have access to memory We need abstractions that give them the required access.
RealTimeSystems Lab Jong-Koo, Lim
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
1 cs205: engineering software university of virginia fall 2006 Running Untrustworthy Code Project team requests: extended until 11pm tonight.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Object Oriented Programming in
Modularity Most useful abstractions an OS wants to offer can’t be directly realized by hardware Modularity is one technique the OS uses to provide better.
Introduction to Operating Systems
Chapter 1 Introduction to Computers, Programs, and Java
CS216: Program and Data Representation
Java Programming Language
Java security (in a nutshell)
Java programming lecture one
Introduction Enosis Learning.
Modularity and Memory Clearly, programs must have access to memory
Introduction Enosis Learning.
CS216: Program and Data Representation
Introduction to Operating Systems
Java Byte Codes (0xCAFEBABE) cs205: engineering software
Security in Java Real or Decaf? cs205: engineering software
Object Oriented Programming
Byte Code Verification
From C++ to Java Java history: Oak, toaster-ovens, internet language, panacea What it is O-O language, not a hybrid (cf. C++) compiled to byte-code, executed.
Language-based Security
Security.
Lecture 17: Defeating Malcode (Shameless Self-Promotion) Background
Lecture 19: Proof-Carrying Code Background just got here last week
COSC Assignment 3 - Part 1 Java Security Susan Kovacs 19 April 2019 COSC Assignment 3 - Part 1.
Introducing Java.
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
SPL – PS2 C++ Memory Handling.
Presentation transcript:

David Evans http://www.cs.virginia.edu/~evans Lecture 18: Java™ Decaffeinated CS551: Security and Privacy University of Virginia Computer Science David Evans http://www.cs.virginia.edu/~evans

University of Virginia CS 551 Menu SSL Challenge Question Java Voting 15 November 2018 University of Virginia CS 551

SSL Challenge Question Are there skeletons in VeriSign’s closet? 15 November 2018 University of Virginia CS 551

Secure Socket Layer (SSL) 141 Sextillion years; Not going any where for awhile; grab a snickers

SSL Background Two Kinds of SSL Low Encryption (40-bit; 1.1x1012 possible keys) High Encryption (128-bit; 3.8x1038 possible keys) SSL is a transport level technology for authentication and data encryption between a web server and a Web server (example). Applied at the socket interface from the application to the network software. Data Link Header Internet Header Transport Header Application Header Data being sent Plaintext Cipher Text

SSL Handshake Client Server SSL Data Exchange Tell me who you are; Here are the protocols I support. Here is my Digital ID to prove who I am; Here is the protocols I have decided we should use. For your ID, I know who you are and have your public key; Here is a secret key I created with your protocols encrypted with your key Here is a copy of everything we’ve said encrypted with our secret key. Here is a copy of everything we’ve said encrypted with our secret key. SSL Data Exchange

Time to Break Specific Keys   Years Key length (bits) 1995 2000 2005 40 68 hours 8.6 minutes 1.07 minutes 56 7.4 weeks 6.5 days 19 hours 64 36.7 years 4.6 years 6.9 months 128 6.7x1017 millennia 8.4x1016 millennia 1.1x1016 millennia [Erkomaa, 1998]

University of Virginia CS 551 Brute Force Attacks 15 November 2018 University of Virginia CS 551

VeriSign’s Claim

Moore’s Law 18 months

General Timeline CS-551 Class (1.25 hours) Not to scale CS-551 Class (1.25 hours) Actual 128- bit Time to Crack Two Universe Lifetimes Total Human Lifetime VeriSign’s Claim Universe Lifetime 1010 1019 1020 1023 Quintillion years Sextillion years

VeriSign’s Assumptions Hackers or key breakers have computers that are extremely slow. We are using the processing speed of computers that were built in the 1980’s era. Distributed networks and special hardware are not authorized for key breaking schemes. We are not increasing our processing power every 18-24 months (based on Moore’s Law). 15 November 2018 University of Virginia CS 551

Java Security Real or Decaf? 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 Java Island in Indonesia A Programming Language (Java) A Portable Low-Level Language (JVML) A Platform (JavaVM) A successful marketing strategy JavaScript is not related to Java or Java So you can have more time to work on your projects All of the above 15 November 2018 University of Virginia CS 551

Java : Programming Language “A simple, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high-performance, multithreaded, and dynamic language.” [Sun95] 15 November 2018 University of Virginia CS 551

What is a secure language? Language is designed so it cannot express certain computations considered insecure. Language is designed so that (accidental) program bugs are likely to be caught by the compiler or run-time environment instead of leading to security vulnerabilities. A few attempts to do this: PLAN, packet filters 15 November 2018 University of Virginia CS 551

Safe Programming Languages Type Safety Compiler and run-time environment ensure that bits are treated as the type they represent Memory Safety Compiler and run-time environment ensure that program cannot access memory outside defined storage Control Flow Safety Can’t jump to arbitrary addresses Which of these does C++ have? Not a new idea: LISP had these in 1960! 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 Java Safety Type Safety Most types checked statically Coercions, array assignments type checked at run time Memory Safety No direct memory access (e.g., pointers) Primitive array type with mandatory run-time bounds checking Control Flow Safety Structured control flow, no arbitrary jumps 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 Malicious Code Can a safe programming language protect you from malcode? Code your servers in it to protect from buffer overflow bugs Only allow programs from untrustworthy origins to run if the are programmed in the safe language 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 Safe Languages? But how can you tell program was written in the safe language? Get the source code and compile it (most vendors, and all malicious attackers refuse to provide source code) Special compilation service signs object files generated from the safe language (SPIN, [Bershad96]) Verify object files preserve safety properties of source language (Java) 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 JVML malcode.java Java Source Code javac Compiler malcode.class JVML Object Code JavaVM Joe User Joe wants to know JVML code satisfies Java’s safety properties. 15 November 2018 University of Virginia CS 551

Does JVML satisfy Java’s safety properties? iconst_2 push integer constant 2 on stack istore_0 store top of stack in variable 0 as int aload_0 load object reference from variable 0 arraylength replace array on top of stack with its length No! This code violates Java’s type rules. 15 November 2018 University of Virginia CS 551

Bytecode Verifier malcode.class JVML Object Code Trusted Computing Base Java Bytecode Verifier Invalid “Okay” Joe User STOP JavaVM 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 Bytecode Verifier Checks JVML code satisfies Java’s safety properties Type safe – stack and variable slots must store and load as same type Memory safe (guaranteed by instruction set) Control flow safe: jumps must be within function, or call/return 15 November 2018 University of Virginia CS 551

Are Java Bytecode Verifiers Complicated? ~700 rules to enforce, JVML specification is (not all clearly specified) Emin Gün Sirer found > 100 bugs in commercial bytecode verifiers (using automatic test generation) At least 15 of them were security vulnerabilities JVML includes jsr instruction (jump to subroutine), can be called with different types in variables and on stack 15 November 2018 University of Virginia CS 551

Java javac malcode.class malcode.java Compiler JVML Trusted Computing Base Java Bytecode Verifier Invalid Joe User “Okay” STOP JavaVM 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 JavaVM Virtual machine – interpreter for JVML programs Has complete access to host machine Bytecode verifier ensures some safety properties, JavaVM must ensure rest: Type safety of run-time casts, array assignments Memory safety: array bounds checking Resource use policy 15 November 2018 University of Virginia CS 551

JavaVM Policy Enforcment [JDK 1.0 – JDK 1.1] From java.io.File: public boolean delete() { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkDelete(path); } if (isDirectory()) return rmdir0(); else return delete0(); 15 November 2018 University of Virginia CS 551

java.lang.SecurityManager /** Throws a SecurityException if the calling thread is not allowed to delete the specified file. This method is invoked for the current security manager by the delete method of class File. */ (Some other comments deleted.) public void checkDelete(String file) { throw new SecurityException(); } 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 Security Manager Reference monitor How well does it satisfy the requirements? Complete mediation Can stop execution/prevent action Limited effect on execution until policy violation User/host application creates a subclass of SecurityManager to define a policy 15 November 2018 University of Virginia CS 551

HotJava’s Policy (JDK 1.1.7) public class AppletSecurity extends SecurityManager { ... public synchronized void checkDelete(String file) { checkWrite(file); } 15 November 2018 University of Virginia CS 551

AppletSecurity.checkWrite (some exception handling code removed) public synchronized void checkWrite(String file) { if (inApplet()) { if (!initACL) initializeACLs(); String realPath = (new File(file)).getCanonicalPath(); for (int i = writeACL.length ; i-- > 0 ;) { if (realPath.startsWith(writeACL[i])) return; } throw new AppletSecurityException ("checkwrite", file, realPath); Note: no checking if not inApplet! Very important this does the right thing. 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 inApplet boolean inApplet() { return inClassLoader(); } Inherited from java.lang.SecurityManager: protected boolean inClassLoader() { return currentClassLoader() != null; 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 currentClassLoader /** Returns an object describing the most recent class loader executing on the stack. Returns the class loader of the most recent occurrence on the stack of a method from a class defined using a class loader; returns null if there is no occurrence on the stack of a method from a class defined using a class loader. */ protected native ClassLoader currentClassLoader(); 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 Recap java.io.File.delete calls SecurityManager.checkDelete before deleting HotJava overrides SecurityManager with AppletSecurity to set policy AppletSecurity.checkDelete calls AppletSecurity.checkWrite AppletSecurity.checkWrite checks if any method on stack has a ClassLoader If not no checks; if it does, checks ACL list 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 JDK 1.0 Trust Model When JavaVM loads a class from the CLASSPATH, it has no associated ClassLoader (can do anything) When JavaVM loads a class from elsewhere (e.g., the web), it has an associated ClassLoader 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 JDK Evolution JDK 1.1: Signed classes from elsewhere and have no associated ClassLoader JDK 1.2: Different classes can have different policies based on ClassLoader Explict enable/disable/check privileges SecurityManager is now AccessController 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 What can go wrong? Java API doesn’t call right SecurityManager checks (63 calls in java.*) Font loading bug, synchronization ClassLoader is tricked into loading external class as internal Bug in Bytecode Verifier can be exploited to circumvent SecurityManager Policy is too weak and allows damaging behavior 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 Hostile Applets See http://java.sun.com/sfaq/chronology.html (about 1 new vulnerability/month) Easy to write “annoying” applets (policy is too imprecise; no way to constrain many resource operations) http://www.cigital.com/hostile-applets/index.html 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 Voting 15 November 2018 University of Virginia CS 551

VA Absentee Voting: Ballot Print out form from state web site Fill in name and address, sign by voter and a witness Mail to local election official Local election official mails ballot to voter’s address (presumably: checks voter is registered, verifies address, marks on election rolls) 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 VA Absentee Voting Open Envelope A in presence of witness (do not open without witness present) Borrow No. 2 pencil and mark ballot. Place ballot in Envelope B and seal. Do not put anything else in that envelope. Fill in identification and sign Envelope B. Witness signs Envelope B. Place Envelope B in return envelope pre-addressed to Secretary of the Electoral Board. Mail or hand deliver in person. 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 Voting Challenges (50 points) Explain why VA absentee ballot protocol uses Envelope A and requires voter to open it in presence of a witness (50 points) Devise a good absentee voting protocol (better than my baseline) (200 points) Exploit vulnerabilities in electoral protocols so Harry Browne or Ralph Nader wins election Remember getting me arrested is -10000 points! 15 November 2018 University of Virginia CS 551

University of Virginia CS 551 Charge Tomorrow: Vote Pay attention to security protocols: who are you trusting? Don’t get arrested, but think about how a malicious person might defeat the system Next time Guest Lecture: Chenxi Wang 15 November 2018 University of Virginia CS 551