-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
344 lines (307 loc) · 11.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Lightning talk: certificate pinning 101</title>
<link rel="stylesheet" href="reveal.js/css/reveal.css">
<link rel="stylesheet" href="reveal.js/css/theme/black.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="reveal.js/lib/css/zenburn.css">
<link rel="stylesheet" href="css/zenburn-nohighlight.css">
<!-- FontAwesome http://fontawesome.io/examples/ and http://fontawesome.io/icons/ -->
<link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.min.css">
<style>
.reveal h1,
.reveal h2 {
text-transform: none !important;
font-variant-caps: small-caps !important;
}
.reveal .column {
float: left;
width: 50%;
padding-left: 0;
padding-right: 0;
}
.reveal .small-column-left {
float: left;
width: 30%;
}
.reveal .big-column-right {
float: left;
width: 58%;
padding-left: 5% !important;
}
.reveal .big-column-left {
float: left;
width: 68%;
}
.reveal .small-column-right {
float: left;
width: 20%;
padding-left: 5% !important;
text-align: left;
}
.reveal .left {
text-align: left;
width: 90%;
}
.reveal .join-with-previous {
margin-top: -0.8em;
}
</style>
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'reveal.js/css/print/pdf.css' : 'reveal.js/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section style="font-size: 0.8em">
<h1>Certificate pinning 101</h1>
<h2>Lightning talk</h2>
<p>Xavier Rubio Jansana</p>
<p style="font-size: 0.8em">
<a href="https://twitter.com/teknik_tdr"><i class="fa fa-twitter" aria-hidden="true"></i> @teknik_tdr</a><br>
<a href="https://xrubio.com"><i class="fa fa-globe" aria-hidden="true"></i> https://xrubio.com</a><br>
<a href="https://github.com/xrubioj/"><i class="fa fa-github" aria-hidden="true"></i> https://github.com/xrubioj/</a>
</p>
</section>
<section>
<h1>Summary</h1>
<ul>
<li>What?</li>
<li>Why?</li>
<li>How SSL/TLS works</li>
<li>MiTM Attacks</li>
<li>Certificate pinning 101</li>
<li>Security considerations</li>
</ul>
</section>
<section>
<h1>What?</h1>
<p class="fragment">Network security technique</p>
</section>
<section data-background="#aa1111">
<h1>Why?</h1>
<p class="fragment">Avoid MiTM attacks 😱</p>
</section>
<section>
<h2>Implications</h2>
<ul>
<li class="fragment">Stealing app secrets</li>
<li class="fragment">Stealing user secrets</li>
<li class="fragment">Subverting communication<br>
(e.g. change delivery address)</li>
</ul>
</section>
<section>
<h1>How SSL/TLS works</h1>
</section>
<section data-background-video="img/magic-giphy.mp4">
</section>
<section>
<h2>HTTPS Connection</h2>
</section>
<section>
<h2>Certificate</h2>
<img src="img/certificate-example.png" class="fragment">
</section>
<section>
<h2>Certificate</h2>
<img src="img/certificate-example-detail.png" class="fragment" style="width: 50%">
</section>
<section>
<h2>Certificate vs Signature</h2>
<p class="fragment">Subject Public Key Info</p>
</section>
<section>
<h2>Certificate name validation</h2>
</section>
<section>
<h2>Certificate chain validation</h2>
<img src="img/certificate-chain.png" class="fragment">
</section>
<section>
<h2>Root CAs</h2>
<div class="column">
<img src="img/root-cas.png" class="fragment" style="width: 60%">
</div>
<div class="column">
<ul>
<li class="fragment">Settings → Security → Trusted certificates</li>
<li class="fragment">System vs User</li>
</ul>
</div>
</section>
<section>
<h1>MiTM Attacks</h1>
<ul>
<li class="fragment">Root CA injection 😈</li>
<li class="fragment">CA insuficient validation → rogue certificate 😐</li>
<li class="fragment">Self-signed certificates → validation disabled 🚨😅</li>
</ul>
</section>
<section>
<h1>Certificate pinning 101</h1>
</section>
<section>
<h2>OkHttp</h2>
<pre><code class="kotlin" data-trim data-noescape style="font-size: 0.82em">
val hostname = "*.google.com"
val certificatePinner = CertificatePinner.Builder()
.add(hostname, "sha256/<mark class="fragment" style="position: absolute">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</mark>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")
.build()
val client = OkHttpClient.Builder()
.certificatePinner(certificatePinner)
.build()
</code></pre>
<div class="fragment">
<small>Exception:</small>
<pre class="join-with-previous" style="font-size: 0.40em; width: inherit">
javax.net.ssl.SSLPeerUnverifiedException: Certificate pinning failure!
Peer certificate chain:
sha256/<mark class="fragment" style="position: absolute">afwiKY3RxoMmLkuRW1l7QsPZTJPwDS2pdDROQjXw8ig=</mark>afwiKY3RxoMmLkuRW1l7QsPZTJPwDS2pdDROQjXw8ig=: CN=publicobject.com, OU=PositiveSSL
sha256/klO23nT2ehFDXCfx3eHTDRESMz3asj1muO+4aIdjiuY=: CN=COMODO RSA Secure Server CA
sha256/grX4Ta9HpZx6tSHkmCrvpApTQGo67CYDnvprLg5yRME=: CN=COMODO RSA Certification Authority
sha256/lCppFqbkrlJ3EcVFAkeip0+44VaoJUymbnOaEUk7tEU=: CN=AddTrust External CA Root
Pinned certificates for publicobject.com:
sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
at okhttp3.CertificatePinner.check(CertificatePinner.java)
at okhttp3.Connection.upgradeToTls(Connection.java)
at okhttp3.Connection.connect(Connection.java)
at okhttp3.Connection.connectAndSetOwner(Connection.java)</pre>
</div>
<aside class="notes">
<ul>
<li>Different pins are <b>alternatives</b></li>
</ul>
</aside>
</section>
<section>
<h2>Android N</h2>
<pre><code class="xml" data-trim data-noescape style="font-size: 0.72em">
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config>
<domain includeSubdomains="true">appmattus.com</domain>
<pin-set>
<pin digest="SHA-256">4hw5tz+scE+TW+mlai5YipDfFWn1dqvfLG+nU7tq1V8=</pin>
<pin digest="SHA-256">YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=</pin>
</pin-set>
</domain-config>
</network-security-config>
</code></pre>
<div class="fragment">
<small>AndroidManifest.xml:</small>
<pre class="join-with-previous"><code class="xml" data-trim data-noescape style="font-size: 0.82em">
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<application
<mark class="fragment" style="position: absolute;">android:networkSecurityConfig="@xml/network_security_config"</mark>android:networkSecurityConfig="@xml/network_security_config">
<!-- ... -->
</application>
</manifest>
</code></pre>
</div>
<aside class="notes">
<ul>
<li>Enforce disallowing cleartext communication</li>
<li>Enforce using only System certificates</li>
<li>Different pins are <b>alternatives</b></li>
</ul>
</aside>
</section>
<section>
<h2>Backport</h2>
<p>CWAC-NetSecurity
<a src="https://github.com/commonsguy/cwac-netsecurity">https://github.com/commonsguy/cwac-netsecurity</a></p>
<blockquote>"Allows the same XML configuration to be used, going back to API Level 17 (Android 4.2)"</blockquote>
<p class="fragment">With some manual work... 🤷♂️</p>
</section>
<section>
<h2>How to react</h2>
<ul>
<li class="fragment">Hard failure</li>
<li class="fragment">Soft failure</li>
</ul>
</section>
<section>
<h2>Strategies</h2>
<ul>
<li class="fragment">Hardcoded pins</li>
<li class="fragment">Accept on first access</li>
<li class="fragment">Get pins from server<span class="fragment"> → inception! 🙃</span></li>
</ul>
</section>
<section>
<h1>Security considerations</h1>
<p class="fragment">⚠️ Hide your secrets!</p>
<p class="fragment">See "Android security basics" talk by Krzysztof Kocel
<a src="https://www.meetup.com/Barcelona-Android-Developer-Group/events/244107028/">https://www.meetup.com/Barcelona-Android-Developer-Group/events/244107028/</a></p>
</section>
<section>
<h1>References</h1>
<ul style="font-size: 0.8em">
<li>
"Android Security: SSL Pinning" by Matthew Dolan
<a href="https://medium.com/@appmattus/android-security-ssl-pinning-1db8acb6621e">
https://medium.com/@appmattus/android-security-ssl-pinning-1db8acb6621e</a>
</li>
<li>
Network Security Configuration
<a href="https://developer.android.com/training/articles/security-config.html">
https://developer.android.com/training/articles/security-config.html</a>
</li>
<li>
"CWAC-NetSecurity: Simplifying Secure Internet Access" by CommonsWare
<a href="https://github.com/commonsguy/cwac-netsecurity">
https://github.com/commonsguy/cwac-netsecurity</a>
</li>
<li>
CertificatePinner class OkHttp documentation
<a href="https://square.github.io/okhttp/3.x/okhttp/okhttp3/CertificatePinner.html">
https://square.github.io/okhttp/3.x/okhttp/okhttp3/CertificatePinner.html</a>
</li>
</ul>
</section>
<section>
<h1>Questions? 🤔</h1>
</section>
<section>
<h1>Thanks! 🎉</h1>
<p>Xavier Rubio Jansana</p>
<p style="font-size: 0.8em">
<a href="https://twitter.com/teknik_tdr"><i class="fa fa-twitter" aria-hidden="true"></i> @teknik_tdr</a><br>
<a href="https://xrubio.com"><i class="fa fa-globe" aria-hidden="true"></i> https://xrubio.com</a><br>
<a href="https://github.com/xrubioj/"><i class="fa fa-github" aria-hidden="true"></i> https://github.com/xrubioj/</a>
</p>
<p style="line-height: 0.6em"><small>This talk is available at:</small><br>
<a href="https://xrubio.com/talks/talk-lightning-certificate-pinning/" style="font-size: 0.6em">
https://xrubio.com/talks/talk-lightning-certificate-pinning/</a>
</p>
</section>
</div>
</div>
<script src="reveal.js/lib/js/head.min.js"></script>
<script src="reveal.js/js/reveal.js"></script>
<script>
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
history: true,
// More info https://github.com/hakimel/reveal.js#dependencies
dependencies: [
{ src: 'reveal.js/plugin/markdown/marked.js' },
{ src: 'reveal.js/plugin/markdown/markdown.js' },
{ src: 'reveal.js/plugin/notes/notes.js', async: true },
{ src: 'reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>