can’t touch this: cloning any android hce contactless card · can’t touch this: cloning any...

94
Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek [email protected] slawekja HackInTheBox Amsterdam, 13.04.2017 https://www.youtube.com/watch?v=tELZEPcgKkE

Upload: others

Post on 21-Apr-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Can’t Touch This:

Cloning Any Android

HCE Contactless Card

Sławomir [email protected]

slawekja

HackInTheBox Amsterdam, 13.04.2017

https://www.youtube.com/watch?v=tELZEPcgKkE

Page 2: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Cloning

1996: Dolly the sheep

Page 3: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Cloning

1996: Dolly the sheep

2001: cat „CopyCat”

2003: horse

Page 4: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Humans? Why no humans?

I. Commercial – no commercial interest in industries

II. Ethical/legal – beliefs, laws...

III. Technical - pets easy, primates very hard

Page 5: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Are we sure?

Page 6: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

2017 – mobile contactless payment cards cloning?

I. Commercial

https://www.statista.com/statistics/461512/nfc-mobile-payment-users-worldwide/

Page 7: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

2017 – mobile contactless payment cards cloning?

I. Commercial

II. Ethical/legal

III. Technical

https://www.statista.com/statistics/461512/nfc-mobile-payment-users-worldwide/

Page 8: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Technical countermeasures

https://www.flickr.com/photos/un_photo/6872103103/www.wordclouds.com

Page 9: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

https://www.flickr.com/photos/mujitra/8606262790/

Page 10: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

HCE TECHNOLOGY

Page 11: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

„Secure Element” (since 2007)

OS

Mobile app

Applet NFC Antenna

Card data, payment services

SE communicates directly with NFC• Apps and OS have no access to card

data and to communication during payment.

Secure Element

Page 12: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

SE dominance hierarchy clashes

Banks vs mobile operators,

handset manufacturers,

payment service providers...

Painful process

- special SIM required

- limited supporthttps://www.flickr.com/photos/jsouthorn/6616455243/

Page 13: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Google vs Isis Wallet

2011: Google Wallet with Galaxy Nexus

embedded SE

Isis wallet (AT&T, Verizon, T-Mobile) -

blocked Google Wallet for their devices.

Google: we will go our way - without SE.

Page 14: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Host Card Emulation

Android >=4.4, Blackberry OS, Windows

Phone

No need for troublesome Secure Element,

moved to „cloud”.

Software emulates contactless smart card.

OS

Payment app

Page 15: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Demo

How does it work?

Page 16: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

INTEGRATION

Page 17: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

How to embed it in mobile app?

• Own implementation

• External, „blackbox”

library

- Visa, Mastercard SDK

- several other products

https://www.flickr.com/photos/lluniau_rich/580859948/

Page 18: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Vendors’ doc

Page 19: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Vendors’ doc

Mobile phone (Android 4.4 +)

Bank’s mobile appHCE Applet

NFC controller

HCE API

„Secure Element in the

Cloud”

SDK

API

Page 20: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Sławomir Jasek

Enjoy appsec (dev, break, build...)

since 2003.

Pentesting, consultancy, training -

web, mobile, embedded...

Significant part of time for research.

Page 21: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

HOW TO STEAL THE MONEY?

Page 22: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Right, so how to steal the money?

http://en.wikipedia.org/wiki/Olsen_Gang

Page 23: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Steal the phone?

immediate report and cancel

https://twitter.com/thereaIbanksy/status/842853661407678464

Page 24: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Steal card data via NFC?

Credit card reader?

Let’s try!

The screen has to be on. In some cases

unlock is required.

You won’t make online payments using it.

Creating magstripe track may be possible.https://play.google.com/store/apps/details?id=com.github.devnied.emvnfccard

Page 25: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Tokenization

Random card numbers (tokens) replacing single static PAN

Limited „domain” use – only for contactless transactions

4556 6519 7871 5407

4485 7332 2613 9733

Page 26: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

So, how are the EMV transactions executed?

a

EMV crypto

tokenized PAN

Page 27: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

The key

How to steal it? OS

Mobile app

Page 28: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Intercept in transfer?

"Secure Element in the cloud"

server

Google Cloud Messaging

Mobile wallet server

Page 29: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Typically

Multiple servers, push included

Certificate pinning

Second layer encryption

"encryptedData":"AAABdxcgfXea9B050gH9/a1fcJz//UpQihZrvfdHwZboTo3kNN45M0

eemFMrM1EM0BzixsDHTMFeUenl9CKMjsbJT/IvZZGceL5KmQK971NoI5wo8Kh5qgF/hazsU

2uOlyu5NxsE69QE62cffruh55DvX8f7/g=="

Page 30: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Flaws?

Improper pinning – accept all certs, use vulnerable lib...

Nasty bugs „deeply hidden” under the proprietary

encryption layer.

- Difficult to exploit, need active access to transmission

during provisioning.

Page 31: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

The key

How to steal it?

• Intercept in transfer?

Stored in user-space – not hardware Secure

Element.

• Get it from the phone?

OS

Mobile app

Page 32: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Mobile malware?

Most common:

• Overlay stealing data

• Intercept SMS

• ...

• Does not have access to card

data (private folder of the app)

https://www.flickr.com/photos/freejay3/3335151608/

Page 33: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

How to access the data?

https://en.wikipedia.org/wiki/The_Creation_of_Adam

root = GOD

Page 34: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Rooting possibilities?

Page 35: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Malware with root?

Sources: Ars Technica, Threatpost, Trend Micro, Hackread

Page 36: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Key stored on the device

Stored in user-space – not hardware

Secure Element.

How to steal it?

• Intercept in transfer?

• Get it from the phone? Root malware!

But the key is encrypted... How to decrypt?

OS

Mobile app

Page 37: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Decompile the app binary?

Page 38: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

https://twitter.com/FailsWork/status/827135802882813953/

Page 39: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

How does it work?

Page 40: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Encryption

Does not require user interaction (no PIN/pass).

Works also when phone is offline.

So, what can we do to clone the card?

data

stored on

the phone

hardcoded in

app

Page 41: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Install the same app, copy data?

OS

Mobile app

OS

Mobile app No, it does not work

The key is tied to specific device

Page 42: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Encryption again

data

stored on

the phone

hardcoded in

app

ID

Device-specific

characteristic

Page 43: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

How about exactly same hardware device?

OS

Mobile app

OS

Mobile app

Same model, OS version, IMEI...

Page 44: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Works!

In most cases you need to copy also other user data

(not just the payment app)

Not really practical attack on a mass scale...

Page 45: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

How to make it to a different device?

OS

Mobile app

OS

Mobile app

Page 46: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Device characteristics?

AndroidID

DeviceID (IMEI)

Phone number

MAC address

Manufacturer, Model

Serial

OS version, build

Page 47: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Device characteristics?

AndroidID

DeviceID (IMEI)

Phone number

MAC address

Manufacturer, Model

Serial

OS version, buildMay change in time

Page 48: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Device characteristics?

AndroidID

DeviceID (IMEI)

Phone number

MAC address

Manufacturer, Model

Serial

OS version, buildMay change in time

Mostly inaccessible

02:00:00:00:00:00 (privacy)

Page 49: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Device characteristics?

AndroidID

DeviceID (IMEI)

Phone number

MAC address

Manufacturer, Model

Serial

OS version, buildMay change in time

Mostly inaccessible

02:00:00:00:00:00 (privacy)

Non-standard, mostly not used

Require special privileges, e.g. „Make phone calls, ..”

Most common

Page 50: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Xposed Framework

Change behavior of system and apps

Hooks into system calls.

Requires root.

OS

Xposed (intercepts

calls)

Mobile app

Page 51: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

OS

Mobile app

Dev

iceI

D?

38

82

34

3...

OS

Xposed

Mobile app

Dev

iceI

D?

66

66

66

6...

Standard

device

Xposed -

framework

+ module

changing ID

Page 52: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Xposed – helps to imitate original device

OS

Xposed

Mobile app

OS

Mobile app

The key is tied to specific device

Page 53: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

ROOT DETECTION

Page 54: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Root detection?

Having ultimate control

you can always hide from

detectors.

Detection checks for

popular rooting ways

http://simpsons.wikia.com/wiki/The_Itchy_%26_Scratchy_Show

Page 55: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

SafetyNet root detection

private static final String[] a = {

"/system/bin/su",

"/system/xbin/su",

"/system/bin/.su",

"/system/xbin/.su" };

Page 56: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

https://www.flickr.com/photos/136682034@N03/26086288495/

Live demo

Page 57: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Cloning script

tar

chown

restorecon

https://www.flickr.com/photos/alijava/27634909445

Page 58: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

backup.sh

<redacted>

Page 59: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

restore.sh

<redacted>

Page 60: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

The secret ingredient

OS

User data

OS

User data

Exactly same OS and Google Services version

Page 61: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Real risk?

PoC was on a single, small amount

transaction from the same network

and physical location.

Google definitely has some

FDS/behavioral analysis systems.

https://www.flickr.com/photos/tambako/3655641638/

Page 62: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

KEYS REPLENISHMENT

Page 63: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Finally, we can use the card on other device!

… but the keys are limited-use.

Only a few transactions < 25 EUR each?

Then the keys have to be replenished.

So, how does it work?

Page 64: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Keys replenish – most common: GCM combined

"Secure Element in the cloud"

server

Google Cloud Messaging

Mobile wallet server

Page 65: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

This part we already have

Mobile wallet server

Not able to determine attacker

vs original user

Page 66: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

How to hijack GCM push?

"Secure Element in the cloud"

server

Google Cloud Messaging

Page 67: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Hijack GCM push

Copy relevant user data (/data/system/users, ...)

Both devices have same AndroidID, keys, subscriptions

Test push received by:

- sometimes both

- only one (mostly „cloned”)

- I can block original user

data data

Page 68: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Having root access to victim’s phone

- Make few low-value transactions from another

device

- Make multiple transactions (renew limited-use keys)

- But... there are usually limits on number of

transactions

Page 69: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

FLOOR LIMIT

Page 70: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

The „floor limit”

Transactions > 25 EUR need authorization

Several options:

• Enter card PIN in terminal

BUT - how do you set up the PIN?

Mobile malware -> can sniff the PIN / trick

user into entering it

Page 71: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

The „floor limit”

Transactions > 25 EUR need

authorization

Several options:

• Enter card PIN in terminal

• CDCVM

Page 72: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

CDCVM

Page 73: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Consumer Device Cardholder Verification Method

a

Malware=steal the PIN

On-device cardholder verification (e.g. PIN)

EMV crypto

Page 74: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Having root access to victim’s phone

- Make few low-value transactions from another

device

- Make multiple transactions (renew limited-use keys)

- Make transactions on higher amounts

Page 75: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

CDCVM – not very common

< 20% apps support it

So what if application does not support CDCVM?

Page 76: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

CDCVM API methods in HCE library?

API method names (cannot be obfuscated)

setCvmVerificationMode(CvmMode

paramCvmMode);

setCvmVerified(boolean paramBoolean);

Page 77: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Patch the application - smali?

const/4 v9, 0x1

invoke-interface {v8,v9}, L<redacted>;->setCvmVerified(Z)V

new-instance v9, L<redacted>/CvmMode;

sget-object v10, L<redacted>/VerifyingEntity;->MOBILE_APP:

L<redacted>/VerifyingEntity;

sget-object v11, L<redacted>/VerifyingType;->PASSCODE:

L<redacted>/VerifyingType;

invoke-direct {v9, v10, v11}, L<redacted>/CvmMode;-><init>

(L<redacted>/VerifyingEntity;L<redacted>/VerifyingType;)V

invoke-interface {v8, v9}, L<redacted>;->setCvmVerificationMode

(L<redacted>/CvmMode;)V

Page 78: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

CDCVM in app which does not support it ;)

aPatched app

On-device cardholder verification

EMV crypto

Page 79: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Results are inconsistent...

• Terminal did not ask for PIN

• Transaction was declined (but the card was incorrect

anyway)

Definitely worth digging deeper

Page 80: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

OTHER APPS

Page 81: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Other applications

Most banks think of/are during/after implementation.

We have physically proved cloning possible in 8 apps

(and 7 libs).

Others we can estimate based on libs used (PoC

requires account in bank).

Page 82: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

The easiest one

No root detection

Simple device checks

No GCM push for

replenish

http://shaunthesheep.wikia.com/wiki/File:Pushing_Shirley.jpg

Page 83: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

The hardest one

Checks multiple device characteristics

Native lib root detection

Good integrity checks and obfuscation

Had to use unrooted phone - same

model, with cloned IMEI

Page 84: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

WHAT CAN WE DO BETTER?

Page 85: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Don’t be the last one...

Page 86: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Check for more device characteristics?

Device serial

SIM serial/IMSI

Display size?

CPU?

Sensors?

https://www.flickr.com/photos/volvob12b/11248541865/

Page 87: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Improve root detection

Craft your own

SafetyNet

• will definitely improve

RootBeer

• Open-source

https://github.com/scottyab/rootbeer/

https://play.google.com/store/apps/details?id=com.scottyab.rootbeer.sample

Page 88: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Integrity checks, binary protections...

Code obfuscation

Install source, signing keys

Tamper, debug detection

Notifications, reporting

Wipe on compromise

https://www.flickr.com/photos/carolynwill/1118743053

Page 89: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Backend - fraud management

Detect duplicated card use not

enough

Device scoring - os version, patch

level, bootloader unlock, installed soft

Malware handling

Behavioral analysis

https://www.flickr.com/photos/widnr/6545526341/

Page 90: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Future?

Devices will be more resilient, TPM?

More widespread mobile payments

= more attention of fraudsters.

Hope for the best, but prepare -

and verify - for the worst!

„with great power comes

great responsibility”

http://www.techiestate.com/spiderman-android-game/

Page 91: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

http://www.wallpaperup.com/52270/Wolves_flock_sheep_shepherd_nature_field_sky_rocks_situation_humor_wolf_people_men_males_landscapes_sky_mountains.html

Page 92: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

See also:

How to steal mobile wallet? – Mobile contactless payments apps attack and defense

Page 93: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

Lunch time!

https://www.flickr.com/photos/34739556@N04/5361451866/

Page 94: Can’t Touch This: Cloning Any Android HCE Contactless Card · Can’t Touch This: Cloning Any Android HCE Contactless Card Sławomir Jasek slawomir.jasek@securing.pl ... 2017 –mobile

MORE THANSECURITYTESTING

Thank you! Questions?

[email protected] slawekja