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: docs/source/quark_script.rst
+34-24Lines changed: 34 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2254,8 +2254,9 @@ Quark Script Result
2254
2254
CWE-925 is detected in method, Lcom/android/insecurebankv2/MyBroadCastReceiver;
2255
2255
2256
2256
2257
+
2257
2258
Detect CWE-73 in Android Application
2258
-
-------------------------------------
2259
+
--------------------------------------
2259
2260
2260
2261
This scenario seeks to find **External Control of File Name or Path** in the APK file.
2261
2262
@@ -2266,36 +2267,43 @@ We analyze the definition of CWE-73 and identify its characteristics.
2266
2267
2267
2268
See `CWE-73 <https://cwe.mitre.org/data/definitions/73.html>`_ for more details.
2268
2269
2269
-
.. image:: https://imgur.com/ES7xg5X.png
2270
+
.. image:: https://imgur.com/I1C5yku.png
2270
2271
2271
2272
Code of CWE-73 in ovaa.apk
2272
2273
===========================
2273
2274
2274
2275
We use the `ovaa.apk <https://github.com/oversecured/ovaa>`_ sample to explain the vulnerability code of CWE-73.
2275
2276
2276
-
.. image:: https://imgur.com/9oa1HIC.png
2277
+
.. image:: https://imgur.com/gLJ6zWr.png
2277
2278
2278
-
Quark Script: CWE-73.py
2279
-
=======================
2279
+
CWE-73 Detection Process Using Quark Script API
2280
+
================================================
2280
2281
2281
-
Let’s use the above APIs to show how Quark script find this vulnerability.
2282
+
.. image:: https://imgur.com/zGjZHA1.png
2282
2283
2283
-
First, we design a detection rule ``accessFileInExternalDir.json`` to spot behavior accessing a file in an external directory.
2284
+
Let’s use the above APIs to show how Quark script finds this vulnerability.
2284
2285
2285
-
Second, we use API ``methodInstance.getArguments()`` to get the argument for the file path and use ``quarkResultInstance.isHardcoded(argument)`` to check if the argument is hardcoded into the APK. If **No**, the argument is from external input.
2286
+
First, we design a detection rule ``useLastPathSegmentAsFileName.json`` to spot behavior that uses the last path segment as the file name.
2286
2287
2287
-
Finally, we use Quark API ``quarkResultInstance.findMethodInCaller(callerMethod, targetMethod)`` to check if any APIs in the caller method for opening files. If **YES**, the APK performs file operations using external input as a path, which may cause CWE-73 vulnerability.
2288
+
Second, we use the API ``methodInstance.getArguments()`` to get the argument for the file path and use ``quarkResultInstance.isHardcoded(argument)`` to check if the argument is hardcoded into the APK. If **No**, the argument is from external input.
2288
2289
2289
-
.. code:: python
2290
+
Finally, we use Quark API ``quarkResultInstance.findMethodInCaller(callerMethod, targetMethod)`` to check if there are any APIs in the caller method for opening files. If **YES**, the APK performs file operations using external input as a path, which may cause CWE-73 vulnerability.
CWE-73 is detected in method, Loversecured/ovaa/providers/TheftOverwriteProvider; openFile (Landroid/net/Uri; Ljava/lang/String;)Landroid/os/ParcelFileDescriptor;
2348
-
2356
+
$ python CWE-73.py
2357
+
CWE-73 is detected in method, Loversecured/ovaa/providers/TheftOverwriteProvider; openFile (Landroid/net/Uri; Ljava/lang/String;)Landroid/os/ParcelFileDescriptor;
0 commit comments