Pluggable Type Systems. Gilad Bracha



Similar documents
Integrating Typed and Untyped Code in a Scripting Language

Semester Review. CSC 301, Fall 2015

Programming Languages Featherweight Java David Walker

Modern Web Development with Dart. Alan Knight Google

Lecture 1: Introduction

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

Language Based Virtual Machines... or why speed matters. by Lars Bak, Google Inc

Habanero Extreme Scale Software Research Project

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Polymorphism. Problems with switch statement. Solution - use virtual functions (polymorphism) Polymorphism

CS-XXX: Graduate Programming Languages. Lecture 25 Multiple Inheritance and Interfaces. Dan Grossman 2012

Checking Access to Protected Members in the Java Virtual Machine

Lecture 7: Class design for security

Lecture 9. Semantic Analysis Scoping and Symbol Table

Introducing Variance into the Java Programming Language DRAFT

2 Introduction to Java. Introduction to Programming 1 1

Object Oriented Database Management System for Decision Support System.

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer

Dart a modern web language

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

Pattern Insight Clone Detection

Mirrors: Design Principles for Meta-level Facilities of Object-Oriented Programming Languages

Object-Oriented Software Specification in Programming Language Design and Implementation

Objectif. Participant. Prérequis. Remarque. Programme. C# 3.0 Programming in the.net Framework. 1. Introduction to the.

Programming Languages

Semantic Analysis: Types and Type Checking

On Language Support for Application Scalability

CSC Software II: Principles of Programming Languages

Fundamentals of Java Programming

Friendship and Encapsulation in C++

CSCI E 98: Managed Environments for the Execution of Programs

Tachyon: a Meta-circular Optimizing JavaScript Virtual Machine

Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz

Tracking Load-time Configuration Options

Chapter 5 Names, Bindings, Type Checking, and Scopes

Compiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding

HybriDroid: Analysis Framework for Android Hybrid Applications

General Introduction

Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages. Corky Cartwright Swarat Chaudhuri November 30, 20111

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science

Bachelor of Games and Virtual Worlds (Programming) Subject and Course Summaries

On Understanding Types, Data Abstraction, and Polymorphism

On Understanding Types, Data Abstraction, and Polymorphism

Practical Online Filesystem Checking and Repair

Introduction to Software Paradigms & Procedural Programming Paradigm

Malicious Code on Java Card Smartcards: Attacks and Countermeasures

Lab Experience 17. Programming Language Translation

The Clean programming language. Group 25, Jingui Li, Daren Tuzi

CSCI 3136 Principles of Programming Languages

Jonathan Worthington Scarborough Linux User Group

On the Design of an Object Oriented Programming Language

Java Application Developer Certificate Program Competencies

Automated Theorem Proving - summary of lecture 1

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

A Software and Hardware Architecture for a Modular, Portable, Extensible Reliability. Availability and Serviceability System

Parsing Technology and its role in Legacy Modernization. A Metaware White Paper

Inheritance in Programming Languages

The C Programming Language course syllabus associate level

VDM vs. Programming Language Extensions or their Integration

Java SE 7 Programming

CS 6371: Advanced Programming Languages

An Ants Algorithm to Improve Energy Efficient Based on Secure Autonomous Routing in WSN

Functional Programming. Functional Programming Languages. Chapter 14. Introduction

Language with a Pluggable Type System and Optional Runtime Monitoring of Type Errors

Neptune. A Domain Specific Language for Deploying HPC Software on Cloud Platforms. Chris Bunch Navraj Chohan Chandra Krintz Khawaja Shams

Java Programming. Binnur Kurt Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

16 April Cloud Security. Dr. Andreas Wespi IBM Corporation

An Object Storage Model for the Truffle Language Implementation Framework

Programming and Software Development CTAG Alignments

Service Governance and Virtualization For SOA

WHITE PAPER DATA GOVERNANCE ENTERPRISE MODEL MANAGEMENT

Summit Public Schools Summit, New Jersey Grade Level / Content Area: Mathematics Length of Course: 1 Academic Year Curriculum: AP Computer Science A

An Eclipse Plug-In for Visualizing Java Code Dependencies on Relational Databases

Type Systems. Luca Cardelli. Microsoft Research

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

SW5706 Application deployment problems

Chapter 7: Functional Programming Languages

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Stack Allocation. Run-Time Data Structures. Static Structures

Java SE 8 Programming

How To Prevent An Sql Injection Attack

I. INTRODUCTION. International Journal of Computer Science Trends and Technology (IJCST) Volume 3 Issue 2, Mar-Apr 2015

Journal of Functional Programming, volume 3 number 4, Dynamics in ML

The Eighth International Conference INCOSE_IL Formal Methods Security Tools in the Service of Cyber Security

Organization of DSLE part. Overview of DSLE. Model driven software engineering. Engineering. Tooling. Topics:

Habanero Extreme Scale Software Research Project

Concern Highlight: A Tool for Concern Exploration and Visualization

How To Write A Program Verification And Programming Book

The Smalltalk Programming Language. Beatrice Åkerblom

Java SE 7 Programming

CSE 326: Data Structures. Java Generics & JUnit. Section notes, 4/10/08 slides by Hal Perkins

Cloud Computing. Up until now

ebay : How is it a hit

Chapter 13 Computer Programs and Programming Languages. Discovering Computers Your Interactive Guide to the Digital World

Visualizing Information Flow through C Programs

Multiple Dispatching. Alex Tritthart WS 12/13

CSE 307: Principles of Programming Languages

Transcription:

Pluggable Type Systems Gilad Bracha

The Paradox of Type Systems Type systems help reliability and security by mechanically proving program properties Type systems hurt reliability and security by making things complex and brittle Copyright Gilad Bracha 2003-2004

Mandatory Typing Well known advantages: Machine-checkable documentation Early error detection Performance advantages Types provide conceptual framework

Mandatory Typing Disadvantages: Brittleness/Rigidity Lack of expressive power

Mandatory Typing Disadvantages: Brittleness/Rigidity Lack of expressive power

Brittleness of Mandatory Typing Security/Robustness - as strong as the type system/the weakest link Persistence/Serialization Type systems for VM and language collide

Brittleness of Mandatory Typing Security/Robustness - as strong as the type system/the weakest link Persistence/Serialization Type systems for VM and language collide

How Mandatory Typing Undermines Security Once a mandatory type system is in place, people rely on it for: Optimization Security Guarantees If type system fails, behavior is completely undefined

Example: Class Loaders Class loading becomes incredibly subtle (cf. Liang and Bracha, OOPSLA 98) Class loaders define name spaces for types JVM has nominal type system Inconsistent namespaces mean inconsistent types Failure to detect inconsistencies across class loaders leads to catastrophic failure (forgeable pointers, privacy violations etc.)

Example: Class Loaders class A { C getc() { return new B().getC();}} class B { C getc() { return new C();}} A and B defined in different, but overlapping namespaces N1 and N2. N1 and N2 agree on B but differ on C. One version of C may have a pointer as its first field, the other an int; or one may have a private field and the other may have a public one. Attacker may create suitable versions to suit their needs

Example: Class Loaders Class loading based type spoofing never caused a real security breach, because other security layers protect against unauthorized class loader definition. One may not always be so lucky.

How Mandatory Typing Undermines Security Wait, type systems shouldn t fail! A good type system will be formally proven to be sound and complete Real systems tend to be too complex to formalize Formalizations make simplifying assumptions These assumptions tend to be wrong Implementations tend to have bugs

How Mandatory Typing Undermines Security Type Systems are subtle and hard Relying on them is dangerous

Brittleness of Mandatory Typing Security/Robustness - as strong as the type system/the weakest link Persistence/Serialization Type systems for VM and language collide

Persistence and Typing Consider Serialization in mainstream languages Nominal typing forces serialization to separate objects from their behavior Versioning problems galore Exposes class internals, compiler implementation details

Persistence and Typing Consider Serialization in mainstream languages Nominal typing forces serialization to separate objects from their behavior Versioning problems galore Exposes class internals, compiler implementation details

Nominal Typing Separates Objects from their Classes When serializing an object one might naturally serialize its class as well This guarantees that data and behavior match Class can change over time, but clients are ok as long as public API is preserved

Nominal Typing Separates Objects from their Classes class Point { // initial version private int x, y; public int getx() { return x;} public int gety() {return y;} }

Nominal Typing Separates Objects from their Classes class Point { // new version private double rho, theta; public int getx() { return cos(rho, theta);} public int gety() { return sin(rho, theta);} }

Nominal Typing Separates Objects from their Classes New version of point differs in format, size Should not be a problem for clients - public API unchanged Deserialization can create distinct classes named Point Works with dynamic or structural typing But...

Nominal Typing Separates Objects from their Classes Nominal typing cannot tolerate two classes named Point! Solution : Serialize object together with the name of its class Deserialization binds object to class of stored name

Persistence and Typing Consider Serialization in mainstream languages Nominal typing forces serialization to separate objects from their behavior Versioning problems galore Exposes class internals, compiler implementation details

Persistence and Typing Persistence works well with structural typing; nominal typing does not Nominal typing suited to practical languages; structural typing problematic Mandatory typing forces a choice between two suboptimal options

Persistence and Typing Persistence bugs can undermine type system Undermining a mandatory type system leads to catastrophic failure

Brittleness of Mandatory Typing Security/Robustness - as strong as the type system/the weakest link Persistence/Serialization Type systems for VM and language collide

Type Systems Collide Run-time and compile-time type systems may be misaligned Cases where Java source code will not verify algorithm Definite assignment rules clash with verifier inference Weird cases with try-finally, boolean expressions

Having our Cake and Eating it too Performance disadvantage is greatly overstated Importance of performance also overstated Other advantages of static types can be had without the downside Enter Pluggable, Optional Type Systems

Having our Cake and Eating it too Performance disadvantage is greatly overstated Importance of performance also overstated Other advantages of static types can be had without the downside Enter Pluggable, Optional Type Systems

Optional Typing How do I define optional typing Concrete example:strongtalk Principled arguments for optional typing

Optional Typing How do I define optional typing Concrete example:strongtalk Principled arguments for optional typing

Optional Type Systems Run-time semantics are independent of type system Type annotations are optional

Optional Type Systems Run-time semantics are independent of type system Type annotations are optional

Common Constructs Precluded Public fields by Optional Typing Class based encapsulation, i.e. class C { private int secret; public int expose(c c) { return c.secret;} } Type based overloading draw(cowboy c)... draw(shape s)...

Optional Typing How do I define optional typing Concrete example:strongtalk Principled arguments for optional typing

Strongtalk An optional type system for Smalltalk Fastest Smalltalk ever, but does not rely on types for performance Very good fit for object oriented languages

Optional Typing How do I define optional typing Concrete example:strongtalk Principled arguments for optional typing

Theoretical Justification Closely related to theory of programming languages: Formal calculi use pluggable typing all the time, e.g. : Evaluation rules of lambda calculus need not change to accommodate type system Type system only determines which programs are guaranteed not to fail

Language Evolution Traditional type systems introduce bidirectional dependency: Type system depends on executable language Semantics of executable language depend on type system (e.g., casts, overloading, accessibility)

Language Evolution Optional typing breaks dependency of executable language on type system Type system can evolve faster than language Programs that were untypeable in the past can be typechecked now, but run the same

Type Inference Type inference relates to type system as type system relates to executable language Inference naturally depends on type system but type system should not depend on type inference Counterexample : Hindley-Milner restricts polymorphic recursion

Type Inference Type inference has caused us a lot of grief in the JVM Verifier complexity -> security bugs, maintenance headaches, performance overhead

Having our Cake and Eating it too Performance disadvantage is greatly overstated Importance of performance also overstated Other advantages of static types can be had without the downside Enter Pluggable, Optional Type Systems

From Optional to Pluggable We want various static analyses to coexist Traditional types, ownership types, tracing information flow Make it easy to experiment with new tools. How to integrate into the language?

Metadata Allows programmers to add user-defined annotations to ASTs Popularized by C#; Being added to Java

Types, Syntax & Metadata Types are just one kind of metadata Tools can choose which metadata to display Require ability to add metadata to every node of AST; Java and C# fall short Metadata might self-identify and choose its own syntax; is this a good idea?

Related Work Variants of this idea have been around for quite a while, but not quite the same Optional Types in Common Lisp Cecil (Chambers/Litvinov) Soft Typing in Scheme (Cartwright/Fagan) Type system for Erlang (Marlow/Wadler) BabyJ type system for JavaScript (Anderson, Giannini)

Conclusions Mandatory typing causes significant engineering problems Mandatory typing actually undermines security The deeper in the system one requires types, the more acute the problems Types should be optional: runtime semantics must not depend on static type system Type systems should be pluggable: multiple type systems for different needs