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-117/README.md
+20-19Lines changed: 20 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,30 @@
1
-
# Detect CWE-117 in Android Application (allsafe.apk)
2
-
1
+
# Detect CWE-117 in Android Application
3
2
4
3
This scenario seeks to find **Improper Output Neutralization for Logs**.
5
-
See [CWE-117](https://cwe.mitre.org/data/definitions/117.html) for more
6
-
details.
7
4
8
-
Let's use this [APK](https://github.com/t0thkr1s/allsafe) and the above
9
-
APIs to show how the Quark script finds this vulnerability.
5
+
## CWE-117: Improper Output Neutralization for Logs
6
+
7
+
We analyze the definition of CWE-117 and identify its characteristics.
8
+
9
+
See [CWE-117](https://cwe.mitre.org/data/definitions/117.html) for more details.
10
+
11
+

10
12
11
-
First, we design a detection rule `writeContentToLog.json` to spot on
12
-
behavior using the method that writes contents to the log file.
13
+
## Code of CWE-117 in allsafe.apk
13
14
14
-
Then, we use `methodInstance.getArguments()` to get all parameter values
15
-
of this method. And we check if these parameters contain keywords of
16
-
APIs for neutralization, such as `escape`, `replace`, `format`, and
17
-
`setFilter`.
15
+
We use the [allsafe.apk](https://github.com/t0thkr1s/allsafe) sample to explain the vulnerability code of CWE-117.
18
16
19
-
If the answer is **YES**, that may result in secret context leakage into
20
-
the log file, or the attacker may perform log forging attacks.
17
+

21
18
22
19
## Quark Script CWE-117.py
23
20
24
-
```python
21
+
First, we design a detection rule ``writeContentToLog.json`` to spot on behavior using the method that writes contents to the log file.
22
+
23
+
Then, we use ``methodInstance.getArguments()`` to get all parameter values of this method. And we check if these parameters contain keywords of APIs for neutralization, such as ``escape``, ``replace``, ``format``, and ``setFilter``.
24
+
25
+
If the answer is **YES**, that may result in secret context leakage into the log file, or the attacker may perform log forging attacks.
26
+
27
+
```python
25
28
from quark.script import Rule, runQuarkAnalysis
26
29
27
30
SAMPLE_PATH="allsafe.apk"
@@ -48,7 +51,7 @@ for logOutputBehavior in quarkResult.behaviorOccurList:
48
51
49
52
## Quark Rule: writeContentToLog.json
50
53
51
-
```json
54
+
```json
52
55
{
53
56
"crime": "Write contents to the log.",
54
57
"permission": [],
@@ -71,9 +74,7 @@ for logOutputBehavior in quarkResult.behaviorOccurList:
71
74
72
75
## Quark Script Result
73
76
74
-
-**allsafe.apk**
75
-
76
-
```TEXT
77
+
```TEXT
77
78
$ python CWE-117.py
78
79
CWE-117 is detected in method, Linfosecadventures/allsafe/challenges/InsecureLogging; lambda$onCreateView$0 (Lcom/google/android/material/textfield/TextInputEditText; Landroid/widget/TextView; I Landroid/view/KeyEvent;)Z
0 commit comments