Link-Time Enforcement of Confined Types for JVM Bytecode Philip W. - - PowerPoint PPT Presentation

link time enforcement of confined types for jvm bytecode
SMART_READER_LITE
LIVE PREVIEW

Link-Time Enforcement of Confined Types for JVM Bytecode Philip W. - - PowerPoint PPT Presentation

Link-Time Enforcement of Confined Types for JVM Bytecode Philip W. L. Fong pwlfong@cs.uregina.ca Department of Computer Science University of Regina Regina, Saskatchewan, Canada Overview Motivation Confined Types A Bytecode-level


slide-1
SLIDE 1

Link-Time Enforcement of Confined Types for JVM Bytecode

Philip W. L. Fong

pwlfong@cs.uregina.ca

Department of Computer Science University of Regina Regina, Saskatchewan, Canada

slide-2
SLIDE 2

Overview

Motivation Confined Types A Bytecode-level Formulation of Confined Types Implementation Efforts Secure Cooperation

Link-Time Enforcement of Confined Types for JVM Bytecode – p.1/33

slide-3
SLIDE 3

Motivation

Link-Time Enforcement of Confined Types for JVM Bytecode – p.2/33

slide-4
SLIDE 4

Dynamically Extensible Software Systems

Process P Process C Code Producer Code Consumer R

Link-Time Enforcement of Confined Types for JVM Bytecode – p.3/33

slide-5
SLIDE 5

Dynamically Extensible Software Systems

E Program Fragment

Code Consumer Process P Process C R Code Producer

Link-Time Enforcement of Confined Types for JVM Bytecode – p.4/33

slide-6
SLIDE 6

Dynamically Extensible Software Systems

Program Fragment E

R Code Producer Code Consumer Process P Process C

Link-Time Enforcement of Confined Types for JVM Bytecode – p.5/33

slide-7
SLIDE 7

Dynamically Extensible Software Systems

Program Fragment E

R Code Producer Code Consumer Process P Process C

Examples:

mobile code, OS kernel extensions, application plug-ins, scriptable software

Link-Time Enforcement of Confined Types for JVM Bytecode – p.6/33

slide-8
SLIDE 8

Language-Based Security

Language-based Security:

Use a safe language to encode untrusted software extensions Protection via programming language facilities e.g., type systems, program rewriting, interpreters Examples: JVM, CLR

Link-Time Enforcement of Confined Types for JVM Bytecode – p.7/33

slide-9
SLIDE 9

Encapsulation and Security

Data Encapsulation

Protecting object states from undisciplined access Well-supported in mainstream OO languages

Reference Encapsulation

Preventing accidental reference leaking Not supported in mainstream OO languages Reference leaking has led to a security breach in JDK 1.1

Link-Time Enforcement of Confined Types for JVM Bytecode – p.8/33

slide-10
SLIDE 10

Confined Types

Confined Types (Vitek et al 2001, 2003)

a recently proposed lightweight annotation system for supporting reference encapsulation in Java-like languages existing formulations target Java-like source languages enforceable only by code producer at compile time not qualified as language-based protection mechanism for code consumers

Link-Time Enforcement of Confined Types for JVM Bytecode – p.9/33

slide-11
SLIDE 11

Contributions

  • 1. the first formulation of confined types for JVM bytecode
  • 2. the first implementation to enforce confined types at

link-time on behalf of the code consumer

  • 3. employing the bytecode-level formulation of confined

types to facilitate a form of secure cooperation

Link-Time Enforcement of Confined Types for JVM Bytecode – p.10/33

slide-12
SLIDE 12

Confined Types

Link-Time Enforcement of Confined Types for JVM Bytecode – p.11/33

slide-13
SLIDE 13

JDK 1.1 Security Breach

public class Class { private Identity[] signers; public Identity[] getSigners() { return signers; } }

Link-Time Enforcement of Confined Types for JVM Bytecode – p.12/33

slide-14
SLIDE 14

Manual Fix

public class Class { private Identity[] signers; public Identity[] getSigners() { Identity[] dup = new Identity[signers.length]; for (int i = 0; i < signers.length; i++) dup[i] = signers[i]; return dup; } }

Link-Time Enforcement of Confined Types for JVM Bytecode – p.13/33

slide-15
SLIDE 15

A New Type Qualifier

A class can be qualified as being confined. References to confined class instances are not allowed to escape outside of the package in which the class is declared. Examples: confined class ConfinedIdentity { ... }

Link-Time Enforcement of Confined Types for JVM Bytecode – p.14/33

slide-16
SLIDE 16

Solution (1)

public class Identity { ConfinedIdentity rep; Identity(ConfinedIdentity si) { rep = si; } ... }

Link-Time Enforcement of Confined Types for JVM Bytecode – p.15/33

slide-17
SLIDE 17

Solution (2)

public class Class { private ConfinedIdentity[] signers; public Identity[] getSigners() { Identity[] dup = new Identity[signers.length]; for (int i = 0; i < signers.length; i++) dup[i] = new Identity(signers[i]); return dup; } }

Link-Time Enforcement of Confined Types for JVM Bytecode – p.16/33

slide-18
SLIDE 18

A Bytecode-Level Formulation of Confined Types

Link-Time Enforcement of Confined Types for JVM Bytecode – p.17/33

slide-19
SLIDE 19

Confined Types as Capabilities (1)

Capability Types (Boyland et al 2001):

A capability is an unforgeable pair:

  • bject-reference, access-rights

In a strongly typed programming language, a type qualifier plays the role of the access-rights component of a capability: const char *p;

Link-Time Enforcement of Confined Types for JVM Bytecode – p.18/33

slide-20
SLIDE 20

Confined Types as Capabilities (2)

A Capability-based Formulation of Confined Types:

In our bytecode-level type system, confined-ness is not just the property of a class, it is a capability type. Every object reference is associated with a capability type to indicate where it can be propagated. Subtype hierarchy:

⊥ <: confined <: anonymous

Supertypes are more restrictive than subtypes. Greatly simplifies the formulation of type rules.

Link-Time Enforcement of Confined Types for JVM Bytecode – p.19/33

slide-21
SLIDE 21

Confined Type Interface

Code safety is a whole-program notion, but . . . Lazy, dynamic linking ⇒ not all application classes are loaded at all times. Every classfile carries a confined type interface to facilitate modular type checking. Designed to be backward compatible: Existing classfiles in the Java platform library does not need further annotation.

Link-Time Enforcement of Confined Types for JVM Bytecode – p.20/33

slide-22
SLIDE 22

Type Rules for Bytecode Instructions

invokevirtual B.m Operand Stack:

. . . , o, a1, a2, . . . , ak

− →

. . . , v

Operation: Invoke method B.m on object instance o,

passing arguments a1, a2, . . . , ak. Any return value v is pushed into the operand stack.

Type Constraints:

Suppose B.m : T0(T1, T2, . . . , Tk)T ∈ IA. Suppose further that o : To, ai : Tai, and v : Tv. Then To <: T0, Tai <: Ti, and T <: Tv.

Link-Time Enforcement of Confined Types for JVM Bytecode – p.21/33

slide-23
SLIDE 23

Intermodular Type Checking

Lazy, dynamic linking ⇒ intermodular type checking must be performed incrementally. Intermodular type checking is carefully staged to dovetail with dynamic linking events. Special consideration to preserve laziness in dynamic linking.

Link-Time Enforcement of Confined Types for JVM Bytecode – p.22/33

slide-24
SLIDE 24

Implementation Efforts

Link-Time Enforcement of Confined Types for JVM Bytecode – p.23/33

slide-25
SLIDE 25

Set-Up

Type Annotations Frontend javac Backend Link−Time Type Checker Annotated Java Source Java Source Internet Annotated Classfile JVM Classfile

Implementation Experiences:

Linux command-line tool for annotating classfiles Link-time type checker

Link-Time Enforcement of Confined Types for JVM Bytecode – p.24/33

slide-26
SLIDE 26

Pluggable Verification Modules

Aegis VM

an open source research VM for Java bytecode verification is a pluggable service third-party verification services can be safely incorporated into the dynamic linking process as a Pluggable Verification Module (PVM) [OOPSLA’04]

PVM-based Implementation of Confined Types

for both intra- and inter-modular type checking enforces confined types at link time

≈ 3000 lines of moderately commented C code

Link-Time Enforcement of Confined Types for JVM Bytecode – p.25/33

slide-27
SLIDE 27

Secure Cooperation

Link-Time Enforcement of Confined Types for JVM Bytecode – p.26/33

slide-28
SLIDE 28

Secure Cooperation

Enabling a form of secure cooperation among mutually suspicious code units.

  • 1. Protection by access contracts
  • 2. Trust inspiration
  • 3. Secure software extensions

Link-Time Enforcement of Confined Types for JVM Bytecode – p.27/33

slide-29
SLIDE 29

Protection via Import Type Annotations

Problem: Alice wants to share a Recourse with Bob, but worries that the sharing leads to resource leaking . . . package domain; confined class Resource { ... } public class Alice { static Resource resource = new Resource(); public static void main(String[] args) throws Throwable { Class C = Class.forName(args[0]); Bob b = (Bob) C.newInstance(); b.share(resource); } } public interface Bob { void share(Resource r); }

Link-Time Enforcement of Confined Types for JVM Bytecode – p.28/33

slide-30
SLIDE 30

Protection via Import Type Annotations

Solution: Annotate the classfile of Bob with the following export type assertion: Bob.share : confined → ⊥ Subtypes of Bob must conform to this access contract.

Link-Time Enforcement of Confined Types for JVM Bytecode – p.29/33

slide-31
SLIDE 31

Non-Compliant Extension

package domain; public class Charlie implements Bob { public static Resource leak; public void share(Resource r) { leak = r; } }

Link-Time Enforcement of Confined Types for JVM Bytecode – p.30/33

slide-32
SLIDE 32

Robustness of Trust Inspiration

  • 1. What if Charlie falsely asserts a matching export

type assertion?

Consequence: PVM fails to confirm compliance of

Charlie.sum to its promised export type. ⇒ Definition of class Charlie will fail.

  • 2. What if Charlie does not supply a matching export

type assertion?

Consequence: Intermodular type checking will fail.

⇒ Preparation of class Charlie will fail.

Link-Time Enforcement of Confined Types for JVM Bytecode – p.31/33

slide-33
SLIDE 33

Summary & Future Work

Summary the first formulation of confined types for JVM bytecode A first implementation to enforce confined types at link time Application to secure cooperation Future Work a static capability type system, Discretionary Capability Confinement (DCC), for Java bytecode a generic framework for defining capability type systems over the Java platform

Link-Time Enforcement of Confined Types for JVM Bytecode – p.32/33

slide-34
SLIDE 34

Thank You

Link-Time Enforcement of Confined Types for JVM Bytecode – p.33/33