are there spectre-based malware on your android smartphone? · smartphone processor(s) huawei honor...
TRANSCRIPT
![Page 1: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/1.jpg)
Are there Spectre-basedmalware on your Android
smartphone?
Axelle Apvrille - Fortinet
Pass The Salt, July 2018
![Page 2: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/2.jpg)
All of you have heard of Spectre *
Sophisticated and powerful cache attack on CPUs
* https://spectreattack.com/spectre.pdf
Pass The Salt, July 2018 - A. Apvrille 2/48
![Page 3: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/3.jpg)
Spectre? “Please not yet another talk!”
Pass The Salt, July 2018 - A. Apvrille 3/48
![Page 4: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/4.jpg)
Good news
I won’t repeat what’s already on the webwhether you are Spectre experts or not, you should be able to follow most of it
Overview: YouTube video
Tech: https://gruss.cc/files/cryptacus2018.pdf
Pass The Salt, July 2018 - A. Apvrille 4/48
![Page 5: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/5.jpg)
Are there Spectre malware onyour Android smartphone?
I am an Anti-Virus researcher at Fortinet
Predestined for a talk on Spectre
official Spectre logo @cryptax
Pass The Salt, July 2018 - A. Apvrille 5/48
![Page 6: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/6.jpg)
Are there Spectre malware onyour Android smartphone?
I am an Anti-Virus researcher at Fortinet
Predestined for a talk on Spectre
official Spectre logo @cryptax
Pass The Salt, July 2018 - A. Apvrille 5/48
![Page 7: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/7.jpg)
Are there Spectre malware onyour Android smartphone?
I am an Anti-Virus researcher at Fortinet
Predestined for a talk on Spectre
official Spectre logo @cryptax
Pass The Salt, July 2018 - A. Apvrille 5/48
![Page 8: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/8.jpg)
Are there Spectremalware on your
Android smartphone?
We’ll rule out Intel x86 phones:
1 Lots of literature on Spectre for Intelx86 processors
2 Most Android smartphones have anARM processor
Pass The Salt, July 2018 - A. Apvrille 6/48
![Page 9: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/9.jpg)
Are there Spectremalware on your
Android smartphone?
We’ll rule out Intel x86 phones:
1 Lots of literature on Spectre for Intelx86 processors
2 Most Android smartphones have anARM processor
Pass The Salt, July 2018 - A. Apvrille 6/48
![Page 10: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/10.jpg)
Are there Spectremalware on your
Android smartphone?
We’ll rule out Intel x86 phones:
1 Lots of literature on Spectre for Intelx86 processors
2 Most Android smartphones have anARM processor
Pass The Salt, July 2018 - A. Apvrille 6/48
![Page 11: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/11.jpg)
Part 1
Are there Spectremalware on my/yourAndroid ARM-based
smartphone?
Pass The Salt, July 2018 - A. Apvrille 7/48
![Page 12: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/12.jpg)
This is going to be soooo simple!
ARM published a security update *Check if our processor is in the list
* https://developer.arm.com/support/security-update
Pass The Salt, July 2018 - A. Apvrille 8/48
![Page 13: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/13.jpg)
Which ARM processors do we have?
Survey among colleagues with an Android smartphone
Smartphone Processor(s)
Huawei Honor 8x ARM Cortex A53Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM
Cortex A53Samsung Galaxy J5 4 x ARM Cortex A53
Motorola Defy + ARM Cortex A8Motorola Moto E 4G 4 x ARM Cortex A53
.. ..
Pass The Salt, July 2018 - A. Apvrille 9/48
![Page 14: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/14.jpg)
Lots of ARM Cortex A53 processors
Warning
Results among close colleagues at work.Different from world wide statistics!
Pass The Salt, July 2018 - A. Apvrille 10/48
![Page 15: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/15.jpg)
Is Cortex A53 vulnerable?
ARM says it is not vulnerable:
“Only affected cores are listed,all other Arm cores are NOT affected.”
Pass The Salt, July 2018 - A. Apvrille 11/48
![Page 16: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/16.jpg)
Why isn’t it vulnerable?
Cortex A53: “in-order pipeline and advanced branch predictor”
False Idea: in-order processors are immune to Spectre
Wrong. Spectre is for Speculative Execution.
In Order
A
B
C
Out of Order:
“I can do C beforeB“A
C
B
SpeculativeExecution:
“Assume we’ll runC”
A
B C
In Order/Out of Order 6= Speculative Execution
Pass The Salt, July 2018 - A. Apvrille 12/48
![Page 17: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/17.jpg)
The more we dig, the less we know...
ARM Cortex A53 specs:
Sounds like it is vulnerable to Spectre!
Conclusion: is it vulnerable, or not? It’s not clear!
Pass The Salt, July 2018 - A. Apvrille 13/48
![Page 18: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/18.jpg)
The more we dig, the less we know...
ARM Cortex A53 specs:
Sounds like it is vulnerable to Spectre!
Conclusion: is it vulnerable, or not? It’s not clear!
Pass The Salt, July 2018 - A. Apvrille 13/48
![Page 19: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/19.jpg)
The more we dig, the less we know...
ARM Cortex A53 specs:
Sounds like it is vulnerable to Spectre!
Conclusion: is it vulnerable, or not? It’s not clear!
Pass The Salt, July 2018 - A. Apvrille 13/48
![Page 20: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/20.jpg)
Solution: test it!
1 Find an Android smartphone with ARMCortex A53.
2 Find a PoC of Spectre for that smartphone
3 Test
Pass The Salt, July 2018 - A. Apvrille 14/48
![Page 21: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/21.jpg)
Step 1: find a smartphone
No problem, I have some in the lab
Pass The Salt, July 2018 - A. Apvrille 15/48
![Page 22: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/22.jpg)
Step 2: find a PoC
Spectre PoCs
From the paper, or on github for Intel x66:https://github.com/Eugnis/spectre-attack/blob/
master/Source.c
Variant 1 for Android AArch64 architectures. https:
//github.com/V-E-O/PoC/tree/master/CVE-2017-5753
Variant 4 “Spectre-NG”.https://www.exploit-db.com/exploits/44695/
A PoC is not a malware
PoC = Proof of ConceptThey recover memory areas from your own process!They are not malicious, only a demo
Pass The Salt, July 2018 - A. Apvrille 16/48
![Page 23: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/23.jpg)
Can we use the PoC for AArch64?
Spectre PoCs
From the paper
Variant 1 for Android AArch64 architectures.
Variant 4 “Spectre-NG”
Pass The Salt, July 2018 - A. Apvrille 17/48
![Page 24: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/24.jpg)
Can we use the PoC for AArch64?
Cortex A53 characteristics
“The Cortex-A53 can be implemented
in two execution states:AArch32 and AArch64.”
AArch32: execute ARMv7 apps - 32 bit
AArch64: 64 bit
https:
//developer.arm.com/products/processors/cortex-a/cortex-a53
Pass The Salt, July 2018 - A. Apvrille 18/48
![Page 25: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/25.jpg)
Can we use the PoC for AArch64?
Cortex A53 characteristics
“The Cortex-A53 can be implemented in two execution states:AArch32 and AArch64.”
AArch32: execute ARMv7 apps - 32 bit
AArch64: 64 bit
https:
//developer.arm.com/products/processors/cortex-a/cortex-a53
Pass The Salt, July 2018 - A. Apvrille 18/48
![Page 26: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/26.jpg)
Can we use the PoC for AArch64?
Cortex A53 characteristics
“The Cortex-A53 can be implemented in two execution states:AArch32 and AArch64.”
AArch32: execute ARMv7 apps - 32 bit
AArch64: 64 bit
https:
//developer.arm.com/products/processors/cortex-a/cortex-a53
Pass The Salt, July 2018 - A. Apvrille 18/48
![Page 27: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/27.jpg)
Push it and run on the smartphone
$ git clone https://...$ NDK DIR/build/tools/make standalone toolchain.py ...
$ TOOLCHAIN DIR/bin/aarch64-linux-android-gcc
source.c -o spectre
spectre
Pass The Salt, July 2018 - A. Apvrille 19/48
![Page 28: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/28.jpg)
Push it and run on the smartphone
$ git clone https://...$ NDK DIR/build/tools/make standalone toolchain.py ...
$ TOOLCHAIN DIR/bin/aarch64-linux-android-gcc
source.c -o spectre
spectre
/system/bin/sh: ./spectre: not executable: 64-bit ELF file
Pass The Salt, July 2018 - A. Apvrille 19/48
![Page 29: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/29.jpg)
Why isn’t it working?
shell@surnia:/ $ cat /proc/cpuinfoprocessor: 0model name : ARMv7 Processor rev 0 (v7l)BogoMIPS: 38.00Features: swp half thumb fastmult vfp edsp ...CPU implementer : 0x41CPU architecture: 7CPU variant : 0x0CPU part: 0xd03CPU revision: 0
ARMv7 is 32-bit!
64-bit capable processorbut 32-bit stock kernel !
Pass The Salt, July 2018 - A. Apvrille 20/48
![Page 30: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/30.jpg)
We need a PoC for ARMv7 /AArch32 (32 bit apps)
There are none...
Let’s implement one!A PoC is not a malware
Pass The Salt, July 2018 - A. Apvrille 21/48
![Page 31: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/31.jpg)
We need a PoC for ARMv7 /AArch32 (32 bit apps)
There are none...
Let’s implement one!A PoC is not a malware
Pass The Salt, July 2018 - A. Apvrille 21/48
![Page 32: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/32.jpg)
We need a PoC for ARMv7 /AArch32 (32 bit apps)
There are none...
Let’s implement one!A PoC is not a malware
Pass The Salt, July 2018 - A. Apvrille 21/48
![Page 33: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/33.jpg)
Implementation of Flush+Reload
The PoC for Intel x86 uses:
1 Flush the cache: the PoC uses mm clflush
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the <c> CLFLUSH </c> instruction.
///
/// \param __p
/// A pointer to the memory location used to identify the cache line to be
/// flushed.
void _mm_clflush(void const * __p);
/// \brief Forces strong memory ordering (serialization) between load
/// instructions preceding this instruction and load instructions following
/// this instruction, ensuring the system completes all previous loads before
/// executing subsequent loads.
2 Read time: the PoC uses rdtscp. Returns the value of theTime Stamp Counter (64-bit tick count).
Pass The Salt, July 2018 - A. Apvrille 22/48
![Page 34: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/34.jpg)
Flush the cache on Android
No mm clflush, no clearcache
There is a ARM NR cacheflush
In usr/include/asm/unistd.h:
#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
...
#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
Pass The Salt, July 2018 - A. Apvrille 23/48
![Page 35: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/35.jpg)
Measuring Time on Android
No rdtscp, no rdtsc on Android
Re-use existing work on cache attacks for ARM:
M. Lipp, D. Gruss, R. Spreitzer, C. Maurice, S. Mangard,ARMageddon: Cache Attacks on Mobile Devices, USENIXSecurity 2016
X. Zhang, Y. Xiao, Y. Zhang, Return-Oriented Flush-ReloadSide Channels on ARM and Their Implications for AndroidDevices, CCS 2016
Pass The Salt, July 2018 - A. Apvrille 24/48
![Page 36: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/36.jpg)
Solutions to measure time on Android
Strategy Does it work on our smart-phone?
Monitor hardware events viaperf event open() syscall
Hardware counters not available onmy smartphone
CPU’s PerformanceMonitor Unit
Only enabled for kernel space
Dedicated thread timer Not precise enoughPOSIX clock gettime() OK
Pass The Salt, July 2018 - A. Apvrille 25/48
![Page 37: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/37.jpg)
Results
Run spectre with clock gettime()
Putting ’The Magic Words are Squeamish Ossifrage.’ in memory
MAX_TRIES=999 CACHE_HIT_THRESHOLD=80 len=40
Reading 40 bytes:
Reading at malicious_x = 0xffffe7e4 Success: 0xFF=’?’ score=0
Reading at malicious_x = 0xffffe7e5 Success: 0xFF=’?’ score=0
Reading at malicious_x = 0xffffe7e6 Success: 0xFF=’?’ score=0
Reading at malicious_x = 0xffffe7e7 Success: 0xFF=’?’ score=0
Reading at malicious_x = 0xffffe7e8 Success: 0xFF=’?’ score=0
Reading at malicious_x = 0xffffe7e9 Success: 0xFF=’?’ score=0
Reading at malicious_x = 0xffffe7ea Success: 0xFF=’?’ score=0
Score = 0 : we have no cache hit!
Pass The Salt, July 2018 - A. Apvrille 26/48
![Page 38: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/38.jpg)
Tuning...
MAX_TRIES=5500 CACHE_HIT_THRESHOLD=364 len=40
Reading 40 bytes:
Reading at malicious_x = 0xffffe7e4 Unclear: 0x6F=’o’ score=809 (second best: 0xF0=’?’ score=806)
Reading at malicious_x = 0xffffe7e5 Unclear: 0xF3=’?’ score=809 (second best: 0xF6=’?’ score=808)
Reading at malicious_x = 0xffffe7e6 Unclear: 0xF0=’?’ score=877 (second best: 0xF6=’?’ score=847)
Reading at malicious_x = 0xffffe7e7 Unclear: 0xF0=’?’ score=839 (second best: 0xF6=’?’ score=829)
We still don’t recover the secretResults are different at each run
It’s not working
Pass The Salt, July 2018 - A. Apvrille 27/48
![Page 39: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/39.jpg)
Same results with ARM Cortex A8
Older ARMv7 processor introduced in 2005
ARM says it is vulnerable to Spectre
Same results above Android 32-bit ROM: impossible torecover the secret
Pass The Salt, July 2018 - A. Apvrille 28/48
![Page 40: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/40.jpg)
Conclusion
Possible conclusions:
1 ”@cryptax: your implementation is wrong”. Don’t think so.Getting same results with libflush from ARMaggedon...
2 or ARM Cortex A53 is not vulnerable to Spectre (but wedon’t know why)
3 or POSIX clock gettime() isn’t precise enough. Option:try Spectre as kernel module.
4 or ARM NR cacheflush isn’t working properly. To do:don’t use Flush+Reload but try Prime+Probe orEvict+Reload.
https://github.com/cryptax/spectre-armv7
Pass The Salt, July 2018 - A. Apvrille 29/48
![Page 41: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/41.jpg)
What have we learned? Part 1
Smartphone Is processorvulnerable?
Is smartphonevulnerable?
Low or middle range An-droid phones with ARMCortex A53
Officially no,but unsure
Straight out of thebox, no
Old Android phones withARM Cortex A8
Yes Straight out of thebox, no
High end Android smart-phones with 64-bit ROM
Check whatARM securityupdate
Test AArch64 PoC
Spectre on Android
Can smartphones be affected? Yes!
A vulnerable processor is different from a vulnerable system
Pass The Salt, July 2018 - A. Apvrille 30/48
![Page 42: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/42.jpg)
Part 2Are there malware in the wild?
Pass The Salt, July 2018 - A. Apvrille 31/48
![Page 43: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/43.jpg)
That’s we read in the news (end of January 2018)
Pass The Salt, July 2018 - A. Apvrille 32/48
![Page 44: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/44.jpg)
That’s we read in the news (end of January 2018)
Pass The Salt, July 2018 - A. Apvrille 32/48
![Page 45: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/45.jpg)
That’s we read in the news (end of January 2018)
Is this true?
Pass The Salt, July 2018 - A. Apvrille 32/48
![Page 46: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/46.jpg)
Checked those samples one by one
At that time, 139 samples:
W32/Spectre.D!tr
Riskware/SpectrePOC
Riskware/POC Spectre
Linux/Spectre!tr
Linux/Spectre.C!tr
Linux/Spectre.A!exploit 3043151C.vsc
All of them are Proof of Concepts
Renamed them to Riskware/SpectrePOC
Pass The Salt, July 2018 - A. Apvrille 33/48
![Page 47: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/47.jpg)
A PoC is not a malware
A Proof of Concept demonstrates a concept works
PoC proves cache attack works by recovering “The MagicWords are Squeamish Ossifrage”
PoC is not malicious: “The Magic Words are SqueamishOssifrage” is known from the beginning
Turning the PoC into malware would require more work
Identify a vulnerable function in targeted software potentiallylong!
Access shared memory (inter process communication)
Compile for given OS and CPU: cf Android, this can bedifficult
Pass The Salt, July 2018 - A. Apvrille 34/48
![Page 48: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/48.jpg)
What’s true, what’s wrong
There is no malware yet in the wild, only PoCs
Attackers are possibly testing / experimenting (but we don’thave the proof for that)
Pass The Salt, July 2018 - A. Apvrille 35/48
![Page 49: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/49.jpg)
The graph is correct, but the label is wrong
Pass The Salt, July 2018 - A. Apvrille 36/48
![Page 50: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/50.jpg)
Spectre PoCs status - June 2018
183 PoCs: 119 PE32+, 62 ELF, 2 Mach-O
Pass The Salt, July 2018 - A. Apvrille 37/48
![Page 51: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/51.jpg)
Detection hits for Spectre Proof of Concepts
0
500
1000
1500
2000
2500
3000
3500
Jan Feb Mar Apr May Jun
Hits on Riskware/SpectrePoC from Fortinet products(when enabled) in 2018
Jan 3. Spectrevulnerabilitypublicly disclosed
Jan 27-29. Patchesfor Windows
March 1-13. Morepatches
May 3. Spectre-NG
January spike: initial release of signaturesMarch spikes: customers testing after several patches of Microsoft?
Pass The Salt, July 2018 - A. Apvrille 38/48
![Page 52: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/52.jpg)
Detection hit details for Proof of Concepts
0
20
40
60
80
100
Jan Feb Mar Apr May Jun
Apart from spikes, average 40 hits / dayLess starting in April
Pass The Salt, July 2018 - A. Apvrille 39/48
![Page 53: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/53.jpg)
No Spectre malware currently
And later?We need pro-active detection!
Pass The Salt, July 2018 - A. Apvrille 40/48
![Page 54: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/54.jpg)
No Spectre malware currentlyAnd later?
We need pro-active detection!
Pass The Salt, July 2018 - A. Apvrille 40/48
![Page 55: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/55.jpg)
No Spectre malware currentlyAnd later?
We need pro-active detection!
Pass The Salt, July 2018 - A. Apvrille 40/48
![Page 56: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/56.jpg)
Detect Flush+Reload cache attacks
Is this ELF x86-64?
Binary
Cache Flush
Time Time
Detect
In AV, this is called a signature. Though it is not a cryptographic signature(nor a hash), rather a detection pattern.
Pass The Salt, July 2018 - A. Apvrille 41/48
![Page 57: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/57.jpg)
Detect Flush+Reload cache attacks
Is this ELF x86-64?
Binary
Cache Flush
Time
Time
Detect
In AV, this is called a signature. Though it is not a cryptographic signature(nor a hash), rather a detection pattern.
Pass The Salt, July 2018 - A. Apvrille 41/48
![Page 58: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/58.jpg)
Detect Flush+Reload cache attacks
Is this ELF x86-64?
Binary
Cache Flush
Time Time
Detect
In AV, this is called a signature. Though it is not a cryptographic signature(nor a hash), rather a detection pattern.
Pass The Salt, July 2018 - A. Apvrille 41/48
![Page 59: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/59.jpg)
Detect Flush+Reload cache attacks
Is this ELF x86-64?
Binary
Cache Flush
Time Time
Detect
In AV, this is called a signature. Though it is not a cryptographic signature(nor a hash), rather a detection pattern.
Pass The Salt, July 2018 - A. Apvrille 41/48
![Page 60: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/60.jpg)
This signature is far from perfect
Time-consuming (full binary search)High risk of False Positives
Does not detect Prime+Probe etcAlways possible to evade
but let’s try it
Pass The Salt, July 2018 - A. Apvrille 42/48
![Page 61: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/61.jpg)
This signature is far from perfect
Time-consuming (full binary search)High risk of False Positives
Does not detect Prime+Probe etcAlways possible to evade
but let’s try it
Pass The Salt, July 2018 - A. Apvrille 42/48
![Page 62: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/62.jpg)
This signature is far from perfect
Time-consuming (full binary search)High risk of False Positives
Does not detect Prime+Probe etcAlways possible to evade
but let’s try it
Pass The Salt, July 2018 - A. Apvrille 42/48
![Page 63: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/63.jpg)
"./2FC4432E.vsc" is infected with the "Linux/FlushReload.A!tr" virus. VID: 888 SIGID: 8888 SIGTYPE: C
"./2FC0C6A4.vsc" is infected with the "Linux/FlushReload.A!tr" virus. VID: 888 SIGID: 8888 SIGTYPE: C
"./2FC4A10C.vsc" is infected with the "Linux/FlushReload.A!tr" virus. VID: 888 SIGID: 8888 SIGTYPE: C
[Summary] Scanned: 62 Infected: 38 Total bytes: 1.614MiB Time: 0m0.001s
Quite good: 38 detections in one shot!Why are we missing some samples?
Pass The Salt, July 2018 - A. Apvrille 43/48
![Page 64: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/64.jpg)
We do have 2 rdtscp instructions
Pass The Salt, July 2018 - A. Apvrille 44/48
![Page 65: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/65.jpg)
Missing cache flush! (bad)
This is a damaged sample. Won’t work.Good: We don’t care our signature does not detect it
Pass The Salt, July 2018 - A. Apvrille 45/48
![Page 66: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/66.jpg)
Cache attacks are not common in malware
Signature only caught Spectre PoC samples.No Linux malware currently using Flush+Reload
Pass The Salt, July 2018 - A. Apvrille 46/48
![Page 67: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/67.jpg)
Conclusion - Part 2
Spectre malware
Currently, no Spectre malware, only PoCs for W32, Linuxand Mac. Nothing for ARM-based smartphones (or otherIoT)
Cache attacks are not common in malware
Will there be Spectre malware in the future?
Pass The Salt, July 2018 - A. Apvrille 47/48
![Page 68: Are there Spectre-based malware on your Android smartphone? · Smartphone Processor(s) Huawei Honor 8x ARM Cortex A53 Samsung Galaxy S6 1 x ARM Cortex A57 + 1 x ARM Cortex A53 Samsung](https://reader030.vdocuments.net/reader030/viewer/2022041005/5eab0724d76081475b60aa70/html5/thumbnails/68.jpg)
Questions?
Thanks@TuxDePoinsisse, Daniel Gruss, Adam Shewchuk, Renaud Pacalet
aapvrille (at) fortinet (dot) com - @cryptax
Smart devices CTFDecember 14, 2018 - https://ph0wn.org
Pass The Salt, July 2018 - A. Apvrille 48/48