@@ -2108,17 +2108,19 @@ We analyze the definition of CWE-88 and identify its characteristics.
2108
2108
2109
2109
See `CWE-88 <https://cwe.mitre.org/data/definitions/88.html >`_ for more details.
2110
2110
2111
- .. image :: https://imgur.com/7EBPGUT .png
2111
+ .. image :: https://imgur.com/5vfXkIE .png
2112
2112
2113
2113
Code of CWE-88 in vuldroid.apk
2114
- =========================================
2114
+ ===============================
2115
2115
2116
2116
We use the `vuldroid.apk <https://github.com/jaiswalakshansh/Vuldroid >`_ sample to explain the vulnerability code of CWE-88.
2117
2117
2118
- .. image :: https://imgur.com/emnvGcE .png
2118
+ .. image :: https://imgur.com/recX0t5 .png
2119
2119
2120
- Quark Script: CWE-88.py
2121
- ========================
2120
+ CWE-88 Detection Process Using Quark Script API
2121
+ ================================================
2122
+
2123
+ .. image :: https://imgur.com/s7Ajr6M.png
2122
2124
2123
2125
Let‘s use the above APIs to show how the Quark script finds this vulnerability.
2124
2126
@@ -2130,44 +2132,50 @@ Then we check if the method neutralizes any special elements in the argument.
2130
2132
2131
2133
If the neutralization is not complete, then it may cause CWE-88 vulnerability.
2132
2134
2135
+ Quark Script: CWE-88.py
2136
+ ========================
2137
+
2138
+ .. image :: https://imgur.com/f8Yee3P.png
2139
+
2133
2140
.. code-block :: python
2134
2141
2135
2142
from quark.script import runQuarkAnalysis, Rule, findMethodInAPK
2136
2143
2137
- SAMPLE_PATH = " Vuldroid.apk"
2138
- RULE_PATH = " ExternalStringCommand.json"
2144
+ SAMPLE_PATH = " Vuldroid.apk"
2145
+ RULE_PATH = " ExternalStringCommand.json"
2139
2146
2140
2147
2141
- STRING_MATCHING_API = set ([
2142
- (" Ljava/lang/String;" , " contains" , " (Ljava/lang/CharSequence)Z" ),
2143
- (" Ljava/lang/String;" , " indexOf" , " (I)I" ),
2144
- (" Ljava/lang/String;" , " indexOf" , " (Ljava/lang/String;)I" ),
2145
- (" Ljava/lang/String;" , " matches" , " (Ljava/lang/String;)Z" ),
2146
- (" Ljava/lang/String;" , " replaceAll" , " (Ljava/lang/String; Ljava/lang/String;)Ljava/lang/String;" )
2147
- ])
2148
+ STRING_MATCHING_API = set ([
2149
+ (" Ljava/lang/String;" , " contains" , " (Ljava/lang/CharSequence)Z" ),
2150
+ (" Ljava/lang/String;" , " indexOf" , " (I)I" ),
2151
+ (" Ljava/lang/String;" , " indexOf" , " (Ljava/lang/String;)I" ),
2152
+ (" Ljava/lang/String;" , " matches" , " (Ljava/lang/String;)Z" ),
2153
+ (" Ljava/lang/String;" , " replaceAll" , " (Ljava/lang/String; Ljava/lang/String;)Ljava/lang/String;" )
2154
+ ])
2148
2155
2149
- delimeter = " -"
2156
+ delimeter = " -"
2150
2157
2151
- ruleInstance = Rule(RULE_PATH )
2152
- quarkResult = runQuarkAnalysis(SAMPLE_PATH , ruleInstance)
2158
+ ruleInstance = Rule(RULE_PATH )
2159
+ quarkResult = runQuarkAnalysis(SAMPLE_PATH , ruleInstance)
2153
2160
2154
- for ExternalStringCommand in quarkResult.behaviorOccurList:
2161
+ for ExternalStringCommand in quarkResult.behaviorOccurList:
2155
2162
2156
- methodCalled = set ()
2157
- caller = ExternalStringCommand.methodCaller
2163
+ methodCalled = set ()
2164
+ caller = ExternalStringCommand.methodCaller
2158
2165
2159
- for method in ExternalStringCommand.getMethodsInArgs():
2160
- methodCalled.add(method.fullName)
2166
+ for method in ExternalStringCommand.getMethodsInArgs():
2167
+ methodCalled.add(method.fullName)
2161
2168
2162
- if methodCalled.intersection(STRING_MATCHING_API ) and not ExternalStringCommand.hasString(delimeter):
2163
- continue
2164
- else :
2165
- print (f " CWE-88 is detected in method, { caller.fullName} " )
2169
+ if methodCalled.intersection(STRING_MATCHING_API ) and not ExternalStringCommand.hasString(delimeter):
2170
+ continue
2171
+ else :
2172
+ print (f " CWE-88 is detected in method, { caller.fullName} " )
2166
2173
2167
2174
2168
-
2169
2175
Quark Rule: ExternalStringCommand.json
2170
- =========================================
2176
+ =======================================
2177
+
2178
+ .. image :: https://imgur.com/s9QNF19.png
2171
2179
2172
2180
.. code-block :: json
2173
2181
@@ -2190,16 +2198,16 @@ Quark Rule: ExternalStringCommand.json
2190
2198
"label" : []
2191
2199
}
2192
2200
2193
-
2194
2201
Quark Script Result
2195
- ======================
2202
+ ====================
2196
2203
2197
2204
.. code-block :: TEXT
2198
2205
2199
2206
$ python3 CWE-88.py
2200
2207
CWE-88 is detected in method, Lcom/vuldroid/application/RootDetection; onCreate (Landroid/os/Bundle;)V
2201
2208
2202
2209
2210
+
2203
2211
Detect CWE-925 in Android Application
2204
2212
--------------------------------------
2205
2213
0 commit comments