-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamp2023-57100-eng-All_cops_are_broadcasting_opus.srt
1532 lines (1149 loc) · 50 KB
/
camp2023-57100-eng-All_cops_are_broadcasting_opus.srt
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1
00:00:00,000 --> 00:00:10,000
[MUSIC]
2
00:00:10,000 --> 00:00:20,000
[MUSIC]
3
00:00:20,000 --> 00:00:33,000
Welcome to the Millie Ray stage for our next talk.
4
00:00:33,000 --> 00:00:38,000
But first things first, I hope you all are well hydrated,
5
00:00:38,000 --> 00:00:42,000
are drinking enough water, and because of the windy conditions,
6
00:00:42,000 --> 00:00:48,000
have secured your tents safely so that they don't fly around and endanger people.
7
00:00:48,000 --> 00:00:53,000
I also would like to ask you if you took cups from the heaven kitchen,
8
00:00:53,000 --> 00:00:59,000
haven't returned them yet, to please return them so that the angels can drink their liquid fuel
9
00:00:59,000 --> 00:01:03,000
and can fly still fast and happily.
10
00:01:03,000 --> 00:01:07,000
Also, as we have a lot of guests here today, which is great,
11
00:01:07,000 --> 00:01:12,000
please keep the pathways here clear so that people can leave,
12
00:01:12,000 --> 00:01:19,000
and if people want to leave, please make way for them. Thank you very much.
13
00:01:19,000 --> 00:01:24,000
So I'm very pleased to announce the talk, All Cops are Broadcasting,
14
00:01:24,000 --> 00:01:31,000
Obtaining the Secret Tetra Primitives of After Decades in the Shadows.
15
00:01:31,000 --> 00:01:41,000
Here with me are Raute and Carlo. They are researchers who also founded a company called Midnight Blue,
16
00:01:41,000 --> 00:01:45,000
but they are going to tell you all this stuff way better themselves,
17
00:01:45,000 --> 00:01:48,000
so I'm going to fly away and give the word to you.
18
00:01:48,000 --> 00:01:51,000
And give applause please to our wonderful speakers.
19
00:01:51,000 --> 00:01:59,000
[APPLAUSE]
20
00:01:59,000 --> 00:02:02,000
Thank you. All right. Welcome everyone to our talk,
21
00:02:02,000 --> 00:02:07,000
All Cops are Broadcasting, Obtaining the Secret Tetra Primitives of After Decades in the Shadows.
22
00:02:07,000 --> 00:02:13,000
I'm very excited to finally present this to you all after two and a half years of silence on the matter.
23
00:02:13,000 --> 00:02:20,000
My name is Karde Meijer, and these are my colleagues Wouter Boxlag and unfortunately Jos Wetzels, who isn't here.
24
00:02:20,000 --> 00:02:25,000
Together we form Midnight Blue, a specialist security company firm from the Netherlands,
25
00:02:25,000 --> 00:02:32,000
and we focus on high-end security research, mainly in critical infrastructure and embedded systems.
26
00:02:32,000 --> 00:02:40,000
The three of us found vulnerabilities from everything from car immobilizers, the BlackBerry QNX operating systems,
27
00:02:40,000 --> 00:02:46,000
and MyFair Classic RFID cards. So what's Tetra?
28
00:02:46,000 --> 00:02:54,000
Tetra is a globally used radio technology that competes with the likes of P25, DMR, TetraPol.
29
00:02:54,000 --> 00:03:00,000
It was standardized in 1995 by the European standards organization ETSI,
30
00:03:00,000 --> 00:03:06,000
who is known for GSM, 3G, 4G, and 5.3, DMR, and the likes.
31
00:03:06,000 --> 00:03:15,000
And Tetra is used for conventional voice communication in handheld radios, but also data communication, including machine-to-machine.
32
00:03:15,000 --> 00:03:21,000
And the interesting thing is that it relies on secret proprietary cryptography.
33
00:03:21,000 --> 00:03:30,000
So Tetra is one of the most popular radio technologies used by police all around the world, with the exception of the US and France.
34
00:03:30,000 --> 00:03:38,000
It is used by national or regional police forces in countries like the UK, Germany, Scandinavia, and Eastern Europe,
35
00:03:38,000 --> 00:03:41,000
but also in large parts of South America and Asia.
36
00:03:41,000 --> 00:03:48,000
Now be aware that these maps we're showing are just the users we could confirm through open source intelligence.
37
00:03:48,000 --> 00:03:51,000
There may be more out there.
38
00:03:51,000 --> 00:04:01,000
Not only the police uses Tetra, it is also used by the military and intelligence agencies across the world in different capacities.
39
00:04:01,000 --> 00:04:11,000
And on top of that, it's also used by widely critical infrastructure, private security personnel at airports, harbors, and train stations.
40
00:04:11,000 --> 00:04:20,000
They use it for voice communication, but it's also deployed as a radio link in wide area SCADA networks to carry telecontrol traffic
41
00:04:20,000 --> 00:04:26,000
for electrical substations, oil, gas pipelines, or railway signaling.
42
00:04:26,000 --> 00:04:31,000
So while Tetra is a public standard, its cryptography is kept secret.
43
00:04:31,000 --> 00:04:37,000
In the figure on the right, you can see how they describe a lot of high-level schemes,
44
00:04:37,000 --> 00:04:46,000
but then the primitives within those schemes are essentially black boxes whose specifications are only available under NDA,
45
00:04:46,000 --> 00:04:54,000
which means you cannot publish the details of any findings if you're a researcher.
46
00:04:54,000 --> 00:04:59,000
Manufacturers are also required to protect algorithms against extraction.
47
00:04:59,000 --> 00:05:09,000
This kind of security theater, however, since any top-tier adversary will already have these specifications through either their own manufacturer,
48
00:05:09,000 --> 00:05:17,000
so for example, any major country in the world has a Tector manufacturer on their soil, for example, the US, the UK, China, Russia,
49
00:05:17,000 --> 00:05:22,000
or they'll simply snatch them off a SharePoint from a small manufacturer.
50
00:05:22,000 --> 00:05:33,000
Meanwhile, scientific researchers or the security community has to jump through significant hoops in order to get a look at these primitives, like we had to.
51
00:05:33,000 --> 00:05:40,000
Now, Tetra security mainly consists of two components, both of which are secret.
52
00:05:40,000 --> 00:05:49,000
This is the TAA-1 suite, which is used for authentication, key management, identity encryption, and remote terminal disabling.
53
00:05:49,000 --> 00:05:55,000
And then there's the TAA suite, which is used for voice and data encryption over the air.
54
00:05:55,000 --> 00:06:03,000
The TAA suite consists of four algorithms divided by use case, so TAA-1 and 4 being readily exportable.
55
00:06:03,000 --> 00:06:10,000
TAA-2 is only intended for European police forces as emergency services and military,
56
00:06:10,000 --> 00:06:19,000
and TAA-3 is intended for public safety outside of European countries, but with friendly relationship with the EU.
57
00:06:19,000 --> 00:06:25,000
So this means typically India, Mexico, China, those kind of countries.
58
00:06:25,000 --> 00:06:31,000
So with this in mind, let's talk about project reTetra that we undertook.
59
00:06:31,000 --> 00:06:35,000
We know all about Kirchhoff's principle, right?
60
00:06:35,000 --> 00:06:46,000
A crypto system should be secure even if everything about the system is known except for the key.
61
00:06:46,000 --> 00:06:50,000
So basically no security through obscurity.
62
00:06:50,000 --> 00:06:54,000
Violating this principle doesn't usually end well.
63
00:06:54,000 --> 00:07:03,000
There's plenty of examples of secret proprietary cryptography in GSM, GMR, GPRS, DECT, various RFID systems.
64
00:07:03,000 --> 00:07:08,000
And all of them turned out to be flawed or intentionally backdoored.
65
00:07:08,000 --> 00:07:12,000
So why would Tetra be different?
66
00:07:12,000 --> 00:07:15,000
Now Etsy has a different opinion on this.
67
00:07:15,000 --> 00:07:24,000
In an interview with Kim Zetter, the Etsy Tetra chairman explicitly said that they consider obscurity as also a way of maintaining security.
68
00:07:24,000 --> 00:07:26,000
Right.
69
00:07:26,000 --> 00:07:30,000
So we obviously disagree with such an approach.
70
00:07:30,000 --> 00:07:37,000
So we went to the NLNet Foundation for a research proposal.
71
00:07:37,000 --> 00:07:42,000
And they decided to fund us to open up Tetra for public review.
72
00:07:42,000 --> 00:07:50,000
NLNet is a non-profit organization which funds open source projects and research like this with the goal of promoting open standards.
73
00:07:50,000 --> 00:07:57,000
So if you have something that you would like to investigate which costs a significant amount of time, I would highly recommend approaching them.
74
00:07:57,000 --> 00:08:00,000
So let's break open a radio.
75
00:08:00,000 --> 00:08:05,000
So we had to start out by picking the right kind of radio.
76
00:08:05,000 --> 00:08:08,000
There's lots of vendor, models, architectures involved.
77
00:08:08,000 --> 00:08:12,000
And picking the wrong one can make you waste a ton of time.
78
00:08:12,000 --> 00:08:21,000
So we spent quite some time poring over manuals, data sheets in order to get an idea of the different architectures involved.
79
00:08:21,000 --> 00:08:25,000
And what kind of basements were actually used by which vendors.
80
00:08:25,000 --> 00:08:28,000
And what architectures they were based on.
81
00:08:28,000 --> 00:08:34,000
And if there were any ASICs or FPGAs that likely implemented the algorithms and so on and so forth.
82
00:08:34,000 --> 00:08:43,000
So thus we ended up with the Freon baseband from Motorola which is based on a TI OMAP 1L38 SoC.
83
00:08:43,000 --> 00:08:47,000
This thing is also used in DMR and P25 radios.
84
00:08:47,000 --> 00:08:53,000
So therefore it's highly unlikely that the algorithms are implemented in hardware.
85
00:08:53,000 --> 00:09:01,000
And also interestingly this baseband has a trusted execution environment so that immediately caught our attention.
86
00:09:01,000 --> 00:09:05,000
So it's highly suitable for implementing the algorithm software.
87
00:09:05,000 --> 00:09:10,000
So this baseband is used in Motorola MTM5400.
88
00:09:10,000 --> 00:09:14,000
That's a common radio model that you can buy for relatively cheap online.
89
00:09:14,000 --> 00:09:17,000
The baseband SoC is just a common TI chip.
90
00:09:17,000 --> 00:09:22,000
So it's unlikely that it has the tetra-kypto in hardware.
91
00:09:22,000 --> 00:09:32,000
And it has some software security features which we suspect make it a great candidate for protecting crypto from extraction.
92
00:09:32,000 --> 00:09:37,000
The high level architecture of the radio looks like this.
93
00:09:37,000 --> 00:09:43,000
As you can see on the right of the slide there's a control head which controls the microphone, the keyboard and so on.
94
00:09:43,000 --> 00:09:48,000
There's a rear connector for the depot programming of the radio.
95
00:09:48,000 --> 00:09:52,000
And inside there's a baseband chip which consists of two cores.
96
00:09:52,000 --> 00:09:57,000
There's an ARM core and that's for high level stuff.
97
00:09:57,000 --> 00:10:02,000
And there's a digital signal processor. That's for processing signals.
98
00:10:02,000 --> 00:10:09,000
And the DSP core has a trusted execution environment which is where the MAD-X SoC probably is.
99
00:10:09,000 --> 00:10:14,000
So the MTM firmware format is shipped in an RPK package.
100
00:10:14,000 --> 00:10:21,000
Turns out that this is just a zip archive with a bunch of Z19 files encrypted in it.
101
00:10:21,000 --> 00:10:30,000
But since the firmware files are not personalized for an individual radio, there has to be a general way to load them.
102
00:10:30,000 --> 00:10:34,000
And the programming software decrypts those files in the zip archive.
103
00:10:34,000 --> 00:10:37,000
The zip archive is password protected.
104
00:10:37,000 --> 00:10:44,000
So it gets the files out of them and then uses it to program the radio.
105
00:10:44,000 --> 00:10:49,000
So after some light .NET reverse engineering we found static passwords for these files.
106
00:10:49,000 --> 00:10:52,000
So this is an easy hurdle to take.
107
00:10:52,000 --> 00:10:56,000
So now we can extract the Z90 files and decrypt them with the password.
108
00:10:56,000 --> 00:11:01,000
Extract the S19 files which is a Motorola S-record file.
109
00:11:01,000 --> 00:11:11,000
Then parse them, identify firmware components within it like the kernel or file system or a baseband firmware image.
110
00:11:11,000 --> 00:11:13,000
And so on and so forth.
111
00:11:13,000 --> 00:11:18,000
And once we have that, let's look at the DSP firmware and see what's in there.
112
00:11:18,000 --> 00:11:23,000
Because we don't have tooling yet in order to properly reverse engineer it.
113
00:11:23,000 --> 00:11:28,000
We'll just have a very high level overview of it as of now.
114
00:11:28,000 --> 00:11:36,000
And well, if we look at entropy analysis, the entropy distribution of the DSP firmware,
115
00:11:36,000 --> 00:11:40,000
there's a single area with extremely high entropy.
116
00:11:40,000 --> 00:11:46,000
And it's referenced by a bunch of system calls that's related to the trusted execution of our API.
117
00:11:46,000 --> 00:11:50,000
So this is highly likely containing the secret sauce.
118
00:11:50,000 --> 00:11:54,000
So let's dive deeper.
119
00:11:54,000 --> 00:11:59,000
So now that we have a good idea of where to go, how do we break the trusted execution environment?
120
00:11:59,000 --> 00:12:03,000
Well, we first have to get code execution on the application processor.
121
00:12:03,000 --> 00:12:06,000
So that's the ARM core.
122
00:12:06,000 --> 00:12:09,000
So by the way, this thing has secure boot.
123
00:12:09,000 --> 00:12:14,000
So we cannot just go in and modify the memory chips.
124
00:12:14,000 --> 00:12:18,000
So this goes through three possibilities.
125
00:12:18,000 --> 00:12:25,000
The first one, the rear connector on the back has a modem 80 command interface.
126
00:12:25,000 --> 00:12:34,000
The other possibility was to modify the memory chips and see if we could find some memory corruption exploit through that.
127
00:12:34,000 --> 00:12:38,000
Or through some peripheral interface, for example, this thing talks to a GPS module.
128
00:12:38,000 --> 00:12:44,000
So maybe it's interesting to maybe those links are trusted and maybe we could get code execution through them.
129
00:12:44,000 --> 00:12:49,000
After that, we'd have to hop onto the DSP to get code execution there.
130
00:12:49,000 --> 00:12:54,000
This might be possible through direct memory access or the DSP link libraries,
131
00:12:54,000 --> 00:12:59,000
the library that passes messages back and forth between the ARM core and the DSP.
132
00:12:59,000 --> 00:13:05,000
And finally, we had to find a vulnerability or side channel in the TEE itself.
133
00:13:05,000 --> 00:13:08,000
So let's begin our journey.
134
00:13:08,000 --> 00:13:12,000
This is basically the last slide, but then a bit prettier.
135
00:13:12,000 --> 00:13:18,000
All right. So the MTM has a rear connector that exposes the 80 modem command interface.
136
00:13:18,000 --> 00:13:22,000
Here you can read and write parameters, for example.
137
00:13:22,000 --> 00:13:25,000
And analyzing the firmware gave us a list of commands.
138
00:13:25,000 --> 00:13:34,000
And we immediately started looking for commands that handle strings with variable lengths or some parsing involved.
139
00:13:34,000 --> 00:13:41,000
And there's this command that is used to set a talk group list entry and another one that enumerates them.
140
00:13:41,000 --> 00:13:51,000
And we found that there's a classic format string vulnerability in there that allows you to write any data in some address that is already on the stack.
141
00:13:51,000 --> 00:13:58,000
So you can basically interpret a value on the stack as a pointer and you can write to that address.
142
00:13:58,000 --> 00:14:04,000
Now, if we control a value on the stack, that would mean we could write anything anywhere.
143
00:14:04,000 --> 00:14:07,000
Unfortunately, we don't.
144
00:14:07,000 --> 00:14:11,000
So luckily there's frame pointers in this firmware.
145
00:14:11,000 --> 00:14:16,000
So frame pointers have the nice property that one frame pointer points to the next.
146
00:14:16,000 --> 00:14:24,000
And due to the circumstances that we have here, we can only write a single byte to an address that is on the stack.
147
00:14:24,000 --> 00:14:30,000
So what we do is we have three frame pointers here, one points to the other, which points to the next.
148
00:14:30,000 --> 00:14:42,000
So the first one, we write a single byte to the next and therefore we can change the least significant byte of that address where that pointer points to.
149
00:14:42,000 --> 00:14:49,000
So therefore we can use it as a cursor to write over the next address and therefore we control the full address.
150
00:14:49,000 --> 00:14:53,000
So now we have a write anything anywhere primitive.
151
00:14:53,000 --> 00:15:03,000
So now that we have that, we can use the fact that the read somehow has read write execute permissions.
152
00:15:03,000 --> 00:15:13,000
So we can just straightforwardly write the shellcode onto the heap, then overwrite some pointer to executable code, trigger that pointer execution and boom, we have a shellcode.
153
00:15:13,000 --> 00:15:16,000
We have a root shell on the ARM core.
154
00:15:16,000 --> 00:15:25,000
Right.
155
00:15:25,000 --> 00:15:26,000
Thank you.
156
00:15:26,000 --> 00:15:27,000
All right.
157
00:15:27,000 --> 00:15:30,000
The next step would be to move on to the DSP.
158
00:15:30,000 --> 00:15:44,000
So to recap, that would be exploiting vulnerability in DSP link, the message passing framework, or exploit some flaw and misconfiguration in the firewalls, let's say, between the ARM core and the DSP.
159
00:15:44,000 --> 00:15:48,000
So the two cores within the baseband need to communicate.
160
00:15:48,000 --> 00:15:54,000
They do this by having shared internal RAM and some external DDR memory.
161
00:15:54,000 --> 00:15:59,000
And this could present an interesting avenue for lateral movement towards the DSP.
162
00:15:59,000 --> 00:16:08,000
So the SOC in question has memory protection features, which allow for the segmentation of memory errors between cores and within cores.
163
00:16:08,000 --> 00:16:29,000
So the plan would be to dump the MPU configuration, then find ranges used by both the DSP and the application processor, and then identify and exploit an interface that uses these memory ranges, such as DSP link, that is used to have these cores talk to each other.
164
00:16:29,000 --> 00:16:36,000
However, when we dumped the configuration, we saw that essentially no segmentation was applied whatsoever.
165
00:16:36,000 --> 00:16:41,000
So these MPUs posed zero problems and made our life a lot easier.
166
00:16:41,000 --> 00:16:56,000
So this basically means that getting code execution on DSP is straightforward as like loading a kernel module, asking for a buffer that maps to this physical address that's supposed to be DSP memory, and just override parts of the DSP firmware.
167
00:16:56,000 --> 00:16:59,000
Microphone.
168
00:16:59,000 --> 00:17:04,000
Are we okay? Yeah, okay.
169
00:17:04,000 --> 00:17:10,000
So now that we have code execution on DSP, we implemented a framework for running code on it.
170
00:17:10,000 --> 00:17:23,000
We wrote multiple application processor kernel modules, which hijacked DSP control by allocating a shared buffer, copying our payload into it, and then redirect the DSP execution to that.
171
00:17:23,000 --> 00:17:32,000
And meanwhile, we made sure that there's this hardware peripheral called a watchdog, and it needs to be satisfied every now and then, otherwise it spontaneously reboots the board.
172
00:17:32,000 --> 00:17:36,000
So we got that on the control as well.
173
00:17:36,000 --> 00:17:42,000
All of this was kind of complicated by the fact that the DSP architecture is pretty hellish.
174
00:17:42,000 --> 00:17:50,000
It has delayed branches, very old degrees of concurrency, lots of conditionals, and no support for IDA.
175
00:17:50,000 --> 00:17:58,000
So we had to implement our own disassembler, and on top of that, we also ported the architecture to the RedDeck decompiler.
176
00:17:58,000 --> 00:18:03,000
So this is the disassembly output, and this is the decompiler output.
177
00:18:03,000 --> 00:18:08,000
So you can read, as you can see, this reads a lot easier than the disassembly.
178
00:18:08,000 --> 00:18:14,000
Good. All right. And with that, we had reliable DSP code execution.
179
00:18:14,000 --> 00:18:27,000
Thanks. So that brings us to the last part of this reverse engineering process.
180
00:18:27,000 --> 00:18:31,000
We now have to somehow break the DSP trusted execution environment.
181
00:18:31,000 --> 00:18:36,000
And in order to explain that to you, let's first dive into how this thing actually works.
182
00:18:36,000 --> 00:18:40,000
So the chip is a Texas Instruments chip with ROM code in it.
183
00:18:40,000 --> 00:18:44,000
And in this ROM code is embedded what they call a secure kernel.
184
00:18:44,000 --> 00:18:52,000
And this is like a lightweight library or operating system kind of thing that runs in a secure mode.
185
00:18:52,000 --> 00:18:59,000
So most code running on the DSP runs in insecure mode and can use the secure kernel, but cannot see it,
186
00:18:59,000 --> 00:19:07,000
and cannot interfere with anything that happens within this trusted execution environment or other secure context stuff.
187
00:19:07,000 --> 00:19:13,000
So what non-secure code can do is use functions like skload.
188
00:19:13,000 --> 00:19:20,000
And skload is a secure kernel call that allows for the runtime loading of an encrypted module.
189
00:19:20,000 --> 00:19:23,000
And this module is then copied to the secure context.
190
00:19:23,000 --> 00:19:28,000
It is decrypted using a factory set key, the customer encryption key.
191
00:19:28,000 --> 00:19:31,000
It is then validated using RSA.
192
00:19:31,000 --> 00:19:35,000
And if everything checks out, it remains present within this protected context.
193
00:19:35,000 --> 00:19:41,000
And it can be used by non-secure code through the use of the sklgo_invoke function.
194
00:19:41,000 --> 00:19:45,000
So it can then use the algorithms, but it cannot see them.
195
00:19:48,000 --> 00:19:55,000
So let's dive into cache architecture because we're going to use this in our attack.
196
00:19:55,000 --> 00:20:00,000
The OMAP L138 uses a two-tier cache architecture.
197
00:20:00,000 --> 00:20:04,000
It has a level one program and data cache, and it has a level two cache.
198
00:20:04,000 --> 00:20:13,000
And if the CPU performs a memory lookup, it will first check whether the data it wants to retrieve is already present in one of these caches.
199
00:20:13,000 --> 00:20:17,000
And if so, the read request is serviced very quickly.
200
00:20:17,000 --> 00:20:27,000
If not, it has to take a detour, or actually the full route, all the way to the memory chip, DDR2 chip, which takes significantly longer.
201
00:20:27,000 --> 00:20:35,000
Now, as we are running non-secure supervisor level code, we can manipulate some of the cache mechanics.
202
00:20:35,000 --> 00:20:39,000
What we can do is evict lines from the cache.
203
00:20:39,000 --> 00:20:45,000
So we can say, OK, this address, if it is in cache, I would like to throw it out of the cache.
204
00:20:45,000 --> 00:20:48,000
What we also can do is freeze the cache.
205
00:20:48,000 --> 00:20:56,000
This is a peculiar function that I haven't seen before in other chips, but it allows you to switch the entire cache to a read-only mode.
206
00:20:56,000 --> 00:21:03,000
So it will be used to accelerate the lookup if something is present, but the cache will not be updated.
207
00:21:03,000 --> 00:21:07,000
Now, we can use this.
208
00:21:07,000 --> 00:21:13,000
Some of you may be familiar with the structure of AES, but if you don't, the first few steps are listed here.
209
00:21:13,000 --> 00:21:19,000
I wonder who is able to read it, but the slides will be online, or some of them are already online.
210
00:21:19,000 --> 00:21:22,000
So you can always look back if you need to.
211
00:21:22,000 --> 00:21:30,000
In any case, the first thing that happens during a decryption is that the round key, an AES key, is XORed into the AES state.
212
00:21:30,000 --> 00:21:36,000
So a ciphertext goes in, a round key is XORed through it, and then further steps are taken.
213
00:21:36,000 --> 00:21:43,000
One of the later steps is inverse subbytes, which performs a lookup in a table.
214
00:21:43,000 --> 00:21:48,000
This table is called the S-Box. It's a 256-byte table.
215
00:21:48,000 --> 00:21:56,000
So a state byte is used as an index in this table, and whichever is there is then the new value for that state byte.
216
00:21:56,000 --> 00:22:04,000
So we do not know where this S-Box resides. It's somewhere in this Texas Instruments ROM code, but we cannot read all of it.
217
00:22:04,000 --> 00:22:08,000
So we somehow have to figure out where the S-Box lives.
218
00:22:08,000 --> 00:22:18,000
We do that by throwing out a small part of the secret ROM code from the cache using our eviction control,
219
00:22:18,000 --> 00:22:23,000
and then measure how long it takes to perform a module load.
220
00:22:23,000 --> 00:22:31,000
So we try to load a module and we see how long this takes on average, and then we throw out another part of the secret page,
221
00:22:31,000 --> 00:22:37,000
and we check how long that takes to load. And what we get is a plot something like this.
222
00:22:37,000 --> 00:22:46,000
Most addresses do not affect the running time, except a small portion where a drastic performance penalty is seen if we throw that out of the caches.
223
00:22:46,000 --> 00:22:52,000
So clearly these are the areas that the S-Box resides.
224
00:22:52,000 --> 00:23:02,000
So fully blindly we manage to locate the S-Box in ROM, and for the remainder we will assume the following setup.
225
00:23:02,000 --> 00:23:09,000
We ensure the entire table, the entire S-Box is loaded into cache memory by loading a module once.
226
00:23:09,000 --> 00:23:16,000
Then we use our eviction control to throw out the first 32 entries, and then we enable cache freeze.
227
00:23:16,000 --> 00:23:25,000
So what we have now is a situation where a lookup in the first part of the S-Box, which we call the first octant,
228
00:23:25,000 --> 00:23:35,000
will incur a performance penalty that we can see, and a lookup in any other part of the S-Box will be serviced quickly from cache and will not show the penalty.
229
00:23:35,000 --> 00:23:39,000
And this setup is assumed for the remainder of this section.
230
00:23:39,000 --> 00:23:49,000
So the attack will work as follows. We set our first ciphertext byte to zero and we randomize all the other ciphertext bytes.
231
00:23:49,000 --> 00:23:59,000
And then we ask the secure kernel to load this module. It will try to load it, of course it will fail validation, so it will reject the module, but it will decrypt it first.
232
00:23:59,000 --> 00:24:07,000
So we can see whether, if we set the ciphertext byte to zero, whether it incurs this penalty or not.
233
00:24:07,000 --> 00:24:17,000
So in short, you have this AES state byte. It goes as an index into the table. If it hits the first part, it will be slow. If it hits the rest, it will be fast.
234
00:24:17,000 --> 00:24:29,000
And we do that repeatedly for all values for the first ciphertext byte. And if we plot that, we see this. For those who do not see it, I shall describe it.
235
00:24:29,000 --> 00:24:39,000
The first 32 entries are fast, then we get 32 entries that are significantly slower, and the remainder is fast again.
236
00:24:39,000 --> 00:24:51,000
So what we have here is that the first ciphertext byte, XORed with the first round key byte, is exhibiting a performance penalty when it is between 32 and 64.
237
00:24:51,000 --> 00:25:13,000
So we have effectively recovered three bits of this byte. So we can repeat that for all the other bytes, and we can get 48 bits of a round key, which is amazing, but not enough, because 80 bits remain, and that's just too much to brute force, at least for someone with our equipment.
238
00:25:13,000 --> 00:25:29,000
So we somehow have to go deeper. Why doesn't this work? This doesn't work because the least significant bits of our ciphertext and of the round key byte do not influence in which octant the lookup will hit.
239
00:25:29,000 --> 00:25:55,000
So this is inherently limited. And as such, what we decided to do is take the attack one round further. We will not target the SBOX lookup in the first decryption round, but in the second decryption round, to make sure that the least significant bits are now indeed affecting the most significant three bits, and as such are affecting in which octant the lookup occurs.
240
00:25:55,000 --> 00:26:14,000
Now, it's complicated because you have to account for some stuff. There is some rows shifting around. There is another round key byte that is affecting the state, and also there is this mixed columns step that performs a computation over multiple state bytes, so this gets all mixed up.
241
00:26:14,000 --> 00:26:30,000
We were able to account for all of that. I'm not going into detail for the sake of time. But we managed to get it working, and I'll now show a short demo video.
242
00:26:30,000 --> 00:26:49,000
So what we see here is how we load some kernel modules on the application processor. I cannot read it myself, but oh yeah, I can't. Clearly here we are loading a module that kicks the watchdog, so we hijack the execution of the DSP, but the watchdog has to be serviced in order to prevent a board reset.
243
00:26:49,000 --> 00:27:11,000
And then we start gathering measurements from the DSP. We're collecting timing data and constantly comparing the timing data to a profile we built, and we can recover bytes of round key 10 in this way.
244
00:27:11,000 --> 00:27:24,000
This takes about a minute, and then it will have recovered all of the 16 round key bytes. If you have all round key bytes, you can reverse the key schedule AES uses and retrieve the original base key.
245
00:27:24,000 --> 00:27:43,000
[no audio]
246
00:27:43,000 --> 00:27:55,000
[no audio]
247
00:27:55,000 --> 00:28:15,000
Alright, so there we have it. Thank you. Cool. So in about a minute we recovered the cryptographic key from this radio, fully running on the radio.
248
00:28:15,000 --> 00:28:28,000
By the way, what you saw was not the actual Motorola key, we changed it because if not people would get really angry at us.
249
00:28:28,000 --> 00:28:38,000
We're good? We're good. Okay. So now that we were able to decrypt our module, there were some other hoops to jump through, but I'm going to skip that in the interest of time.
250
00:28:38,000 --> 00:28:50,000
We were able to decrypt the module that embeds the Tetra cryptographic primitives. Recapping, we first attacked the AT modem command interface, we found the format string vulnerability which we exploited.