|
1 | 1 | # Detect CWE-312 in Android Application
|
2 | 2 |
|
3 |
| -This scenario seeks to find **cleartext storage of sensitive data** in the APK file. |
4 | 3 |
|
5 |
| -## CWE-312: Cleartext Storage of Sensitive Information |
| 4 | +This scenario seeks to find **cleartext storage of sensitive data** in |
| 5 | +the APK file. |
| 6 | + |
| 7 | +## CWE-312 Cleartext Storage of Sensitive Information |
6 | 8 |
|
7 | 9 | We analyze the definition of CWE-312 and identify its characteristics.
|
8 | 10 |
|
9 |
| -See [CWE-312](https://cwe.mitre.org/data/definitions/312.html) for more details. |
| 11 | +See [CWE-312](https://cwe.mitre.org/data/definitions/312.html) for more |
| 12 | +details. |
10 | 13 |
|
11 |
| - |
| 14 | + |
12 | 15 |
|
13 | 16 | ## Code of CWE-312 in ovaa.apk
|
14 | 17 |
|
15 |
| -We use the [ovaa.apk](https://github.com/oversecured/ovaa) sample to explain the vulnerability code of CWE-312. |
16 |
| - |
17 |
| - |
18 |
| - |
19 |
| -## CWE-312 Detection Process Using Quark Script API |
20 |
| - |
21 |
| -Let’s use the above APIs to show how the Quark script finds this vulnerability. |
| 18 | +We use the [ovaa.apk](https://github.com/oversecured/ovaa) sample to |
| 19 | +explain the vulnerability code of CWE-312. |
22 | 20 |
|
23 |
| -We have designed a [Frida](https://frida.re/) script ``agent.js`` to hook a specified method and get the arguments when the method is called. It can be found in [quark-engine/quark/script/frida](https://github.com/quark-engine/quark-engine/tree/master/quark/script/frida). |
24 |
| - |
25 |
| -To begin with, we hook the method ``putString`` to catch its arguments. Then, we check if sensitive information like email or password is passed. Finally, we use ``checkClearText`` imported from [Ares](https://github.com/bee-san/Ares) to check if the arguments are cleartext. If both **YES**, CWE-312 vulnerability might be caused. |
| 21 | + |
26 | 22 |
|
27 |
| - |
| 23 | +## Quark Script CWE-312.py |
28 | 24 |
|
29 |
| -## Quark Script: CWE-312.py |
| 25 | +Let\'s use the above APIs to show how the Quark script finds this |
| 26 | +vulnerability. |
30 | 27 |
|
31 |
| - |
| 28 | +First, we designed a [Frida](https://frida.re) script `agent.js` to hook |
| 29 | +the target method and get the arguments when the target method is |
| 30 | +called. Then we hook the method `putString` to catch its arguments. |
| 31 | +Finally, we use [Ares](https://github.com/bee-san/Ares) to check if |
| 32 | +the arguments are encrypted. |
32 | 33 |
|
33 |
| -```python |
| 34 | +``` python |
34 | 35 | from quark.script.frida import runFridaHook
|
35 | 36 | from quark.script.ares import checkClearText
|
36 | 37 |
|
@@ -61,7 +62,7 @@ for putString in fridaResult.behaviorOccurList:
|
61 | 62 |
|
62 | 63 | ## Frida Script: agent.js
|
63 | 64 |
|
64 |
| -```javascript |
| 65 | +``` javascript |
65 | 66 | // -*- coding: utf-8 -*-
|
66 | 67 | // This file is part of Quark-Engine - https://github.com/quark-engine/quark-engine
|
67 | 68 | // See the file 'LICENSE' for copying permission.
|
@@ -124,7 +125,7 @@ rpc.exports["watchMethodCall"] = (classAndMethodName, methodParamTypes) => watch
|
124 | 125 |
|
125 | 126 | ## Quark Script Result
|
126 | 127 |
|
127 |
| -```TEXT |
| 128 | +``` TEXT |
128 | 129 | $ python3 CWE-312.py
|
129 | 130 | The CWE-312 vulnerability is found. The cleartext is "[email protected]"
|
130 | 131 | The CWE-312 vulnerability is found. The cleartext is "password"
|
|
0 commit comments