Java Card Applet Firewall Java Card Applet Firewall Exploration and - - PowerPoint PPT Presentation

java card applet firewall java card applet firewall
SMART_READER_LITE
LIVE PREVIEW

Java Card Applet Firewall Java Card Applet Firewall Exploration and - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

Java Card Applet Firewall Java Card Applet Firewall Exploration and Exploitation Exploration and Exploitation

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

slide-2
SLIDE 2

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)

Introduction Introduction

slide-3
SLIDE 3

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 Specifications Java Card Specifications

slide-4
SLIDE 4

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 Java Card Firewall

slide-5
SLIDE 5

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)

Java Card Firewall Test Java Card Firewall Test

slide-6
SLIDE 6

Query the Shareable interface status:

Noncompliance #1 Noncompliance #1

if (o instanceof Shareable) ...

slide-7
SLIDE 7

Query the Shareable interface status: Specification on instanceof

  • belongs to other context and is not shareable 

SecurityException

Noncompliance #1 Noncompliance #1

if (o instanceof Shareable) ...

slide-8
SLIDE 8

Query the Shareable interface status: Specification on instanceof

  • belongs to other context and is not shareable 

SecurityException

Cards Only one card non-compliant: it says false.

Noncompliance #1 Noncompliance #1

if (o instanceof Shareable) ...

slide-9
SLIDE 9

Query the Shareable interface status: Specification on instanceof

  • 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 #1 Noncompliance #1

if (o instanceof Shareable) ...

slide-10
SLIDE 10

Privileged API methods (system owned AID instance):

Noncompliance #2 Noncompliance #2

public boolean equals(Object o);

slide-11
SLIDE 11

Privileged API methods (system owned AID instance): 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 Noncompliance #2

public boolean equals(Object o);

slide-12
SLIDE 12

Privileged API methods (system owned AID instance): 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 Noncompliance #2

public boolean equals(Object o);

slide-13
SLIDE 13

Privileged API methods (system owned AID instance): 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 #2 Noncompliance #2

public boolean equals(Object o);

slide-14
SLIDE 14

Accessing an array belonging to another context:

Noncompliance #3 Noncompliance #3

a[i] = x;

slide-15
SLIDE 15

Accessing an array belonging to another context: Specification Should result in SecurityException

Noncompliance #3 Noncompliance #3

a[i] = x;

slide-16
SLIDE 16

Accessing an array belonging to another context: Specification Should result in SecurityException Cards One card reports SystemException

Noncompliance #3 Noncompliance #3

a[i] = x;

slide-17
SLIDE 17

Accessing an array belonging to another context: Specification Should result in SecurityException Cards One card reports SystemException Severity None: the overall result is the same

Noncompliance #3 Noncompliance #3

a[i] = x;

slide-18
SLIDE 18

Creation of and accessing clear-on-deselect arrays

Noncompliance #4 Noncompliance #4

slide-19
SLIDE 19

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

Noncompliance #4 Noncompliance #4

slide-20
SLIDE 20

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 Noncompliance #4

slide-21
SLIDE 21

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 #4 Noncompliance #4

slide-22
SLIDE 22

Non-multiselectable applets and SIOs

Noncompliance #5 Noncompliance #5

slide-23
SLIDE 23

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 Noncompliance #5

slide-24
SLIDE 24

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 Noncompliance #5

slide-25
SLIDE 25

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

Noncompliance #5 Noncompliance #5

slide-26
SLIDE 26

Relates to multiselectable applets and clear-on-deselect arrays

Unexplained Specifications Unexplained Specifications

slide-27
SLIDE 27

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

Unexplained Specifications Unexplained Specifications

slide-28
SLIDE 28

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 Unexplained Specifications

slide-29
SLIDE 29

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 Unexplained Specifications

slide-30
SLIDE 30

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.

Unexplained Specifications Unexplained Specifications

slide-31
SLIDE 31

Type Confusion via Shareable Interfaces Type Confusion via Shareable Interfaces

Client Server

TypeA TypeA

slide-32
SLIDE 32

Type Confusion via Shareable Interfaces Type Confusion via Shareable Interfaces

Client Server

TypeA TypeA TypeB

slide-33
SLIDE 33

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 Type Confusion via Shareable Interfaces

Client Server

TypeA TypeA TypeB

slide-34
SLIDE 34

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 Type Confusion via Shareable Interfaces

Client Server

TypeA TypeA

Client thinks:

void service(TypeA a);

Server thinks:

void service(TypeB a);

TypeB

Whether a type confusion (introduced this or any other way) can be exploited is another subject [CARDIS 2008].

slide-35
SLIDE 35

The scenario: Certain kind of a type attack has to be possible: direct

  • bject access and reference switching

AID Exploit AID Exploit

public class AID { private byte[] aidBytes; ...

slide-36
SLIDE 36

The scenario: Certain kind of a type attack has to be possible: direct

  • bject access and reference switching

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 AID Exploit

public class AID { private byte[] aidBytes; ...

slide-37
SLIDE 37

The scenario: Certain kind of a type attack has to be possible: direct

  • bject access and reference switching

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.

AID Exploit AID Exploit

public class AID { private byte[] aidBytes; ...

slide-38
SLIDE 38

Confuse an object with an array: An object

Direct Reference Manipulation Details Direct Reference Manipulation Details

public class TestClass { Object ref = new Object(); short sVal = 10; }

#fields ref sVal

slide-39
SLIDE 39

Confuse an object with an array: An object An array

Direct Reference Manipulation Details Direct Reference Manipulation Details

public class TestClass { Object ref = new Object(); short sVal = 10; } a.length: 2 a[0]: 0x09E0 // ref a[1]: 0x000A // sVal

a.length a[0] a[1] #fields ref sVal

slide-40
SLIDE 40

Confuse an object with an array: An object An array All reference values readable and writable directly, public access

Direct Reference Manipulation Details Direct Reference Manipulation Details

public class TestClass { Object ref = new Object(); short sVal = 10; } a.length: 2 a[0]: 0x09E0 // ref a[1]: 0x000A // sVal

a.length a[0] a[1] #fields ref sVal

slide-41
SLIDE 41

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

Discussion and Conclusion Discussion and Conclusion

slide-42
SLIDE 42

Questions?

The End The End