You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CWE-20/README.md
+20-22Lines changed: 20 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -1,38 +1,34 @@
1
1
# Detect CWE-20 in Android Application
2
2
3
+
This scenario seeks to find **Improper Input Validation** in the APK file.
3
4
4
-
This scenario seeks to find **Improper Input Validation** in the APK
5
-
file.
6
-
7
-
## CWE-20 Improper Input Validation
5
+
## CWE-20: Improper Input Validation
8
6
9
7
We analyze the definition of CWE-20 and identify its characteristics.
10
8
11
-
See [CWE-20](https://cwe.mitre.org/data/definitions/20.html) for more
12
-
details.
9
+
See [CWE-20](https://cwe.mitre.org/data/definitions/20.html) for more details.
13
10
14
-

11
+

15
12
16
13
## Code of CWE-20 in diva.apk
17
14
18
-
We use the [diva.apk](https://github.com/payatu/diva-android) sample to
19
-
explain the vulnerability code of CWE-20.
15
+
We use the [diva.apk](https://github.com/payatu/diva-android) sample to explain the vulnerability code of CWE-20.
20
16
21
-

17
+

22
18
23
-
## Quark Script CWE-20.py
19
+
## CWE-20 Detection Process Using Quark Script API
20
+
21
+

22
+
23
+
Let’s use the above APIs to show how the Quark script finds this vulnerability.
24
24
25
-
Let's use the above APIs to show how the Quark script finds this
26
-
vulnerability.
25
+
First, we design a detection rule ``openUrlThatUserInput.json``, to spot the behavior of opening the URL that the user inputs. Then, we use API ``behaviorInstance.getMethodsInArgs()`` to get a list of methods that the URL in ``loadUrl`` passes through. Finally, we check if any validation method is in the list. If No, the APK does not validate user input. That causes CWE-20 vulnerability.
27
26
28
-
First, we design a detection rule `openUrlThatUserInput.json`, to spot
29
-
the behavior of opening the URL that the user inputs. Then, we use API
30
-
`behaviorInstance.getMethodsInArgs()` to get a list of methods that the
31
-
URL in `loadUrl` passes through. Finally, we check if any validation
32
-
method is in the list. If No, the APK does not validate user input. That
33
-
causes CWE-20 vulnerability.
27
+
## Quark Script CWE-20.py
28
+
29
+

34
30
35
-
```python
31
+
```python
36
32
from quark.script import runQuarkAnalysis, Rule
37
33
38
34
SAMPLE_PATH="diva.apk"
@@ -54,7 +50,9 @@ for openUrl in result.behaviorOccurList:
54
50
55
51
## Quark Rule: openUrlThatUserInput.json
56
52
57
-
```json
53
+

54
+
55
+
```json
58
56
{
59
57
"crime": "Open the Url that user input",
60
58
"permission": [],
@@ -77,7 +75,7 @@ for openUrl in result.behaviorOccurList:
77
75
78
76
## Quark Script Result
79
77
80
-
```TEXT
78
+
```
81
79
$ python CWE-20.py
82
80
CWE-20 is detected in method, Ljakhar/aseem/diva/InputValidation2URISchemeActivity; get (Landroid/view/View;)V
0 commit comments