Malicious Code on Java Card Smartcards: Attacks and Countermeasures



Similar documents
Malicious Code on Java Card Smartcards: Attacks and Countermeasures

Java Card Applet Firewall Exploration and Exploitation

JavaCard. Java Card - old vs new

Testing the Java Card Applet Firewall

Java Card. Smartcards. Demos. . p.1/30

SMARTCARD SECURITY. Java Card Security. Marc Witteman. Introduction

Java Card TM Open Platform for Smart Cards

Software security specification and verification

Restraining Execution Environments

1. Overview of the Java Language

Mobile Application Languages XML, Java, J2ME and JavaCard Lesson 04 Java

Secure application programming in the presence of side channel attacks. Marc Witteman & Harko Robroch Riscure 04/09/08 Session Code: RR-203

Threat Modeling. Frank Piessens ) KATHOLIEKE UNIVERSITEIT LEUVEN

Embedded Java & Secure Element for high security in IoT systems

Sandy. The Malicious Exploit Analysis. Static Analysis and Dynamic exploit analysis. Garage4Hackers

Java and Java Virtual Machine Security

Eugene Tsyrklevich. Ozone HIPS: Unbreakable Windows

Analysis of Secure Key Storage Solutions on Android

UNCLASSIFIED Version 1.0 May 2012

A SECURITY ARCHITECTURE FOR AGENT-BASED MOBILE SYSTEMS. N. Borselius 1, N. Hur 1, M. Kaprynski 2 and C.J. Mitchell 1

I Control Your Code Attack Vectors Through the Eyes of Software-based Fault Isolation. Mathias Payer, ETH Zurich

Security Vulnerability Notice

Cloud Computing. Up until now

Jonathan Worthington Scarborough Linux User Group

RE-TRUST Design Alternatives on JVM

Mobile Devices and Malicious Code Attack Prevention

APPLETS AND NETWORK SECURITY: A MANAGEMENT OVERVIEW

jcardsim Java Card is simple!

Attacks on Clients: Dynamic Content & XSS

KAIST Cyber Security Research Center SAR(Security Analysis Report) Date. August 31, Modified

02 B The Java Virtual Machine

Securing software by enforcing data-flow integrity

2 Introduction to Java. Introduction to Programming 1 1

Homeland Security Red Teaming

QUIRE: : Lightweight Provenance for Smart Phone Operating Systems

RVS Seminar Deployment and Performance Analysis of JavaCards in a Heterogenous Environment. Carolin Latze University of Berne

Smart Cards a(s) Safety Critical Systems

WEB SECURITY. Oriana Kondakciu Software Engineering 4C03 Project

Fine-Grained User-Space Security Through Virtualization. Mathias Payer and Thomas R. Gross ETH Zurich

Joeri de Ruiter Sicco Verwer

Java Card Protection Profile Open Configuration

CSC 551: Web Programming. Spring 2004

Pluggable Type Systems. Gilad Bracha

JCAT. Java Card TM. An environment for attack and test on. Serge Chaumette, Iban Hatchondo, Damien Sauveron CCCT 03 & ISAS 03

CSCI E 98: Managed Environments for the Execution of Programs

Oracle Solaris Studio Code Analyzer

SQL Injection January 23, 2013

Confinement Problem. The confinement problem Isolating entities. Example Problem. Server balances bank accounts for clients Server security issues:

Lecture 17: Mobile Computing Platforms: Android. Mythili Vutukuru CS 653 Spring 2014 March 24, Monday

Enhanced Model of SQL Injection Detecting and Prevention

THE IMPORTANCE OF CODE SIGNING TECHNICAL NOTE 02/2005

Operating System Structures

Adobe Systems Incorporated

Format string exploitation on windows Using Immunity Debugger / Python. By Abysssec Inc

What is Web Security? Motivation

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

Security Guide. BlackBerry Enterprise Service 12. for ios, Android, and Windows Phone. Version 12.0

Hardware/Software Co-Design of a Java Virtual Machine

BlackBerry Enterprise Server Wireless Software Upgrades Version: 4.1 Service Pack: 7. Administration Guide

Top virtualization security risks and how to prevent them

Where every interaction matters.

Chapter 7D The Java Virtual Machine

Chapter 9 Firewalls and Intrusion Prevention Systems

CIS 551 / TCOM 401 Computer and Network Security

資 通 安 全 產 品 研 發 與 驗 證 (I) ICT Security Overview. Prof.. Albert B. Jeng ( 鄭 博 仁 教 授 ) 景 文 科 技 大 學 資 訊 工 程 系

Advanced Endpoint Protection Overview

Security Issues of the Sandbox inside Java Virtual Machine (JVM) Mohammad Shouaib Hashemi

Stateful Inspection Technology

Software security. Buffer overflow attacks SQL injections. Lecture 11 EIT060 Computer Security

Cyber Security in Taiwan's Government Institutions: From APT To. Investigation Policies

Last update: February 23, 2004

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

How Security Testing can ensure Your Mobile Application Security. Yohannes, CEHv8, ECSAv8, ISE, OSCP(PWK) Information Security Consultant

Google Apps Engine. G-Jacking AppEngine-based applications. Presented 30/05/2014. For HITB 2014 By Nicolas Collignon and Samir Megueddem

PUF Physical Unclonable Functions

Habanero Extreme Scale Software Research Project

COS 318: Operating Systems

Java Card 2.2 Off-Card Verifier

OPERATING SYSTEMS MEMORY MANAGEMENT

Intro to Firewalls. Summary

Administration Guide. Wireless software upgrades

Semantic Analysis: Types and Type Checking

Software & Hardware Security

Oracle Solaris Security: Mitigate Risk by Isolating Users, Applications, and Data

How To Prevent An Sql Injection Attack

Security Vulnerability Notice

Securing EtherNet/IP Using DPI Firewall Technology

QA Analysis of the WRF Program

The Devils Behind Web Application Vulnerabilities

The SmartLogic Tool: Analysing and Testing Smart Card Protocols

Java Interview Questions and Answers

Transcription:

Malicious Code on Java Card Smartcards: Attacks and Countermeasures Wojciech Mostowski and Erik Poll Digital Security Radboud University Nijmegen To be presented at CARDIS'2008 Erik Poll Radboud University Nijmegen 1

Background and motivation Overview Ways to create type confusion experiments on actual cards Ways to exploit type confusion experiments on actual cards runtime countermeasures used Conclusions Erik Poll Radboud University Nijmegen 2

Background Java Card smartcard allow multiple applets to be installed installation strictly controlled by digital signatures or completely disabled eg on Dutch Java Card epassport Most JavaCard smartcards have no bytecode verifier could malicious, illtyped applets do any damage? not just to other applets, but also to platform eg retrieving bytecode of platform implementation Java Cards do have a firewall can this compensate for absence of bvc? Erik Poll Radboud University Nijmegen 3

Two lines of defence on Java Card platform Type safety Firewall enforced by bytecode verifier at installation time optional; most cards use code signing instead enforced by VM at runtime restricts interactions between applets that type system allows quite tricky!! Are these defences complementary or defenseindepth? what guarantees can firewall make about illtyped code? Erik Poll Radboud University Nijmegen 4

Java security: typesafety + visibility public access untrusted applet private access trusted applet public access public access Java platform (JRE = VM + API) Erik Poll Radboud University Nijmegen 5

Java security: typesafety + visibility + sandbox public access untrusted applet private access trusted applet disallowed API call allowed API call sandbox Java platform (JRE = VM + API) Erik Poll Radboud University Nijmegen 6

reference Java security: typesafety + visibility + sandbox untrusted applet reference public access private access disallowed API call sandbox trusted applet Java platform (JRE = VM + API) no protection if trusted applet or API exposes public field exposes too much functionality leaks reference allowed API call Erik Poll Radboud University Nijmegen 7

JavaCard security:... + firewall untrusted applet trusted applet runtime checks to prevent exposing public field exposing too much functionality leaking reference ok JCRE entry points Java platform (JRE = VM + API) Erik Poll Radboud University Nijmegen 8

llltyped code on Java Card NB Java Card specifications only define behaviour of welltyped programs For illtyped code, all bets are off... This is case for VM spec, API specs, and JCRE specs Eg a card could do a complete memory dump if a type error occurs. The specs allow this, but it's clearly unwanted. Only way to find out what happens: test some cards Erik Poll Radboud University Nijmegen 9

Rest of this talk Ways to create type confusion how can be trick the VM in accessing the same piece of physical memory via references with different (incompatible) types? Ways to exploit type confusion to do some damage ie. 'illegally' read or write memory in ways that should not be allowed Erik Poll Radboud University Nijmegen 10

Way to create type confusion byte code editing edit bytecode by hand to introduce type errors or use some tool, eg by ST Microelectronics abusing shareable interface mechanism two welltyped applets with type mismatch in shareable interface between them abusing transaction mechanism exploring bug in transaction mechanism implementation fault injections? introduce hardware fault (eg by laser) to corrupt memory that stores bytecode Erik Poll Radboud University Nijmegen 11

Creating type errors with shareable interface Firewall allows applets to communicate via shareable interfaces. We can abuse this to create type confusion: applet A byte[] byte[] short[] applet B A thinks B thinks void accessarray(byte[] a); void accessarray(short[] a); Both applets typecorrect (individually), compilable, and loadable. Pro: need to hardwrite bytecode Con: overhead Erik Poll Radboud University Nijmegen 12

Creating type errors using transactions class MyApplet extend Applet { short[] s; // instance field byte[] b; // instance field void somemethod(){ short[] local = null; JCSystem.beginTransaction(); s = new short[1]; s[0] = 24; JCSystem.endTransaction();... s is either allocated and initialised, or neither, even if execution is interrupted by a card tear s reset to null if a card tear occurs during transaction Erik Poll Radboud University Nijmegen 13

Creating type errors using transactions class MyApplet extend Applet { short[] s; // instance field byte[] b; // instance field void somemethod(){ short[] local = null; JCSystem.beginTransaction(); s = new short[1]; s[0] = 24; local = s; JCSystem.abortTransaction(); // resets s to null b = new byte[10]; if ((Object)b ==(Object)local))...// true on some cards!!! buggy transaction mechanism reset only s to null, not local Erik Poll Radboud University Nijmegen 14

One role of formal methods (Too) hard to formalise > Hard to implement > Security problems are not unlikely... For example, the transaction mechanism is very tricky when allocating objects inside transactions see Nicolas Rousset's thesis, Chapter 3 Erik Poll Radboud University Nijmegen 15

Experiments creating type confusion oncard bytecod bcv? abusing e abusing shareab editing transac le tion A2 11 A2 21 B2 11 B2 2 B2 21 illtyped code possible on card C211 despite bcv!! because of buggy transaction mechanism cards with bcv don't allow shareable interfaces and hence are not standardcompliant? C2 11 ye s C21 1' yes D2 11 Erik Poll Radboud University Nijmegen 16

Ways to exploit with type confusion confusing byte arrays and short arrays possibly accessing twice as much memory accessing array as object possibly set the length field accessing object as array possibly doing pointer arithmetic (using numeric value as references) confusing objects of various types possibly accessing outside memory or doing pointer arithmetic Erik Poll Radboud University Nijmegen 17

class A { final short x; Confusing object types class B { short x, Object y, z; short y; } } What if VM can be tricked to access object A a as if it is of type B? A a x y B b x y z We might be able to access memory outside bounds (namely a.z) do pointer arithmetic (using a.y) modify final fields (namely a.x) Erik Poll Radboud University Nijmegen 18

Accessing byte array as short array byte[] b = { 23, 24}; // b.length = 2 If we acccess byte[] b as short[] s, then what is s.length? what is s[1]? byte[] b length b[0] b[1] short[] s length s[0] s[1] If VM can be tricked in treating byte[] as short[], physical array size might double, allowing access outside array bounds Erik Poll Radboud University Nijmegen 19

Accessing object as array (1) [M Witteman, RSA2003] public class FakeArray { short length = 0x7FFF; short x = 23 ; } FakeArray a 0x7FF 23 short[] s length s[0] s[1] s[2] If VM can be tricked in treating FakeArray as short[], maybe array lengths can be set accessing memory way outside the object's bounds depending on layout of objects and arrays in memory Erik Poll Radboud University Nijmegen 20

Accessing object as array (2) public class MyObject { A a = new A(); B b = new B(); C c = new C(); } MyObject o a b c Treating MyObject o as a short[] s, what happens with s[0] = s[1];? swapping references like this works on some cards s[0] = 24612;? spoofing a reference like this fails on nearly all cards Erik Poll Radboud University Nijmegen 21

Runtime defense mechanisms Some cards employ runtime countermeasures: Physical Bounds Checking (PBC) array bounds are checked using physical sizes rather than logical sizes confusing byte[] and short[] becomes harmless Object Bounds Checking (OBC) object bounds checked at runtime just like array bounds confusing objects and arrays becomes less harmfull ; no access beyond object's original size Runtime Type Checking (RTC) object types are checked at runtime for every VM step all attempts at type confusion become harmless Erik Poll Radboud University Nijmegen 22

Experiments running illtyped code protection? byteshort[ ] object as array array as object A2 11 PB C A2 21 O B C B2 11 R T C B2 2 O B C B2 21 R T C C2 11 bc v C21 bcv 1' D2 11 reference switching ~ in AIDs reference spoofing nt nt possible but harmless possible and dangerous nt = not tried Erik Poll Radboud University Nijmegen 23

Reference switching in AID objects package javacard.framework public class AID { final byte[] theaid; }... reference switching on some cards allows theaid field in AIDs (Applet IDentifiers) to be changed to point to other byte arrays this allows systemowned AIDs to be changed AIDs are used for identifying applets on the card... Erik Poll Radboud University Nijmegen 24

Conclusions Many attacks, some with harmful results Oncard bcv not sufficient if there are bugs in transaction mechanism... Also, oncard bcv limits functionality: no Shareable Interfaces between applets (Increasingly?) cards employ runtime countermeasures runtime checks more robust that static checks! runtime typechecking is best countermeasure downside: performance overhead? All this applies only to open cards no threat on most (all?) Java Cards in the field Erik Poll Radboud University Nijmegen 25