Introduction EMAN 2 EMAN 4 Conclusion Combined Software and Hardware Attacks on the Java Card Control Flow Guillaume Bouffard Julien Iguchi-Cartigny Jean-Louis Lanet Smart Secure Devices (SSD) Team – Xlim – Universit´ e de Limoges guillaume.bouffard @xlim.fr http://secinfo.msi.unilim.fr CARDIS 2011 i nsti tut de recherche Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 1 / 24
Introduction EMAN 2 EMAN 4 Conclusion Outline Introduction 1 EMAN 2: A Stack Underflow in the Java Card 2 EMAN 4: Modifying the Execution Flow with a Laser Beam 3 Conclusion 4 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 2 / 24
Introduction EMAN 2 EMAN 4 Conclusion Introduction 1 Java Card Security Model Everything must begin A quick overview about EMAN 1 EMAN 2: A Stack Underflow in the Java Card 2 EMAN 4: Modifying the Execution Flow with a Laser Beam 3 Conclusion 4 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 3 / 24
Introduction EMAN 2 EMAN 4 Conclusion Java Card Security Model Java Card Security Model Off-card Security Java Class Files Java Card Files Byte Code Verifier Byte Code Converter Byte Code Signer On-card Security Byte Code Verifier Installed applet Java Card Files Firewall Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 4 / 24
Introduction EMAN 2 EMAN 4 Conclusion Everything must begin Why? Our motivations Understand the implemented Java Card security mechanisms Improve these implementations Design the associated counter-measures Tools developed by the team OPAL to communicate with the smart cards The CapFileManipulator in order to modify CAP Files Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 5 / 24
Introduction EMAN 2 EMAN 4 Conclusion A quick overview about EMAN 1 EMAN1? Design by ´ Emilie Faugeron and Anthony Dessiatnikoff, former Cryptis Master degree students (2008–2009) Hypothesis Smart card loading keys are known The card has not Byte Code Verifier (BCV) The firewall does not check the call of putstatic , getstatic and invokestatic Yes, we can! Generate mutant code Dump the EEPROM & RAM memories Modify other installed applets ;) Published at SSTIC 2008 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 6 / 24
Introduction EMAN 2 EMAN 4 Conclusion Introduction 1 EMAN 2: A Stack Underflow in the Java Card 2 The Aim of this attack Obtain address array The Java Card Stack Let’s modify the stack Counter-measures EMAN 4: Modifying the Execution Flow with a Laser Beam 3 Conclusion 4 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 7 / 24
Introduction EMAN 2 EMAN 4 Conclusion The Aim of this attack The Attack idea I Attack idea Locate the return address of the current function Modify this address . . . . . . to execute our malicious byte code Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 8 / 24
Introduction EMAN 2 EMAN 4 Conclusion The Aim of this attack The Attack idea II Hypothesis There is no BCV The loading keys are known Requirements list 1 Find the array address (EMAN 1) 2 Discover where is located the return address in the stack 3 Change this value in the stack Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 9 / 24
Introduction EMAN 2 EMAN 4 Conclusion Obtain address array Find the array address ... p u b l i c short getMyAddressTabByte ( byte [ ] tab ) { foo=( byte ) 0xAA ; short tab [0]=( byte ) 0xFF ; foo ; } return getMyAddressTabByte ( byte [ ] tab ) { 03 // f l a g s : 0 max stack : 3 21 // nargs : 2 m a x l o c a l s : 1 10 AA bspush 0xAA TOS 31 s s t o r e 2 19 alo ad 1 03 sconst 0 L2: foo 02 sconst m1 39 s a s t o r e 1E s l oa d 2 @tab L1 78 s r e t u r n } ⇒ Return value: ?? this L0 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 10 / 24
Introduction EMAN 2 EMAN 4 Conclusion Obtain address array Find the array address ... p u b l i c short getMyAddressTabByte ( byte [ ] tab ) ⇐ { foo=( byte ) 0xAA ; short tab [0]=( byte ) 0xFF ; foo ; } return getMyAddressTabByte ( byte [ ] tab ) TOS { 03 // f l a g s : 0 max stack : 3 21 // nargs : 2 m a x l o c a l s : 1 10 AA bspush 0xAA AA ⇐ 31 s s t o r e 2 19 alo ad 1 03 sconst 0 L2: foo 02 sconst m1 39 s a s t o r e 1E s l oa d 2 @tab L1 78 s r e t u r n } ⇒ Return value: ?? this L0 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 10 / 24
Introduction EMAN 2 EMAN 4 Conclusion Obtain address array Find the array address ... p u b l i c short getMyAddressTabByte ( byte [ ] tab ) { foo=( byte ) 0xAA ; short ⇐ tab [0]=( byte ) 0xFF ; foo ; } return getMyAddressTabByte ( byte [ ] tab ) { 03 // f l a g s : 0 max stack : 3 21 // nargs : 2 m a x l o c a l s : 1 10 AA bspush 0xAA TOS 31 s s t o r e 2 ⇐ 19 alo ad 1 03 sconst 0 AA L2: foo 02 sconst m1 39 s a s t o r e 1E s l oa d 2 @tab L1 78 s r e t u r n } ⇒ Return value: ?? this L0 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 10 / 24
Introduction EMAN 2 EMAN 4 Conclusion Obtain address array Find the array address ... p u b l i c short getMyAddressTabByte ( byte [ ] tab ) TOS { foo=( byte ) 0xAA ; short ⇐ tab [0]=( byte ) 0xFF ; foo ; } FF return getMyAddressTabByte ( byte [ ] tab ) 00 { 03 // f l a g s : 0 max stack : 3 21 // nargs : 2 m a x l o c a l s : 1 10 AA bspush 0xAA @tab 31 s s t o r e 2 19 alo ad 1 03 sconst 0 AA L2: foo 02 sconst m1 ⇐ 39 s a s t o r e 1E s l oa d 2 @tab L1 78 s r e t u r n } ⇒ Return value: ?? this L0 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 10 / 24
Introduction EMAN 2 EMAN 4 Conclusion Obtain address array Find the array address ... p u b l i c short getMyAddressTabByte ( byte [ ] tab ) { foo=( byte ) 0xAA ; short tab [0]=( byte ) 0xFF ; } ⇐ foo ; return getMyAddressTabByte ( byte [ ] tab ) TOS { 03 // f l a g s : 0 max stack : 3 21 // nargs : 2 m a x l o c a l s : 1 10 AA bspush 0xAA AA 31 s s t o r e 2 19 alo ad 1 03 sconst 0 AA L2: foo 02 sconst m1 39 s a s t o r e 1E s l oa d 2 @tab } ⇐ L1 78 s r e t u r n ⇒ Return value: AA this L0 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 10 / 24
Introduction EMAN 2 EMAN 4 Conclusion Obtain address array Find the array address ... p u b l i c short getMyAddressTabByte ( byte [ ] tab ) { foo=( byte ) 0xAA ; short tab [0]=( byte ) 0xFF ; foo ; } return getMyAddressTabByte ( byte [ ] tab ) { 03 // f l a g s : 0 max stack : 3 21 // nargs : 2 m a x l o c a l s : 1 10 AA bspush 0xAA TOS 31 s s t o r e 2 19 alo ad 1 00 nop L2: foo 00 nop 00 nop 00 nop @tab L1 78 s r e t u r n } ⇒ Return value: ?? this L0 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 10 / 24
Introduction EMAN 2 EMAN 4 Conclusion Obtain address array Find the array address ... p u b l i c short getMyAddressTabByte ( byte [ ] tab ) ⇐ { foo=( byte ) 0xAA ; short tab [0]=( byte ) 0xFF ; foo ; } return getMyAddressTabByte ( byte [ ] tab ) TOS { 03 // f l a g s : 0 max stack : 3 21 // nargs : 2 m a x l o c a l s : 1 10 AA bspush 0xAA AA ⇐ 31 s s t o r e 2 19 alo ad 1 00 nop L2: foo 00 nop 00 nop 00 nop @tab L1 78 s r e t u r n } ⇒ Return value: ?? this L0 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 10 / 24
Introduction EMAN 2 EMAN 4 Conclusion Obtain address array Find the array address ... p u b l i c short getMyAddressTabByte ( byte [ ] tab ) { foo=( byte ) 0xAA ; short ⇐ tab [0]=( byte ) 0xFF ; foo ; } return getMyAddressTabByte ( byte [ ] tab ) TOS { 03 // f l a g s : 0 max stack : 3 21 // nargs : 2 m a x l o c a l s : 1 10 AA bspush 0xAA @tab 31 s s t o r e 2 ⇐ 19 alo ad 1 00 nop AA L2: foo 00 nop 00 nop 00 nop @tab L1 78 s r e t u r n } ⇒ Return value: ?? this L0 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 10 / 24
Introduction EMAN 2 EMAN 4 Conclusion Obtain address array Find the array address ... p u b l i c short getMyAddressTabByte ( byte [ ] tab ) { foo=( byte ) 0xAA ; short tab [0]=( byte ) 0xFF ; } ⇐ foo ; return getMyAddressTabByte ( byte [ ] tab ) TOS { 03 // f l a g s : 0 max stack : 3 21 // nargs : 2 m a x l o c a l s : 1 10 AA bspush 0xAA @tab 31 s s t o r e 2 19 alo ad 1 00 nop AA L2: foo 00 nop 00 nop 00 nop @tab } ⇐ L1 78 s r e t u r n ⇒ Return value: @tab this L0 Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 10 / 24
Introduction EMAN 2 EMAN 4 Conclusion The Java Card Stack Characterize the Stack ... Operand Stack Local variables Guillaume Bouffard (SSD – Xlim) Combined Attacks on the Java Card Control Flow CARDIS 2011 11 / 24
Recommend
More recommend