99
No, thank you! MAN IN THE MIDDLE ? Daniel Schneller – CenterDevice GmbH

Man in the Middle? - No, thank you!

Embed Size (px)

Citation preview

Page 1: Man in the Middle? - No, thank you!

No,$thank$you!MAN$IN$THE$MIDDLE$?

Daniel$Schneller$–$CenterDevice$GmbH

Page 2: Man in the Middle? - No, thank you!

SSL$–$and$you’re$done™

Page 3: Man in the Middle? - No, thank you!

SSL$–$and$you’re$done™

Page 4: Man in the Middle? - No, thank you!

SSL$–$and$you’re$done™

…are$you?

Page 5: Man in the Middle? - No, thank you!

Mac$App$Store

Page 6: Man in the Middle? - No, thank you!

Mac$App$Store

Page 7: Man in the Middle? - No, thank you!

Mac$App$Store

Page 8: Man in the Middle? - No, thank you!

Outbank

Page 9: Man in the Middle? - No, thank you!

What$happened$to$SSL?

Page 10: Man in the Middle? - No, thank you!

SSL$–$Chain$of$Trust

Page 11: Man in the Middle? - No, thank you!

SSL$–$Chain$of$Trust

Root$CA$Cer)ficate

Page 12: Man in the Middle? - No, thank you!

SSL$–$Chain$of$Trust

Root$CA$Cer)ficate

$Intermediate$CA$Cer)ficate(s)issues

Page 13: Man in the Middle? - No, thank you!

SSL$–$Chain$of$Trust

Root$CA$Cer)ficate

$Intermediate$CA$Cer)ficate(s)

Leaf$Cer)ficate

issues

issues

Page 14: Man in the Middle? - No, thank you!

SSL$–$Chain$of$Trust

Page 15: Man in the Middle? - No, thank you!

SSL$–$Chain$of$Trust

Page 16: Man in the Middle? - No, thank you!

SSL$–$Chain$of$Trust

Page 17: Man in the Middle? - No, thank you!

SSL$–$Chain$of$Trust

Page 18: Man in the Middle? - No, thank you!

SSL$–$Chain$of$Trust

Page 19: Man in the Middle? - No, thank you!

SSL$–$Chain$of$Trust

Page 20: Man in the Middle? - No, thank you!

Just$how$many$Root$CAs$are$there?

Page 21: Man in the Middle? - No, thank you!

System$Roots

Page 22: Man in the Middle? - No, thank you!

System$Roots

Page 23: Man in the Middle? - No, thank you!

System$Roots

Windows$8:$~350Mozilla:$~160iOS$6:$~220

Page 24: Man in the Middle? - No, thank you!

Man$In$The$Middle?

Page 25: Man in the Middle? - No, thank you!

Man$In$The$Middle

[Corporate]$Proxy Client

Page 26: Man in the Middle? - No, thank you!

Man$In$The$Middle

[Corporate]$Proxy Client

Page 27: Man in the Middle? - No, thank you!

Man$In$The$Middle

[Corporate]$Proxy Client

Page 28: Man in the Middle? - No, thank you!

Man$In$The$Middle

Website [Corporate]$Proxy Client

Page 29: Man in the Middle? - No, thank you!

Man$In$The$Middle

Website [Corporate]$Proxy Client

Page 30: Man in the Middle? - No, thank you!

Man$In$The$Middle

Website [Corporate]$Proxy Client

Page 31: Man in the Middle? - No, thank you!

Man$In$The$Middle

Website [Corporate]$Proxy Client

Page 32: Man in the Middle? - No, thank you!

Man$In$The$Middle

Page 33: Man in the Middle? - No, thank you!

Man$In$The$Middle

Page 34: Man in the Middle? - No, thank you!

Man$In$The$Middle

Page 35: Man in the Middle? - No, thank you!

Man$In$The$Middle

Page 36: Man in the Middle? - No, thank you!

Man$In$The$Middle

Page 37: Man in the Middle? - No, thank you!

Man$In$The$Middle

Page 38: Man in the Middle? - No, thank you!

Consequences

•Monitoring

•ManipulaZon

• Sent$and$received$data$affected

• Chain\Of\Trust$formally$verified

Page 39: Man in the Middle? - No, thank you!

Good$and$evil

• Debugging

• Reverse$Engineering

• Security$Audits

• Learning$and$Understanding

Page 40: Man in the Middle? - No, thank you!

ReST$Debugging

Page 41: Man in the Middle? - No, thank you!

Good$and$evil

• Phishing

• IdenZty$The`

• Industrial$Espionage

• …

Page 42: Man in the Middle? - No, thank you!

Mac$App$Store

Page 43: Man in the Middle? - No, thank you!

Mac$App$Store

Page 44: Man in the Middle? - No, thank you!

Mac$App$Store

Page 45: Man in the Middle? - No, thank you!

iTunes

Page 46: Man in the Middle? - No, thank you!

iTunes

Page 47: Man in the Middle? - No, thank you!

iTunes

Page 48: Man in the Middle? - No, thank you!

Demo$1

Video$1

Video$2

Page 49: Man in the Middle? - No, thank you!

Countermeasures

Page 50: Man in the Middle? - No, thank you!

Reference$CerZficates

Page 51: Man in the Middle? - No, thank you!

Reference$CerZficates

• Client$bundles$server$cerZficate$as$a$reference

• Compare$reference$and$cerZficate$sent$by$the$server$

• Connect$only$when$there’s$a$perfect$match

Page 52: Man in the Middle? - No, thank you!

Reference$CerZficates

$Client$App$Server

Page 53: Man in the Middle? - No, thank you!

Reference$CerZficates

$Client$App$Server

==

Page 54: Man in the Middle? - No, thank you!

Reference$CerZficates

SecTrustResultType evaluationResult;OSStatus status = SecTrustEvaluate(srvTrust, &evaluationResult);

if (status == errSecSuccess) { if (evaluationResult == kSecTrustResultUnspecified) {

// ...

}}

• Step$1:$$Validate$Chain\of\Trust

Page 55: Man in the Middle? - No, thank you!

Reference$CerZficates

SecTrustResultType evaluationResult;OSStatus status = SecTrustEvaluate(srvTrust, &evaluationResult);

if (status == errSecSuccess) { if (evaluationResult == kSecTrustResultUnspecified) {

// ...

}}

• Step$1:$$Validate$Chain\of\Trust

Page 56: Man in the Middle? - No, thank you!

Reference$CerZficates

• Step$1:$$Validate$Chain\of\Trust

SecTrustResultType evaluationResult;OSStatus status = SecTrustEvaluate(srvTrust, &evaluationResult);

if (status == errSecSuccess) { if (evaluationResult == kSecTrustResultUnspecified) {

// ...

}}

Page 57: Man in the Middle? - No, thank you!

Reference$CerZficates

• Step$1:$$Validate$Chain\of\Trust

SecTrustResultType evaluationResult;OSStatus status = SecTrustEvaluate(srvTrust, &evaluationResult);

if (status == errSecSuccess) { if (evaluationResult == kSecTrustResultUnspecified) {

// ...

}}

Page 58: Man in the Middle? - No, thank you!

Reference$CerZficates

• Step$1:$$Validate$Chain\of\Trust

SecTrustResultType evaluationResult;OSStatus status = SecTrustEvaluate(srvTrust, &evaluationResult);

if (status == errSecSuccess) { if (evaluationResult == kSecTrustResultUnspecified) {

// ...

}}

Page 59: Man in the Middle? - No, thank you!

Reference$CerZficates

• Step$1:$$Validate$Chain\of\Trust

SecTrustResultType evaluationResult;OSStatus status = SecTrustEvaluate(srvTrust, &evaluationResult);

if (status == errSecSuccess) { if (evaluationResult == kSecTrustResultUnspecified) {

// ...

}}

Page 60: Man in the Middle? - No, thank you!

NSString *refPath = [[NSBundle mainBundle] pathForResource:@"reference" ofType:@"der"];

NSData *refCertData = [[NSData alloc] initWithContentsOfFile:refPath];

Reference$CerZficates

• Step$2:$Load$Reference$CerZficate

Page 61: Man in the Middle? - No, thank you!

NSString *refPath = [[NSBundle mainBundle] pathForResource:@"reference" ofType:@"der"];

NSData *refCertData = [[NSData alloc] initWithContentsOfFile:refPath];

Reference$CerZficates

• Step$2:$Load$Reference$CerZficate

Page 62: Man in the Middle? - No, thank you!

Reference$CerZficates

• Step$2:$Load$Reference$CerZficate

NSString *refPath = [[NSBundle mainBundle] pathForResource:@"reference" ofType:@"der"];

NSData *refCertData = [[NSData alloc] initWithContentsOfFile:refPath];

Page 63: Man in the Middle? - No, thank you!

Reference$CerZficates

BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); found = [refCertData isEqualToData:certData];}

• Step$3:$Compare$cerZficates

Page 64: Man in the Middle? - No, thank you!

Reference$CerZficates

BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); found = [refCertData isEqualToData:certData];}

• Step$3:$Compare$cerZficates

Page 65: Man in the Middle? - No, thank you!

Reference$CerZficates

• Step$3:$Compare$cerZficates

BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); found = [refCertData isEqualToData:certData];}

Page 66: Man in the Middle? - No, thank you!

Reference$CerZficates

• Step$3:$Compare$cerZficates

BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); found = [refCertData isEqualToData:certData];}

Page 67: Man in the Middle? - No, thank you!

Reference$CerZficates

• Step$3:$Compare$cerZficates

BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); found = [refCertData isEqualToData:certData];}

Page 68: Man in the Middle? - No, thank you!

Reference$CerZficates

• Step$3:$Compare$cerZficates

BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); found = [refCertData isEqualToData:certData];}

Page 69: Man in the Middle? - No, thank you!

Reference$CerZficates

• Step$3:$Compare$cerZficates

BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); found = [refCertData isEqualToData:certData];}

Page 70: Man in the Middle? - No, thank you!

Demo$2

Video

Page 71: Man in the Middle? - No, thank you!

FingerprinZng

Page 72: Man in the Middle? - No, thank you!

FingerprinZng

• Similar$to$Reference$CerZficate$approach

• Compares$CerZficate$Fingerprint$against$reference$value

• Server$CerZficate$not$needed$in$the$client

• Example:$$Apple$So`ware$Update

Page 73: Man in the Middle? - No, thank you!

FingerprinZng$

$Client$App$Server

1122 3344 55667788 9900 AABBCCDD EEFF 9988

7766

SHA-1 Hash

Page 74: Man in the Middle? - No, thank you!

FingerprinZng$

$Client$App$Server

1122 3344 55667788 9900 AABBCCDD EEFF 9988

7766

SHA-1 Hash

Page 75: Man in the Middle? - No, thank you!

FingerprinZng$

$Client$App$Server

==1122 3344 55667788 9900 AABBCCDD EEFF 9988

7766

SHA-1 Hash

1122 3344 55667788 9900 AABBCCDD EEFF 9988

7766

Page 76: Man in the Middle? - No, thank you!

FingerprinZng

• Schrie$1:$Chain\of\Trust$validieren

SecTrustResultType evaluationResult;OSStatus status = SecTrustEvaluate(srvTrust, &evaluationResult);

if (status == errSecSuccess) { if (evaluationResult == kSecTrustResultUnspecified) {

// ...

}}

Page 77: Man in the Middle? - No, thank you!

FingerprinZng

static NSString* const kReferenceFP = @"AC .... DC";BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); NSString* fingerprint = [self sha1:certData]; found = [kReferenceFP isEqualToString:fingerprint]}

• Schrie$2:$Fingerprint$berechnen

Page 78: Man in the Middle? - No, thank you!

FingerprinZng

static NSString* const kReferenceFP = @"AC .... DC";BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); NSString* fingerprint = [self sha1:certData]; found = [kReferenceFP isEqualToString:fingerprint]}

• Schrie$2:$Fingerprint$berechnen

Page 79: Man in the Middle? - No, thank you!

FingerprinZng

• Schrie$2:$Fingerprint$berechnen

static NSString* const kReferenceFP = @"AC .... DC";BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); NSString* fingerprint = [self sha1:certData]; found = [kReferenceFP isEqualToString:fingerprint]}

Page 80: Man in the Middle? - No, thank you!

FingerprinZng

• Schrie$2:$Fingerprint$berechnen

static NSString* const kReferenceFP = @"AC .... DC";BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); NSString* fingerprint = [self sha1:certData]; found = [kReferenceFP isEqualToString:fingerprint]}

Page 81: Man in the Middle? - No, thank you!

FingerprinZng

• Schrie$2:$Fingerprint$berechnen

static NSString* const kReferenceFP = @"AC .... DC";BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); NSString* fingerprint = [self sha1:certData]; found = [kReferenceFP isEqualToString:fingerprint]}

Page 82: Man in the Middle? - No, thank you!

FingerprinZng

• Schrie$2:$Fingerprint$berechnen

static NSString* const kReferenceFP = @"AC .... DC";BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); NSString* fingerprint = [self sha1:certData]; found = [kReferenceFP isEqualToString:fingerprint]}

Page 83: Man in the Middle? - No, thank you!

FingerprinZng

• Schrie$2:$Fingerprint$berechnen

static NSString* const kReferenceFP = @"AC .... DC";BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); NSString* fingerprint = [self sha1:certData]; found = [kReferenceFP isEqualToString:fingerprint]}

Page 84: Man in the Middle? - No, thank you!

FingerprinZng

• Schrie$2:$Fingerprint$berechnen

static NSString* const kReferenceFP = @"AC .... DC";BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); NSString* fingerprint = [self sha1:certData]; found = [kReferenceFP isEqualToString:fingerprint]}

Page 85: Man in the Middle? - No, thank you!

FingerprinZng

• Schrie$2:$Fingerprint$berechnen

static NSString* const kReferenceFP = @"AC .... DC";BOOL found = NO;CFIndex crtCount = SecTrustGetCertificateCount(srvTrust);

for (CFIndex j = 0; j < crtCount && !found; j++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(srvTrust, j); NSData* certData = CFBridgingRelease(SecCertificateCopyData(cert)); NSString* fingerprint = [self sha1:certData]; found = [kReferenceFP isEqualToString:fingerprint]}

Page 86: Man in the Middle? - No, thank you!

Demo$3

Video

Page 87: Man in the Middle? - No, thank you!

Caveats

Page 88: Man in the Middle? - No, thank you!

Caveats

• Change$of$CerZficate

• Expired

• Compromised

• Update$app$with$plenty$of$lead$Zme

• Temporarily$accept$old$and$new$cerZficates

Page 89: Man in the Middle? - No, thank you!

VariaZon

Page 90: Man in the Middle? - No, thank you!

VariaZon

• Check$Root\CerZficate$against$reference

• Trade\Off:$Flexibility$vs.$Security

• Updates$only$required$when$changing$Root\CA

Page 91: Man in the Middle? - No, thank you!

Conclusions

Page 92: Man in the Middle? - No, thank you!

Conclusions

• SSL$provides

• ConfidenZality$(encrypted)

• AuthenZcity

• CA$system$(usually)$suffiecient

•More$Security$=$More$Work

Page 93: Man in the Middle? - No, thank you!

Make$informed$decisions!

Page 94: Man in the Middle? - No, thank you!

Links

Sample,Code

•github.com/dschneller/mitm\no\thank\you

Tools

•github.com/ADVTOOLS/ADVcerZficator

•github.com/ADVTOOLS/ADVTrustStore

•www.apple.com/support/iphone/enterprise

•technet.microso`.com/en\us/library/cc754841.aspx

Page 95: Man in the Middle? - No, thank you!

LinksTLS,Session,Cache

•developer.apple.com/library/ios/#qa/qa1727

Root6CA,Lists

•support.apple.com/kb/HT5012

•www.mozilla.org/projects/security/certs/included/

•social.technet.microso`.com/wiki/contents/arZcles/14215.windows\and\windows\phone\8\ssl\root\cerZficate\program\member\cas.aspx

•Android:$Sepngs–Security–Trusted$CredenZals

Page 96: Man in the Middle? - No, thank you!

Thank$you!

Page 97: Man in the Middle? - No, thank you!

QuesZons$?

[email protected]

$$$$$@dschneller

Page 98: Man in the Middle? - No, thank you!

That’s$all.$Really.$:)

Page 99: Man in the Middle? - No, thank you!

Demo$1Standard$SSL,$MITM$Root\CA$not$installiert

zurück