Mobile Systems and Smartphone Security�(MOBISEC 2020)
Prof: Yanick Fratantonio�EURECOM
1
Vulnerability Analysis�and Exploitation
Last class...
2
This class
3
Security Vulnerability
4
Not all vulns are the same
5
Threat Model
6
Key Concept: Threat Model
7
Key Concept: Threat Model
8
Threat Modelling for Attacks
9
Threat Modelling for Attacks
10
Threat Modelling for Defense Systems
11
Threat Modelling for Defense Systems
12
Threat Models
13
Common Threat Models
14
Common Threat Models
15
Common Threat Models
16
Common Threat Models
17
Common Threat Models
18
Common Threat Models
19
Common Threat Models: Three classes (ref)
20
Attack Surface
21
Why attackers like vulns?
22
Threat Model /�Assumptions
What the attacker wants to do
Technical Gap
Security Vulnerabilities
Vulnerability Characterization
23
The "type"
24
The "type"
25
The "type"
26
The "type"
27
The "type"
28
The "type"
29
The "where"
30
The "where"
31
The "where"
32
Type + Where
33
Vulnerability Exploitation
34
Vulnerability Severity
35
Severity Score
36
Severity Score
37
Vulnerability Chaining
38
Vulnerability Tracking
39
Vulnerability Tracking: CVE numbers
40
Android Security Bulletins
41
Classes of vulnerabilities
42
Classes of vulnerabilities
43
Attack Surface Enumeration
44
Attacking the user
45
Attacking apps
46
App ⇔ Network backend
47
Dynamic Code Loading
48
Cryptographic Vulnerabilities
49
Confused Deputy Problem
50
Confused Deputy Problem
51
Confused Deputy Problem
52
Confused Deputy Problem
53
Component Hijacking
54
Permission/Capability Leak
55
Content Leaks & Pollution
56
Content Leaks & Pollution
57
Overpermissioning
58
Zip Path Traversal
59
Zip Path Traversal
GET http://skslm.swiftkey.net/samsung/downloads/v1.3-USA/az_AZ.zip
← 200 application/zip 995.63kB 601ms
root@kltevzw:/data/data/com.sec.android.inputmethod/app_SwiftKey/az_AZ # ls -l
-rw------- system system 606366 2015-06-11 15:16 az_AZ_bg_c.lm1
-rw------- system system 1524814 2015-06-11 15:16 az_AZ_bg_c.lm3
-rw------- system system 413 2015-06-11 15:16 charactermap.json
-rw------- system system 36 2015-06-11 15:16 extraData.json
-rw------- system system 55 2015-06-11 15:16 punctuation.json
$ unzip -l evil.zip
Archive: evil.zip
Length Date Time Name
--------- ---------- ----- ----
5 2014-08-22 18:52 ../../../../../../../../data/payload
--------- -------
5 1 file
Zip Path Traversal
Tech details: https://www.nowsecure.com/blog/2015/06/16/remote-code-execution-as-system-user-on-samsung-phones/
root@kltevzw:/data/dalvik-cache # /data/local/tmp/busybox find . -type f -group 1000
./system@framework@colorextractionlib.jar@classes.dex
./system@framework@com.google.android.media.effects.jar@classes.dex
./system@framework@com.google.android.maps.jar@classes.dex
./system@framework@VZWAPNLib.apk@classes.dex
./system@framework@cneapiclient.jar@classes.dex
./system@framework@com.samsung.device.jar@classes.dex
./system@framework@com.quicinc.cne.jar@classes.dex
./system@framework@qmapbridge.jar@classes.dex
./system@framework@rcsimssettings.jar@classes.dex
./system@framework@rcsservice.jar@classes.dex
./system@priv-app@DeviceTest.apk@classes.dex
Critical: the keyboard app could NOT be uninstalled
This is code!
Native Code
62
More apps' vulns
63
Attacking the system
64
Unsafe Self-Update
65
L. Xing, X. Pan, R. Wang, K. Yuan, and X. Wang. Upgrading Your Android, Elevating My Malware: Privilege Escalation Through Mobile OS Updating. In IEEE Symposium on Security and Privacy, 2014.
Attacking the system
66
Stagefright bug
Stagefright bug
status_t MPEG4Source::parseChunk(off64_t *offset) {
uint64_t chunk_size = ntohl(hdr[0]); // attacker-controlled!
size_t size = 0;
if (!mLastTrack->meta->findData(
kKeyTextFormatData, &type, &data, &size)) {
size = 0;
}
uint8_t *buffer = new (std::nothrow) uint8_t[size + chunk_size];
[...]
if (size > 0) {
memcpy(buffer, data, size);
}
}
uint64_t
size_t
The parameter of the “new” operator has type size_t
Stagefright bug
status_t MPEG4Source::parseChunk(off64_t *offset) {
uint64_t chunk_size = ntohl(hdr[0]); // attacker-controlled!
size_t size = 0;
if (!mLastTrack->meta->findData(
kKeyTextFormatData, &type, &data, &size)) {
size = 0;
}
uint8_t *buffer = new (std::nothrow) uint8_t[size + chunk_size];
[...]
if (size > 0) {
memcpy(buffer, data, size);
}
}
uint64_t
size_t
The parameter of the “new” operator has type size_t
Stagefright bug
status_t MPEG4Source::parseChunk(off64_t *offset) {
uint64_t chunk_size = ntohl(hdr[0]); // attacker-controlled!
size_t size = 0;
if (!mLastTrack->meta->findData(
kKeyTextFormatData, &type, &data, &size)) {
size = 0;
}
uint8_t *buffer = new (std::nothrow) uint8_t[size + chunk_size];
[...]
if (size > 0) {
memcpy(buffer, data, size);
}
}
uint64_t
size_t
Buffer overflow!
sizeof(buffer) < sizeof(data)
The parameter of the “new” operator has type size_t
Baseband vulnerabilities
71
Bootloader vulnerabilities
72
TEE-related bugs
73
74
PTR are addresses
They must be converted to physical addresses so that both NSW / SW understand them
They must be converted to physical addresses so that both NSW / SW understand them
Flaw #2: TA does not know which UA started this transaction
Flaw #1: it's possible to "hide" a PTR so that it does not go through the VA ⇒ PA conversion
Instance of confused deputy problem!
Net result: TA will read from an attacker-chosen kernel address
Attacking the hardware
75
Rowhammer bug
76
Rowhammer bug
77
Image from wiki
Rowhammer bug
78
Image from wiki
Rowhammer bugs
79
Rowhammer bugs
80
Drammer
81
Drammer's "fix"
82
"Traditional" bugs vs. design bugs
83