Java Card Applet Firewall Exploration and Exploitation



Similar documents
Testing the Java Card Applet Firewall

Malicious Code on Java Card Smartcards: Attacks and Countermeasures

Malicious Code on Java Card Smartcards: Attacks and Countermeasures

JavaCard. Java Card - old vs new

Java Card TM Open Platform for Smart Cards

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

SQL Injection January 23, 2013

Adobe Systems Incorporated

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

Security Assessment of Waratek AppSecurity for Java. Executive Summary

Security in Android apps

Homeland Security Red Teaming

Software security specification and verification

1. Overview of the Java Language

Java and Java Virtual Machine Security

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

(General purpose) Program security. What does it mean for a pgm to be secure? Depends whom you ask. Takes a long time to break its security controls.

Building A Secure Microsoft Exchange Continuity Appliance

The Trivial Cisco IP Phones Compromise

Java Card Protection Profile Open Configuration

ICTN Enterprise Database Security Issues and Solutions

SMARTCARD SECURITY. Java Card Security. Marc Witteman. Introduction

IOActive Security Advisory

Crash Course in Java

WebView addjavascriptinterface Remote Code Execution 23/09/2013

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

1 Recommended Readings. 2 Resources Required. 3 Compiling and Running on Linux

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

Who am I? Dipl.-Inf. Matthias Deeg Expert IT Security Consultant CISSP, CISA, OSCP, OSCE Interested in information technology especially IT security s

CS 111 Classes I 1. Software Organization View to this point:

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

Fully Verified JAVA CARD API Reference Implementation

Customizing the Security Architecture

Penetration Testing: Advanced Oracle Exploitation Page 1

Criteria for web application security check. Version

Secure Semantic Web Service Using SAML

IS L06 Protect Servers and Defend Against APTs with Symantec Critical System Protection

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

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

Bypassing CAPTCHAs by Impersonating CAPTCHA Providers

CYBER ATTACKS EXPLAINED: PACKET CRAFTING

Penetration Testing. Presented by

Formal analysis of EMV

Threat Modeling. Frank Piessens ) KATHOLIEKE UNIVERSITEIT LEUVEN

Client Server Registration Protocol

Security features of ZK Framework

02 B The Java Virtual Machine

SCAAS: A Secure Authentication and Access Control System for Web Application Development

Adjusting Prevention Policy Options Based on Prevention Events. Version 1.0 July 2006

The Need for Fourth Generation Static Analysis Tools for Security From Bugs to Flaws

Introduction to Endpoint Security

How To Prevent An Sql Injection Attack

Application Security Testing. Generic Test Strategy

3 Improving the Crab more sophisticated programming

CS506 Web Design and Development Solved Online Quiz No. 01

Application Compatibility Best Practices for Remote Desktop Services

Chapter 7D The Java Virtual Machine

Penetration Testing Getting the Most out of Your Assessment. Chris Wilkinson Crowe Horwath LLP September 22, 2010

Thick Client Application Security

Bypassing Browser Memory Protections in Windows Vista

An evaluation of the Java Card environment

Maintaining Stored Procedures in Database Application

Adam Rauch Partner, LabKey Software Extending LabKey Server Part 1: Retrieving and Presenting Data

Passing PCI Compliance How to Address the Application Security Mandates

Securing Your Web Application against security vulnerabilities. Ong Khai Wei, IT Specialist, Development Tools (Rational) IBM Software Group

DNS REBINDING DENIS BARANOV, POSITIVE TECHNOLOGIES

Securing Database Servers. Database security for enterprise information systems and security professionals

APPLICATION SECURITY: FROM WEB TO MOBILE. DIFFERENT VECTORS AND NEW ATTACK

Persist It Using and Abusing Microsoft s Fix It Patches

Loyalty Systems over Near Field Communication (NFC)

Java and Java Virtual Machine security vulnerabilities and their exploitation techniques

Enterprise Apps: Bypassing the Gatekeeper

Pemrograman Dasar. Basic Elements Of Java

FileDrawer An Enterprise File Sharing and Synchronization (EFSS) solution.

Java History. Java History (cont'd)

Pre-authentication XXE vulnerability in the Services Drupal module

Checking Access to Protected Members in the Java Virtual Machine

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

An Overview of Java. overview-1

Mobile Application Security Study

Smart Cards a(s) Safety Critical Systems

Webapps Vulnerability Report

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

How to achieve PCI DSS Compliance with Checkmarx Source Code Analysis

OPENID AUTHENTICATION SECURITY

Study of Java Card and its Application 1 Nainesh Rawani, 2 Akhil Patel

JAVA 2 Network Security

The Top Web Application Attacks: Are you vulnerable?

ETHICAL HACKING APPLICATIO WIRELESS110 00NETWORK APPLICATION MOBILE MOBILE0001

The Nexpose Expert System

The purpose of this report is to educate our prospective clients about capabilities of Hackers Locked.

Transcription:

Java Card Applet Firewall Exploration and Exploitation Wojciech Mostowski and Erik Poll Digital Security Radboud University Nijmegen The Netherlands http://www.cs.ru.nl/~{woj,erikpoll}/

Introduction Study of the Java Card firewall mechanism in connection with research on Java Card malicious code vulnerabilities: Firewall specification study Firewall compliance tests Shareable Interface Object as a way to introduce type confusion on the card Type confusion + firewall weakness AID exploit Experimental studies on 8 cards (4 producers)

Java Card Specifications Specifications assume type correctness, i.e. bytecode is type correct. Not always clear at first sight cause of implementation mistakes Followed carefully to construct a compliance test Smaller and bigger noncompliance: Smaller: security is preserved, but the specification not followed to the letter Bigger: possible security (or at least robustness) problems Java Card 3.0 Classic Edition essentially the same as for 2.2.X

Java Card Firewall Runtime protection mechanism Provides applet data separation: each reference belongs and is confined to a context (applet), foreign reference is not accessible, including type information Provides applet data sharing: a reference can be explicitly tagged as shareable declared methods accessible to anyone The Java Card Runtime Environment has root privilege: can read and write anything JCRE data not accessible to anyone, unless it is special, e.g. JCRE entry points Again: specs assume type correctness can we exploit the firewall with broken bytecode?

Java Card Firewall Test The firewall compliance test: Test all firewall features / requirements one by one Only features testable from the applet level are tested Give warnings in human readable form A few ideas borrowed from Riscure's JCWorkBench, a few ideas transferred to JCWorkBench Out of 8 cards 5 were testable, the rest refused to install code using shareable interfaces (probable cause: bytecode verifier, loader parameters)

Noncompliance #1 Query the Shareable interface status: if (o instanceof Shareable)...

Noncompliance #1 Query the Shareable interface status: if (o instanceof Shareable)... Specification on instanceof o belongs to other context and is not shareable SecurityException

Noncompliance #1 Query the Shareable interface status: if (o instanceof Shareable)... Specification on instanceof o belongs to other context and is not shareable SecurityException Cards Only one card non-compliant: it says false.

Noncompliance #1 Query the Shareable interface status: if (o instanceof Shareable)... Specification on instanceof o belongs to other context and is not shareable SecurityException Cards Only one card non-compliant: it says false. Severity None: the overall check results are equivalent

Noncompliance #2 Privileged API methods (system owned AID instance): public boolean equals(object o);

Noncompliance #2 Privileged API methods (system owned AID instance): public boolean equals(object o); Required checks 1. firewall check: o is accessible to the calling context 2. o is an AID? if not return false 3. compare the AID bytes: return true or false

Noncompliance #2 Privileged API methods (system owned AID instance): public boolean equals(object o); Required checks 1. firewall check: o is accessible to the calling context 2. o is an AID? if not return false 3. compare the AID bytes: return true or false Cards Two cards do 2-1-3, others 1-2-3

Noncompliance #2 Privileged API methods (system owned AID instance): public boolean equals(object o); Required checks 1. firewall check: o is accessible to the calling context 2. o is an AID? if not return false 3. compare the AID bytes: return true or false Cards Two cards do 2-1-3, others 1-2-3 Severity Very Mild: 2-1-3 can reveal that o is an AID

Noncompliance #3 Accessing an array belonging to another context: a[i] = x;

Noncompliance #3 Accessing an array belonging to another context: a[i] = x; Specification Should result in SecurityException

Noncompliance #3 Accessing an array belonging to another context: a[i] = x; Specification Should result in SecurityException Cards One card reports SystemException

Noncompliance #3 Accessing an array belonging to another context: a[i] = x; Specification Should result in SecurityException Cards One card reports SystemException Severity None: the overall result is the same

Noncompliance #4 Creation of and accessing clear-on-deselect arrays

Noncompliance #4 Creation of and accessing clear-on-deselect arrays Specification Forbidden when the context is not the currently selected applet context

Noncompliance #4 Creation of and accessing clear-on-deselect arrays Specification Forbidden when the context is not the currently selected applet context Cards One card overdoes this: creation of clear-on-reset arrays is also not possible, while only clear-on-deselect should not be

Noncompliance #4 Creation of and accessing clear-on-deselect arrays Specification Forbidden when the context is not the currently selected applet context Cards One card overdoes this: creation of clear-on-reset arrays is also not possible, while only clear-on-deselect should not be Severity Very mild: limits the functionality of the card

Noncompliance #5 Non-multiselectable applets and SIOs

Noncompliance #5 Non-multiselectable applets and SIOs Specification Access to SIO is forbidden if the server is not multiselectable and is active on another logical channel

Noncompliance #5 Non-multiselectable applets and SIOs Specification Access to SIO is forbidden if the server is not multiselectable and is active on another logical channel Cards One card ignores this: access always granted

Noncompliance #5 Non-multiselectable applets and SIOs Specification Access to SIO is forbidden if the server is not multiselectable and is active on another logical channel Cards One card ignores this: access always granted Severity Semi serious: the applet has to keep track of its selections by itself to prevent problems with multiple access from outside

Unexplained Specifications Relates to multiselectable applets and clear-on-deselect arrays

Unexplained Specifications Relates to multiselectable applets and clear-on-deselect arrays Spec: Rule X applies.

Unexplained Specifications Relates to multiselectable applets and clear-on-deselect arrays Spec: Rule X applies. Spec: Rule Y applies (even if condition A is met).

Unexplained Specifications Relates to multiselectable applets and clear-on-deselect arrays Spec: Rule X applies. Spec: Rule Y applies (even if condition A is met). Problem: Seemingly condition A cannot possibly take place in scenario Y, because rule X forbids this in the first place.

Unexplained Specifications Relates to multiselectable applets and clear-on-deselect arrays Spec: Rule X applies. Spec: Rule Y applies (even if condition A is met). Problem: Seemingly condition A cannot possibly take place in scenario Y, because rule X forbids this in the first place. Only very careful analysis reveals the other condition for A to be met in scenario Y. But the short comment (even if condition A is met) is not given a detailed explanation.

Type Confusion via Shareable Interfaces Client TypeA TypeA Server

Type Confusion via Shareable Interfaces Client TypeA TypeA TypeB Server

Type Confusion via Shareable Interfaces Client TypeA TypeA TypeB Server Client and server compiled and installed at different times Change the definition of the shareable interface in the meantime The loader does not catch such changes, BCV does, but then, forbids SIOs altogether (Non-compliance #6?!) Two interfaces two types type confusion

Type Confusion via Shareable Interfaces Client TypeA TypeA TypeB Server Client and server compiled and installed at different times Change the definition of the shareable interface in the meantime The loader does not catch such changes, BCV does, but then, forbids SIOs altogether (Non-compliance #6?!) Two interfaces two types type confusion Client thinks: void service(typea a); Server thinks: void service(typeb a); Whether a type confusion (introduced this or any other way) can be exploited is another subject [CARDIS 2008].

AID Exploit The scenario: Certain kind of a type attack has to be possible: direct object access and reference switching public class AID { private byte[] aidbytes;...

AID Exploit The scenario: Certain kind of a type attack has to be possible: direct object access and reference switching public class AID { private byte[] aidbytes;... The result: Malicious applet can change these aidbytes references, and hence change the applet AID registry in any way! In turn real impersonation of an applet possible

AID Exploit The scenario: Certain kind of a type attack has to be possible: direct object access and reference switching public class AID { private byte[] aidbytes;... The result: Malicious applet can change these aidbytes references, and hence change the applet AID registry in any way! In turn real impersonation of an applet possible In reality subject to: BCV, code signing, runtime type checking, etc. But, it was possible on two open cards! Similar exploit allows to bypass firewall, but has limitations.

Direct Reference Manipulation Details Confuse an object with an array: An object #fields ref sval public class TestClass { Object ref = new Object(); short sval = 10; }

Direct Reference Manipulation Details Confuse an object with an array: An object #fields ref sval public class TestClass { Object ref = new Object(); short sval = 10; } An array a.length a[0] a[1] a.length: 2 a[0]: 0x09E0 // ref a[1]: 0x000A // sval

Direct Reference Manipulation Details Confuse an object with an array: An object #fields ref sval public class TestClass { Object ref = new Object(); short sval = 10; } An array a.length a[0] a[1] a.length: 2 a[0]: 0x09E0 // ref a[1]: 0x000A // sval All reference values readable and writable directly, public access

Discussion and Conclusion Specifications are not followed to the letter: implementations still safe, but non-compliances question platform interoperability (what is TCK for?) Specifications (although correct) still leave a little bit to be desired, Java Card 3.0 does not change the picture Restrictive on-card BCV non-compliant? The tricks and exploits are possible because of insufficient protection mechanisms against malicious byte code weak firewall design Out of 8 cards tested: 4 are non-compliant (one vulnerable to AID exploit) 3 not fully tested (BCV forbids SIOs) 1 fully compliant, but vulnerable to AID exploit

The End Questions?