P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\titulka.jpg PV204 Security technologies Introduction to smart cards as secure elements •Petr Švenda svenda@fi.muni.cz •Faculty of Informatics, Masaryk University P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Smart cards •Lecture: –PC/SC communication framework, APDU –Basic platforms – JavaCard & .net card & MULTOS, comparison –Secure channel protocol (authentication, session keys, APDU protection), SCP –Attacks against two-factor authentication •Lab –Creating secure channel protocol –Communicating with smart cards • – | PV204 Smart cards 2 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Mind path for lecture •Smart cards are typical example of secure element ® what smart card can be ® what smart card is capable of •Current variance on cards side ® current variance on host side ® how smart cards fits into bigger system •How to communicate with cards –Contact (ISO7816-2) / contactless (ISO/IEC 14443) –Low level transmission (T=0/T=1, ISO 7816-4) –Logical packets (APDU) –Standardized API on card (OpenPlatform, PIV, OpenPGP, ePassport) –Standardized API on host (PC/SC, PKCS#11/15) –Secure channel with card (OpenPlatform SCP’03, BAC, EAC) •What are cards capable of – supported algorithms, speed •What sc can be used for –Digital signatures – generate and use private key (+ attacks), key encryption on card –Two-factor authentication, access control (challenge-response protocol) (+attacks) –Secure environment (code protection, trusted element - tokenization) (+attacks) – • • | PV204 Smart cards 3 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Overview 1.What smart cards are? 2.What smart cards are capable of? 3.How to manage smart cards? 4.Secure channel protocols 5.Two-factor authentication and attacks | PV204 Smart cards 4 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg WHAT A SMART CARD IS? •Smart card basics | PV204 Smart cards 5 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Basic types of (smart) cards 1.Contactless “barcode” –Fixed identification string (RFID, < 5 cents) 2.Simple memory cards (magnetic stripe, RFID) –Small write memory (< 1KB) for data, (~10 cents) 3.Memory cards with PIN protection –Memory (< 5KB), simple protection logic (<$1) – | PV204 Smart cards rfid 6 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Basic types of (smart) cards (2) 4.Cryptographic smart cards –Support for (real) cryptographic algorithms –Mifare Classic ($1), Mifare DESFire ($3) 5.User-programmable cryptographic smart cards –JavaCard, .NET card, MULTOS cards ($5-$30) •Chip manufacturers: NXP, Infineon, Gemalto, G&D, Oberthur, STM, Atmel, Samsung... • | PV204 Smart cards We will mainly focus on these two categories D:\Documents\Obrázky\cryptojavacard.png 7 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Cryptographic smart cards •SC is quite powerful device –8-32 bit processor @ 5-20MHz –persistent memory 32-150kB (EEPROM) –volatile fast RAM, usually <<10kB –truly random generator –cryptographic coprocessor (3DES,AES,RSA-2048,...) •8.05 billion units shipped in 2013 (ABI Research) –mostly smart cards –telco, payment and loyalty... –1 billion contactless estimated for 2016 (ABI Research) – | PV204 Smart cards ActualGoldChip EEPROM CPU CRYPTO RNG chip 8 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg hybridcard_2 Smart cards forms •Many possible forms –ISO 7816 standard –SIM size, USB dongles, Java rings… •Contact(-less), hybrid/dual interface –contact physical interface –contact-less interface –hybrid card – separate logics on single card –dual interface – same chip accessible contact & c-less | PV204 Smart cards JavaRing 8300-ACOS2-8K iKey_image 9 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Contact vs. contactless •Contact cards (ISO7816-2) –I/O data line, voltage and GND line –clock line, reset lines •Contactless cards –ISO/IEC 14443 type A/B, radio at 13.56 MHz –Chip powered by current induced on antenna by reader –Reader ® chip communication - relatively easy –Chip ® reader – dedicated circuits are charged, more power consumed, fluctuation detected by reader –Multiple cards per single reader possible – – • | PV204 Smart cards 10 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Smart cards are used for… •GSM SIM modules •Digital signatures •Bank payment card (EMV standard) •System authentication •Operations authorizations •ePassports •Multimedia distribution (DRM) •Secure storage and encryption device •… | PV204 Smart cards 11 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Smart card is highly protected device •Intended for physically unprotected environment –NIST FIPS140-2 standard, security Level 4 –Common Criteria EAL4+/5+ •Tamper protection –Tamper-evidence (visible if physically manipulated) –Tamper-resistance (can withstand physical attack) –Tamper-response (erase keys…) •Protection against side-channel attacks (power,EM,fault) •Periodic tests of TRNG functionality •Approved crypto algorithms and key management •Limited interface, smaller trusted computing base •http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140val-all.htm • | PV204 Smart cards 12 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Main advantages of crypto smart cards •High-level of security (CC EAL5+, FIPS 140-2) •Fast cryptographic coprocessor •Programmable secure execution environment •Secure memory and storage •On-card asymmetric key generation •High-quality and very fast RNG •Secure remote card control | PV204 Smart cards 13 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg SMARTCARDS IN WIDER SYSTEM • | PV204 Smart cards 14 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Big picture – terminal/reader and card | PV204 Smart cards laptop What principles and standards are used? D:\Documents\Obrazky\question.png Merchant payment Digital signature 15 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Big picture - components •User application –Merchant terminal GUI –Banking transfer GUI –Browser TLS –… •Card application –EMV applet for payments –SIM applet for GSM –OpenPGP applet for PGP –… | PV204 Smart cards server blank_card User application Card OS Card application Card I/O manager contact(less) transmission OS smart card API smart card reader 16 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg laptop | PV204 Smart cards Libraries PKCS#11, OpenSC, JMRTD Smartcard control language API C/C# WinSCard.h, Java java.smartcardio.*, Python pyscard System smartcard interface: Windows’s PC/SC, Linux’s PC/SC-lite Manage readers and cards, Transmit ISO7816-4’s APDU Custom app with direct control PC application via library: browser TLS, PDF sign… PC application with direct control: GnuPG, GPShell API: EMV, GSM, PIV, OpenPGP, ICAO 9303 (BAC/EAC/SAC) OpenPlatform, ISO7816-4 cmds, custom APDU SC app programming: JavaCard, MultOS, .NET, MPCOS Readers Contact: ISO7816-2,3 (T=0/1) Contactless: ISO 14443 (T=CL) Card application 3 Card application 2 Card application 1 17 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Main standards | PV204 Smart cards server blank_card User application Card OS Card application Card I/O manager contact(less) transmission OS smart card API smart card reader •ISO7816 1-4 –Card physical properties ISO7816-1 –Physical layer communication protocol ISO7816-2-3 –Data packet format (APDU) •PC/SC, PC/SCLite (host side) –Readers/cards management –Transmission of logical APDU packets –C/C# WinSCard.h, Java java.smartcardio.*, Python pyscard •PKCS#11 –standardized interface on host side –card can be proprietary •GlobalPlatform (details in 3rd lecture) –remote card management interface –secure installation of applications 18 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg | PV204 Smart cards server blank_card User application Card OS Card application Card I/O manager contact(less) transmission OS smart card API smart card reader Card’s programming platforms •MultOS –Multiple supported languages, native compilation –Often bank cards •JavaCard (details in 3rd lecture) –open programming platform from Sun –applets portable between cards •Microsoft .NET for smartcards –Similar to JavaCard, but C# –Applications portable between cards –Limited market penetration 19 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg apdu APDU (Application Protocol Data Unit) •APDU is basic logical communication datagram –header (5 bytes) and up to ~256 bytes of user data •Format specified in ISO7816-4 •Header/Data format –CLA – instruction class –INS – instruction number –P1, P2 – optional data –Lc – length of incoming data –Data – user data –Le – length of the expected output data •Some values of CLA/INS/P1/P2 standardized •Custom values used by application developer | PV204 Smart cards 20 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Selected software components •PC/SC (MS API: SCardxx, Java: java.smartcardio.*) •PC/SCLite (implementation of PC/SC for Linux/MAC) •OpenSC – proxy component between proprietary tokens and PKCS#11 interface •SoftHSM – virtual PKCS#11-compliant card • | PV204 Smart cards 21 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg SMARTCARD ALGORITHMS AND PERFORMANCE • | PV204 Smart cards 22 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Common algorithms •Basic - cryptographic co-processor –Truly random data generator –3DES, AES128/256 –MD5, SHA1, SHA-2 256/512 –RSA (up to 2048b common, 4096 possible) –ECC (up to 192b common, 384b possible) –Diffie-Hellman key exchange (DH/ECDSA) •Custom code running in secure environment –E.g. HMAC, OTP code, re-encryption –Might be significantly slower (e.g., SW AES 50x slower) | PV204 Smart cards 23 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Cryptographic operations •Supported algorithms (JCAlgTester, 48+ cards) –https://github.com/crocs-muni/JCAlgTest –https://www.fi.muni.cz/~xsvenda/jcsupport.html – • – D:\Documents\Obrazky\algtest_algs.png | PV204 Smart cards 24 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg What is the typical performance? •Hardware differ significantly –Clock multiplier, memory speed, crypto coprocessor… •Typical speed of operation is: –Milliseconds (RNG, symmetric crypto, hash) –Tens of milliseconds (transfer data in/out) –Hundreds of millisecond (asymmetric crypto) –Seconds (RSA keypair generation) •Operation may consists from multiple steps –Transmit data, prepare key, prepare engine, encrypt –® additional performance penalty | PV204 Smart cards 25 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Performance tables for common cards •Visit http://www.fi.muni.cz/~xsvenda/jcalgtest/ • 26 | PV204 Smart cards http://www.fi.muni.cz/~xsvenda/jcalgtest/ P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Performance with variable data lengths • 27 | PV204 Smart cards http://www.fi.muni.cz/~xsvenda/jcalgtest/ Limited memory and resources may cause non-linear dependency on a processed data length P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg SMART CARD MANAGEMENT • | PV204 Smart cards 28 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Motivation •How to upload, install and remove applications? •Who should be allowed to upload/remove apps? •What if multiple mutually distrusting apps on card? •How to update application in already issued card? • •Need for cross-platform interoperable standard –Many manufactures and platform providers • | PV204 Smart cards 29 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg GLOBALPLATFORM • | PV204 Smart cards 30 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg GlobalPlatform •Specification of API for card administration –Upload/install/delete applications –Card lifecycle management –Card security management –Security mechanisms and protocols •Newest is GlobalPlatform Card Specification v2.2.1 –January 2011 –Previous versions also frequently used –http://www.globalplatform.org/specificationscard.asp – | PV204 Smart cards 31 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg blank_card GlobalPlatform – main terms •Smart card life cycle –OP_READY, INITIALIZED (prepared for personalization) –SECURED (issued to user, use phase) –CARD_LOCKED (temporarily locked (attack), unlock to SECURED) –TERMINATED (logically destroyed) •Card Manager (CM) –Special card component responsible for administration and card system service functions (cannot be removed) •Security Domain (SD) –Logically separated area on card with own access control –Enforced by different authentication keys | PV204 Smart cards Security Domain 1 Security Domain 2 Card Manager D:\Documents\Obrázky\is2\Key-icon.png D:\Documents\Obrázky\is2\Key-icon.png 32 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg blank_card Security Domain 1 Applet 2 Security Domain 2 Applet 1 Applet 3 Card Manager GlobalPlatform – main terms •Card Content (apps,data) Management –Content verification, loading, installation, removal •Security Management –Security Domain locking, Application locking –Card locking, Card termination –Application privilege usage, Security Domain privileges –Tracing and event logging •Command Dispatch –Application selection –(Optional) Logical channel management – | PV204 Smart cards 33 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Smart card life cycles •The smart card passes various logical life cycle states between manufacture and final destruction •Life cycle states define which operations can be performed with the card •The card Life Cycle States OP_READY and INITIALIZED are intended for use during the Pre-Issuance phases of the card’s life. •The states SECURED, CARD_LOCKED and TERMINATED are intended for use during the Post-Issuance phase of the card although it is possible to terminate the card at any point during its life. | PV204 Smart cards 34 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Smart card life cycles •OP_READY –card is ready for uploading of key diversification data, any application and issuer specific structures. •INITIALIZED – card is fully prepared but not yet issued to card holder. •SECURED – card is issued to card holder. Card management is possible only throw Security domain in secure sense (installation of signed applets etc.). •CARD_LOCKED – card is locked due to some security policy and no data management can be performed. Card can be locked by Security domain and later unlocked as well (switch back to SECURED state). •TERMINATED – card is logically “destroyed“ due to card expiration or detection of the severe security thread. | PV204 Smart cards 35 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Global Platform APDU commands •DELETE – delete uniquely identifiable object (e.g. JavaCard applet) •STORE_DATA – upload content of single data object •GET_DATA - used to retrieve a single data object •SET_STATUS – set Life Cycle status •GET_STATUS – return Life Cycle status •INSTALL – initiate installation, typically (JavaCard) applet •LOAD – upload file from PC to smart card, e.g. JavaCard cap file •PUT_KEY – update value of specified key | PV204 Smart cards 36 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Card Production Life Cycle (CPLC) •Manufacturing metadata •Dates (OS, chip) •Circuit serial number •Not mandatory •GlobalPlatform APDU –80 CA 9F 7F 00 –gppro --info •ISO7816 APDU –00 CA 9F 7F 00 | PV204 Smart cards 37 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg SECURE CHANNEL PROTOCOL •How to authenticate and communicate securely? | PV204 Smart cards 38 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Transport Layer Security (TLS) Protocol | PV204 Smart cards Full TLS handshake (RFC 5246) 39 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg TLS handshake | PV204 Smart cards Credit: Cloudflare 40 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Why not to use TLS all the time? 1.Requires asymmetric cryptography –Unsuitable for slower devices 2.Requires long keys –Unsuitable for devices with small memory 3.Requires significant data overhead (~6.5KB) –http://netsekure.org/2010/03/tls-overhead/ 4.More lightweight protocols exist –RFID / smartcards / IoT… •Note: TLS can be fully implemented on smartcards –https://github.com/gilb/smart_card_TLS • – | PV204 Smart cards 41 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Secure channels – questions to ask •Integrity protection? Encryption? Authentication? •What attacker model is assumed? •One-side or mutual authentication? •What kind of cryptography is used? •What keys are required/pre-distributed? •Additional trust hierarchy required? •Is necessary to generate random numbers/keys? •What if keys are compromised? Forward secrecy? | PV204 Smart cards 42 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Secure channel protocol (SCP) requirements •What would you expect from SCP? –Entity authentication (mutual) –Fresh session keys derivation (session freshness) –Message integrity and authentication (MAC) –Message confidentiality (sym. crypto encryption) –Fresh messages (counters, hash chaining) –Forward secrecy (asym. crypto + ephemeral keys) –… • | PV204 Smart cards 43 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Secure channel – typical composition 1.Exchange basic (public) parameters 2.Generate random challenges (freshness) 3.Use pre-distributed secrets and challenges to generate session keys (protect long term secrets) 4.Compute and verify authentication cryptograms (entity authentication) 5.Encrypted&MAC message(s) (Secure Messaging) 6.End secure channel (erase session keys) | PV204 Smart cards 44 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Common lightweight SCPs •OpenPlatform SCP’01,’02 (3DES-based) •OpenPlatform SCP‘10 (RSA-based) •OpenPlatform SCP’03 (AES-based) •ISO/IEC 7816-4 Secure Messaging •ePassports Basic Access Control (3DES-based) •ePassports Extended Access Control (3DES,RSA,DH,SHA1/2-based) • | PV204 Smart cards 45 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg SCP – what to take into account •Usage scenario and expected attackers •Confidentiality and integrity of command data •Network level attacks (replay…) •Atomicity of critical operations •Robustness against side channel attacks (power analysis, fault attacks) •Robustness against incorrect attempts (limit, delay retries ) •Resilience against traffic analysis •API and implementation attacks | PV204 Smart cards 46 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg SCP – usage scenario and attacker model •What are the sensitive objects (keys, data, functions)? •What are these sensitive objects used for and what is the data flow of these objects? •What are the capabilities of the attackers (funding, tools, knowledge)? •What are the points where an attacker can observe the system (dump of exchanged messages, debugging, ...)? •Which parts of the system must be trusted to achieve required functionality (less the better)? | PV204 Smart cards 47 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg SCP – network attacks •Use HMAC or OMAC instead of simple hash only •Include command header/metadata into MAC •Pre-share two keys (encryption, mac) or derive from master instead of using only one •Use pre-shared keys only to derive session keys. Session keys are used than to generate cryptograms etc. •Session keys must be dependent on contributions from both parties. One party cannot force resulting key into specific value | PV204 Smart cards 48 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg SC – network attacks •Replay attack – hash chain better than counter only •Encrypt then MAC: MAC(ENC(data)) •Close channel on error •Use CBC rather than ECB •Be aware of block swap in ECB mode, cut attack in CBC •Do not use XOR for combination of values – use hash/HMAC instead •Reflection attack: Do not use symmetric protocol messages (A®B cannot be reflected as B®A) | PV204 Smart cards 49 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Example: GlobalPlatform SCP’03 •Mutual authentication (based on symmetric crypto) •Session key derivation (based on long-term keys) –NIST SP 800-108 •Message (APDU) confidentiality and integrity MAC 1.INITIALIZE UPDATE –Random challenge, card’s computations 2.EXTERNAL AUTHENTICATE –Terminal response 3.Secure messaging 4. | PV204 Smart cards 50 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg | PV204 Smart cards Secure Channel Protocol '03‘, Card Specification v2.2 – Amendment D, GPC_SPE_014 51 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg | PV204 Smart cards Secure Channel Protocol '03‘, Card Specification v2.2 – Amendment D, GPC_SPE_014 52 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg ePassport protocols (ICAO 9303) •Significantly more complex trust model –Passport, Inspection terminal, Trusting countries, Distrusting countries –Multiple sensitivity levels (basic info / fingerprint / iris) –Combination of symmetric and asymmetric cryptography •Basic Access Control (BAC) protocol –SCP-like protocol, static key is content from MRZ •Extended Access Control (EAC) protocol –Terminal authentication (RSA/ECDSA, SHA-1/2) –Chip authentication (DH/ECDSA key) –PACE protocol to establish session keys •Active Authentication (AA) protocol – | PV204 Smart cards More in 4th lecture 53 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg TWO FACTOR AUTHENTICATION • | PV204 Smart cards 54 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Two-factor authentication •Two factors with tokens/smart cards –Token (smart card, phone) + Knowledge (PIN, Password) 1.Authorize transaction with card and PIN 2.Authenticate with password and SMS 3.Authenticate user with One-Time Password (OTP) generated on mobile phone (stored secret key) after screen unlock (pattern) 4.… • How to attack two-factor? 1. | PV204 Smart cards D:\Documents\Obrazky\question.png 55 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Application uses PC/SC interface (SCardxx) | PV204 Smart cards User application winscard.dll reader driver USB driver APDU 56 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Where to log communication? | PV204 Smart cards User application winscard.dll reader driver USB driver APDU In-application logging Virtual reader SW USB sniffer HW USB sniffer In-card logger “Stub” winscard.dll logging 57 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg APDUPlay project (https://www.fi.muni.cz/~xsvenda/apduinspect.html) | PV204 Smart cards User application winscard.dll (stub) original.dll [begin] SCardTransmit (handle 0xEA010001)# apduCounter:0# totalBytesINCounter:1# transmitted:00 a4 04 00 0a a0 00 00 00 28 80 10 30 01 ff responseTime:31# SCardTransmit result:0x0# received:6a 81 SCardTransmit (handle 0xEA010001)# apduCounter:1# totalBytesINCounter:16# … based on ApduView utility (by Fernandes) 58 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg What can you do then… •Log all APDU send via SCardTransmit() •Log all SCardXXX function calls • • | PV204 Smart cards 59 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Visualize logged APDU’s | PV204 Smart cards 60 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg | PV204 Smart cards 61 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg For two-factor, logging is usually not enough •Manipulate incoming/outgoing APDUs –modify packet content (change receiver account number) –replay of previous packets (pay twice) –simulate presence of smart card –… • | PV204 Smart cards [RULE1] MATCH1=in=1;t=0;cla=00;ins=a4;p1=04; ACTION=in=0;data0=90 00;le=02; 00 a4 04 00 08 01 02 03 04 05 06 07 08 winscard.dll (stub) 90 00 62 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg German banking malware (2009) •Two-factor authorization of transactions (chipTAN/cardTAN) •Application code injection –modifies info about transaction and balance shown to user in browser –intercepts/modifies transaction data for signature by smart card –http://www.cio.com/article/2429854/infrastructure/german-police--two-factor-authentication-failing .html •The Fairy Tale of “What You See Is What You Sign” - Trojan Horse Attacks on Software for Digital Signatures (2001) –http://www.hanno-langweg.de/hanno/research/scits01p.pdf –Importance of physical PIN-pad and display of transaction amount independently • – 63 | PV204 Smart cards P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg German banking malware | PV204 Smart cards User application winscard.dll reader driver USB driver APDU Code inject application 64 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg ZeuS smartcard support module •ZeuS Banking Trojan (2010, 2012) –Analysed by A. Matrosov, Group-IB and others –http://www.welivesecurity.com/2010/11/05/dr-zeus-the-bot-in-the-hat/ –http://www.secureworks.com/cyber-threat-intelligence/threats/zeus/ •Smart card controlled via PC/SC interface 65 | PV204 Smart cards D:\Documents\Obrázky\SmartCard\zeus-2.png D:\Documents\Obrázky\SmartCard\zeus-5.png P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg ZeuS smartcard support module | PV204 Smart cards User application winscard.dll reader driver USB driver APDU Malicious application Malicious app 66 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg D:\Documents\Obrázky\SmartCard\ranbyus.png Win32/Spy.Ranbyus •Analysed by A. Matrosov –http://www.welivesecurity.com/2012/06/05/smartcard-vulnerabilities-in-modern-banking-malware/ •Scans for available smart cards, info send to C&C –uses PC/SC SmartCard API for scan –later redirects communication on USB level (FabulaTech USB for RD installed) • 67 | PV204 Smart cards P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Win32/Spy.Ranbyus | PV204 Smart cards User application winscard.dll reader driver USB driver APDU Malicious application Malicious app Remote USB redirection 68 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Skimmers, PoS hacks | PV204 Smart cards APDU D:\Documents\Obrázky\pos_terminal.jpg key_icon D:\Documents\Obrázky\Lock.png Manipulated PoS firmware: •Magnetic skimmer (+GSM) •MitM: chip®verified by signature D:\Documents\Obrázky\SmartCard\hybridcard_2.jpg 69 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Mandatory reading •When Organized Crime Applies Academic Results –A Forensic Analysis of an In-Card Listening Device –https://eprint.iacr.org/2015/963.pdf • •Which academic attacks is of concern? •What system is targeted? •How is attack carried out? Is it protocol flaw? •What can prevent this attack vector? | PV204 Smart cards 70 P:\CRCS\2012_0178_Redesign_loga_a_JVS\PPT_prezentace\sablona\pracovni\normalni.jpg Conclusions •Smartcards are highly secure and capable modules –Programmable –Accessible (cost, API…) •Many aspects of Secure Channel Protocols –Requirements –Attacker model –Overheads •Two-factor authentication is not silver bullet • • | PV204 Smart cards question Questions 71