Typed Assembly Languages and Security Automatons Ben Watson The George Washington University CS 297 Security and Programming Languages June 2, 2005.

Slides:



Advertisements
Similar presentations
Assembly Language – 1.
Advertisements

Type Analysis and Typed Compilation Stephanie Weirich Cornell University.
The Assembly Language Level
Dec 5, 2007University of Virginia1 Efficient Dynamic Tainting using Multiple Cores Yan Huang University of Virginia Dec
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
CSE 341, Winter Type Systems Terms to learn about types: –Type –Type system –Statically typed language –Dynamically typed language –Type error –Strongly.
An Introduction to Proof-Carrying Code David Walker Princeton University (slides kindly donated by George Necula; modified by David Walker)
The Design and Implementation of a Certifying Compiler [Necula, Lee] A Certifying Compiler for Java [Necula, Lee et al] David W. Hill CSCI
Type Checking.
Compiler Construction
Chapter 8 Runtime Support. How program structures are implemented in a computer memory? The evolution of programming language design has led to the creation.
Extensible Verification of Untrusted Code Bor-Yuh Evan Chang, Adam Chlipala, Kun Gao, George Necula, and Robert Schneck May 14, 2004 OSQ Retreat Santa.
Typed Assembly Languages COS 441, Fall 2004 Frances Spalding Based on slides from Dave Walker and Greg Morrisett.
Procedures in more detail. CMPE12cCyrus Bazeghi 2 Procedures Why use procedures? Reuse of code More readable Less code Microprocessors (and assembly languages)
3/17/2008Prof. Hilfinger CS 164 Lecture 231 Run-time organization Lecture 23.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Typed Memory Management in a Calculus of Capabilities David Walker (with Karl Crary and Greg Morrisett)
1 Enforcing Confidentiality in Low-level Programs Andrew Myers Cornell University.
Honors Compilers Addressing of Local Variables Mar 19 th, 2002.
A Type System for Expressive Security Policies David Walker Cornell University.
Secure Certifying Compilation David Walker Cornell University What do you want to type check today?
Assembly תרגול 8 פונקציות והתקפת buffer.. Procedures (Functions) A procedure call involves passing both data and control from one part of the code to.
Extensible Untrusted Code Verification Robert Schneck with George Necula and Bor-Yuh Evan Chang May 14, 2003 OSQ Retreat.
University of Washington CSE 351 : The Hardware/Software Interface Section 5 Structs as parameters, buffer overflows, and lab 3.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
Previous Next 06/18/2000Shanghai Jiaotong Univ. Computer Science & Engineering Dept. C+J Software Architecture Shanghai Jiaotong University Author: Lu,
Imperative Programming
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Fast, Effective Code Generation in a Just-In-Time Java Compiler Rejin P. James & Roshan C. Subudhi CSE Department USC, Columbia.
CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap.
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
Proof Carrying Code Zhiwei Lin. Outline Proof-Carrying Code The Design and Implementation of a Certifying Compiler A Proof – Carrying Code Architecture.
ITEC 352 Lecture 12 ISA(3). Review Buses Memory ALU Registers Process of compiling.
10/16/2015IT 3271 All about binding n Variables are bound (dynamically) to values n values must be stored somewhere in the memory. Memory Locations for.
CSE 425: Data Types I Data and Data Types Data may be more abstract than their representation –E.g., integer (unbounded) vs. 64-bit int (bounded) A language.
1 cs205: engineering software university of virginia fall 2006 Forgiveness and Permissions.
1 ICS 51 Introductory Computer Organization Fall 2009.
Assembly Language for x86 Processors 7th Edition Chapter 13: High-Level Language Interface (c) Pearson Education, All rights reserved. You may modify.
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
Secure Compiler Seminar 4/11 Visions toward a Secure Compiler Toshihiro YOSHINO (D1, Yonezawa Lab.)
Introduction CPSC 388 Ellen Walker Hiram College.
Programming Languages
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Low Level Programming Lecturer: Duncan Smeed The Interface Between High-Level and Low-Level Languages.
Types and Programming Languages Lecture 11 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Object Oriented Software Development 4. C# data types, objects and references.
SASI Enforcement of Security Policies : A Retrospective* PSLab 오민경.
Preocedures A closer look at procedures. Outline Procedures Procedure call mechanism Passing parameters Local variable storage C-Style procedures Recursion.
Chapter 10 Chapter 10 Implementing Subprograms. Implementing Subprograms  The subprogram call and return operations are together called subprogram linkage.
DR. MIGUEL ÁNGEL OROS HERNÁNDEZ 2. Software de bajo nivel.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
Just-In-Time Compilation. Introduction Just-in-time compilation (JIT), also known as dynamic translation, is a method to improve the runtime performance.
©SoftMoore ConsultingSlide 1 Code Optimization. ©SoftMoore ConsultingSlide 2 Code Optimization Code generation techniques and transformations that result.
Run-Time Environments Presented By: Seema Gupta 09MCA102.
Language-Based Security: Overview of Types Deepak Garg Foundations of Security and Privacy October 27, 2009.
Design issues for Object-Oriented Languages
Advanced Computer Systems
Java Yingcai Xiao.
Types for Programs and Proofs
C# and the .NET Framework
TALx86: A Realistic Typed Assembly Language
Security in Java Real or Decaf? cs205: engineering software
Lecture 19: Proof-Carrying Code Background just got here last week
Presentation transcript:

Typed Assembly Languages and Security Automatons Ben Watson The George Washington University CS 297 Security and Programming Languages June 2, 2005

Problems with Assembly Assembly is completely data-agnostic: it doesn’t care, doesn’t want to care what type of data you’re moving around If C is the rope to hang yourself with, then assembly is parking your car on the train tracks. At rush hour. With a full tank of gas. And you can’t leave your car. Good luck.

TALx86 Typed Assembly Language for Intel x86 processor Implements subset of Intel IA32 instruction set Designed to be “realistic”, as in compilable and usable on a real computer by real people. Allow compilation from multiple high-level languages

TALx86 Designed to overcome specific limitations in Java bytecode JVML has semantic errors that could have been discovered with a formal model JVML has semantic errors that could have been discovered with a formal model Difficult to compile other high-level languages to bytecode Difficult to compile other high-level languages to bytecode Difficult to extend Java itself due to bytecode limitations (impossible to correctly compile Scheme to bytecode, for example) Difficult to extend Java itself due to bytecode limitations (impossible to correctly compile Scheme to bytecode, for example) Bytecode interpretation is slow, thus JIT is often used—but this is an afterthought, not fundamental Bytecode interpretation is slow, thus JIT is often used—but this is an afterthought, not fundamental

Alternate solution (because I like.Net) Many of these problems that TALx86 was designed to address were also addressed in.Net Formal design models were used Formal design models were used CLR designates minimal feature set for supported languages CLR designates minimal feature set for supported languages Scheme compilations is possible, along with dozens of other languages JITted code part of the design of runtime and language JITted code part of the design of runtime and language MSIL, like bytecode, is a typed intermediate assembly language MSIL, like bytecode, is a typed intermediate assembly language

TALx86 Features Most basic assembly features Stack-allocationType-checking Arrays and unions Recursive types (i.e., linked lists) Annotations

Popcorn Standard C isn’t strongly typed and thus can’t be represented as TALx86 A strongly-typed C-based language Support for polymorphism, abstract types, tagged unions, and exceptions Won’t discuss too much

TALx86 Compilation Process Main.tal – assembly listing Main_i.tali – import interfaces Main_e.tale – export interfaces

TALx86 Annotations Import/export interfaces (for type-checking separate object files) Import/export interfaces (for type-checking separate object files) Type constructors (how to declare new types) Type constructors (how to declare new types) Preconditions on code labels (register must have type X before code entered) Preconditions on code labels (register must have type X before code entered) Types for static data Types for static data Type coercions (converting one type to another) Type coercions (converting one type to another) Macros (type checker can treat entire section as single action) Macros (type checker can treat entire section as single action)

TALx86: Register Preconditions int i = n+1; int s = 0; While (--i > 0) s+=i; mov eax, ecx;i=n inc eax;++i mov ebx, 0;s=0 jmp test body: {eax: B4, ebx: B4} add ebx, eax;s+=i test: {eax: B4, ebx: B4} dec eax;--i cmp eax, 0;i>0 jg body B4: 4-byte integer

TALx86: Supporting C/Win32 calling conventions Predicate to describe state of stack {esp: sptr {eax: B4}::B4::se} {esp: sptr {eax: B4}::B4::se} The stack must contain a pointer to a 4-byte int, an int (function argument), then nothing else The stack must contain a pointer to a 4-byte int, an int (function argument), then nothing else Can be generalized to any stack “shape”  :Ts {esp: sptr {eax: B4, esp: sptr B4::  }::B4::  }  :Ts {esp: sptr {eax: B4, esp: sptr B4::  }::B4::  }

TALx86 A type verifier checks the validity of each instruction in each label’s block The type checker is programmed for the semantics of TALx86/IA32 instructions The type checker is programmed for the semantics of TALx86/IA32 instructions Additional rules for Memory allocation Memory allocation But not deallocation! (hence the use of a garbage collector) Arrays Arrays Lists, structs Lists, structs

TALx86: Optimizations Abbreviations (to take less space in source) Remove repetitions (i.e., a stack and its return address have the same type) Forward branch targets need no precondition

TALx86: A foundation for security TALx86 gives you assurance when you compile your code that type safety is enforced It does not add security per se For that, let’s move on to…

Type Systems for Expressive Security Policies Assumes a strongly typed language (such as TALx86) Uses security automata Can always be enforced by runtime checks Can always be enforced by runtime checks Can rewrite programs to obey policy Can rewrite programs to obey policy

Security Automaton

Enforcing Security Automatons Code Instrumentation Auxiliary code (usually for monitoring purposes) Auxiliary code (usually for monitoring purposes) C/C++ usually has to be recompiled C/C++ usually has to be recompiled.Net and Java don’t always (runtime environment + reflection).Net and Java don’t always (runtime environment + reflection)

Enforcing Security Automatons Formal: Let next =  send (current) If next = bad then halt else send()

Enforcing Security Automatons Example:Before:…Send();…

After:… State nextState = GetNextState(currentState); if (nextState == badState) { throw new SecurityException(); }Send();…

Security Instrumentation Systems SASI Security Automata SFI Implementation Security Automata SFI Implementation Software Fault Isolation An implementation of security automatons and instrumentation An implementation of security automatons and instrumentation Slows down native code, but only slightly Slows down native code, but only slightly Reimplemented Java security manager—at least as efficient Reimplemented Java security manager—at least as efficient

Enforcing Security Automatons But what if someone hacks the state- checking code? Prove that the state-checking code is correct Prove that the state-checking code is correct Augment the type system to include value states, similar to TALx86 Augment the type system to include value states, similar to TALx86 Associate predicates with each enforceable statement Associate predicates with each enforceable statement These are decidable at compile-time

Enforcing Security Automatons Optimizations Some predicates are always true, given a certain state – the check can be removed Some predicates are always true, given a certain state – the check can be removed Perform control-flow analysis that propagates proven predicates throughout program Perform control-flow analysis that propagates proven predicates throughout program Possibly proving further predicates that can be removed

Benefits of Previous Techniques Prevents things like buffer overflow attacks More confidence in machine-level code Stronger high-level  low-level mapping

References Morrisett, et al. TALx86: A realistic typed assembly language, ACM SIGPLAN Workshop on Compiler Support for System Software, pages 25-35, Atlanta, GA, USA, May 1999 Walker, David. A type system for expressive security properties. Twenty-Seventh ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages , Boston, MA, USA, January 2000