Slide 1

Slide 1 text

Data transfer security for mobile apps what the fish doesn’t notice in the ocean? #mddaylviv2015 @vixentael

Slide 2

Slide 2 text

There ain’t enough talks about security

Slide 3

Slide 3 text

Apple Security Guide Every program is a potential target. Your customers’ property and your reputation are at stake. https://developer.apple.com/library/mac/documentation/Security/ Conceptual/SecureCodingGuide/Introduction.html data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 4

Slide 4 text

3 kinds of data to protect Data in storage Data in memory Data in motion data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 5

Slide 5 text

Data in motion: what could possibly go wrong

Slide 6

Slide 6 text

Communication with server. Usually. data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 7

Slide 7 text

Imagine little fish... data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 8

Slide 8 text

...in the ocean of threats

Slide 9

Slide 9 text

active eavesdropping data leakage evil twin replay attack ...in the ocean of threats

Slide 10

Slide 10 text

* SSL experimenting with Android Top100 apps http://bit.ly/1NqpheM * Intercepting the App Store's Traffic on iOS http://bit.ly/1H3xMrs One proxy to rule ‘em all!

Slide 11

Slide 11 text

Attack reasons Many apps use HTTP* data transfer security for mobile apps #mddaylviv2015 @vixentael *iOS9 ATS will decrease this number

Slide 12

Slide 12 text

Attack reasons Many apps use HTTP* Some apps use HTTPS data transfer security for mobile apps #mddaylviv2015 @vixentael *iOS9 ATS will decrease this number

Slide 13

Slide 13 text

Attack reasons Many apps use HTTP* Some apps use HTTPS Few apps encrypt user’s data *iOS9 ATS will decrease this number data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 14

Slide 14 text

Why is this happening?

Slide 15

Slide 15 text

1. Security is hard. STACKOVERFLOW!

Slide 16

Slide 16 text

Let’s StackOverflow! http://stackoverflow.com/a/21826729 data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 17

Slide 17 text

Weird padding http://stackoverflow.com/a/21826729 data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 18

Slide 18 text

2. Software is buggy

Slide 19

Slide 19 text

Remove padding! http://stackoverflow.com/a/26147479 data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 20

Slide 20 text

Omg WTF is going on WTF http://stackoverflow.com/a/26147479 WTF WTF data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 21

Slide 21 text

3. Illusion of safety is still a illusion data transfer security for mobile apps #mddaylviv2015 @vixentael #define kUserPassword @“1111111”

Slide 22

Slide 22 text

Armoring your fish

Slide 23

Slide 23 text

Realize security risks data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 24

Slide 24 text

Amateurs Produce Amateur Cryptography Anyone can invent a security system that he himself cannot break — Schneier's Law https://www.schneier.com/blog/archives/ 2011/04/schneiers_law.html data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 25

Slide 25 text

Do not re-implement existing things data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 26

Slide 26 text

Security is a system, not a pluggable library

Slide 27

Slide 27 text

Build stout architecture data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 28

Slide 28 text

Build stout architecture cryptolib key management data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 29

Slide 29 text

Use great tools Themis https://github.com/cossacklabs/themis RNCryptor https://github.com/RNCryptor/RNCryptor MIHCrypto https://github.com/hohl/MIHCrypto OTRKit https://github.com/ChatSecure/OTRKit libsodium/NaCL https://github.com/mochtu/libsodium-ios scientific background trust big guys good track record data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Use SSL? Do it right! https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet ✤use long keys ✤remove backward compatibility ✤use good ciphers (EC vs RSA) ✤SSL pinning ✤use cheat sheet https://www.cossacklabs.com/avoid-ssl-for-your-next-app.html SSL has a lot of problems To survive you need to: data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 32

Slide 32 text

TLS/SSL in short data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 33

Slide 33 text

Where can it break? data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 34

Slide 34 text

SSL pinning data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 35

Slide 35 text

SSL pinning on iOS https://possiblemobile.com/2013/03/ssl-pinning-for-increased-app-security/ https://www.paypal-engineering.com/2015/10/14/key-pinning-in-mobile- applications/ - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge { SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; id sender = challenge.sender; SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, 0); NSData * remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); NSString * cerPath = [[NSBundle mainBundle] pathForResource:@"MyLocalCertificate" ofType:@"cer"]; NSData * localCertData = [NSData dataWithContentsOfFile:cerPath]; if ([remoteCertificateData isEqualToData:localCertData]) { NSURLCredential * credential = [NSURLCredential credentialForTrust:serverTrust]; [sender useCredential:credential forAuthenticationChallenge:challenge]; } else { [sender cancelAuthenticationChallenge:challenge]; } } data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 36

Slide 36 text

SSL pinning more easy :) Swift lib for HTTPS with SSL pinning https://github.com/johnlui/Pitaya/wiki let  certData  =  NSData(contentsOfFile:   NSBundle.mainBundle().pathForResource("lvwenhancom",  ofType:  "cer")!)!
 ...  ...
 .addSSLPinning(LocalCertData:  certData)  {  ()  -­‐>  Void  in
        print("Under  Man-­‐in-­‐the-­‐middle  attack!")
 } data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 37

Slide 37 text

How to achieve the solution

Slide 38

Slide 38 text

Let’s imagine chatting app simple API authentication meaningfull communication confidentiality thread data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 39

Slide 39 text

Securing app step by step 1. HTTPS everywhere 2. SSL pinning 3. Encrypt messages by persistent keys data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 40

Slide 40 text

Securing app step by step 1. HTTPS everywhere ----> SSL/TLS has lots of bugs and bad crypto 2. SSL pinning ----> is not a panacea 3. Encrypt messages by persistent keys ----> can be easily cracked data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

Securing in a more proper way perfect forward secrecy use good ciphers data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 43

Slide 43 text

Using ephemeral key data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 44

Slide 44 text

How to achieve it easily https://github.com/cossacklabs/themis 1. establish session 2. encrypt message with SecureSession before sending 3. decrypt message after receive 4. encrypt history with SecureCell data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 45

Slide 45 text

How to achieve it easily https://github.com/cossacklabs/mobile- websocket-example data transfer security for mobile apps #mddaylviv2015 @vixentael

Slide 46

Slide 46 text

Security is hard, but if you’re smart, security is not so hard :)

Slide 47

Slide 47 text

The last slide @vixentael iOS developer at stanfy.com [creating awesome mobile and IoT apps]

Slide 48

Slide 48 text

To read ★ CryptoCat iOS app security audit https://nabla-c0d3.github.io/documents/iSEC_Cryptocat_iOS.pdf ★ Why you should avoid SSL for your next application https://www.cossacklabs.com/avoid-ssl-for-your-next-app.html ★ OAuth1, OAuth2, OAuth...? http://homakov.blogspot.com/2013/03/oauth1-oauth2-oauth.html

Slide 49

Slide 49 text

To watch youtube ★ All tasks of Moxie Marlinspike https://www.youtube.com/watch?v=ibF36Yyeehw https://www.youtube.com/watch?v=8N4sb-SEpcg https://www.youtube.com/watch?v=tOMiAeRwpPA

Slide 50

Slide 50 text

To read more slides ★ Securing iOS apps https://speakerdeck.com/mbazaliy/securing-ios-applications ★ Users' data security in iOS applications https://speakerdeck.com/vixentael/users-data-security-in-ios-applications ★ Reversing 101 https://speakerdeck.com/0xc010d/reversing-101