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
+71-60Lines changed: 71 additions & 60 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1891,7 +1891,7 @@ Quark Script Result
1891
1891
1892
1892
1893
1893
Detect CWE-23 in Android Application
1894
-
--------------------------------------
1894
+
-------------------------------------
1895
1895
1896
1896
This scenario aims to demonstrate the detection of the **Relative Path Traversal** vulnerability.
1897
1897
@@ -1902,99 +1902,110 @@ We analyze the definition of CWE-23 and identify its characteristics.
1902
1902
1903
1903
See `CWE-23 <https://cwe.mitre.org/data/definitions/23.html>`_ for more details.
1904
1904
1905
-
.. image:: https://imgur.com/YS9umQp.png
1905
+
.. image:: https://imgur.com/k4UPsKO.png
1906
1906
1907
1907
Code of CWE-23 in ovaa.apk
1908
-
============================
1908
+
===========================
1909
1909
1910
1910
We use the `ovaa.apk <https://github.com/oversecured/ovaa>`_ sample to explain the vulnerability code of CWE-23.
1911
1911
1912
-
.. image:: https://imgur.com/GosANyj.png
1912
+
.. image:: https://imgur.com/KT277GG.png
1913
1913
1914
-
Quark Script: CWE-23.py
1915
-
========================
1914
+
CWE-23 Detection Process Using Quark Script API
1915
+
================================================
1916
+
1917
+
.. image:: https://imgur.com/D852ZLV.png
1916
1918
1917
1919
Let’s use the above APIs to show how the Quark script finds this vulnerability.
1918
1920
1919
-
To begin with, we will create a detection rule named ``accessFileInExternalDir.json`` to identify behavior that accesses a file in an external directory.
1921
+
To begin with, we create a detection rule named ``accessFileInExternalDir.json`` to identify behavior that accesses a file in an external directory.
1920
1922
1921
-
Next, we will use ``methodInstance.getArguments()`` to retrieve the file path argument and check whether it belongs to the APK or not. If it does not belong to the APK, the argument is likely from external input.
1923
+
Next, we use ``methodInstance.getArguments()`` to retrieve the file path argument and check whether it belongs to the APK. If it does not belong to the APK, the argument is likely from external input.
1922
1924
1923
-
Finally, we will use the Quark API ``quarkResultInstance.findMethodInCaller(callerMethod, targetMethod)`` to search for any APIs in the caller method that match the string. If no matching API is found, the APK does not neutralize special elements within the argument, which may result in the CWE-23 vulnerability. If a matching API is found, we will verify whether it neutralizes the Relative Path string or not. If it does not neutralize it, the APK may still be vulnerable to CWE-23.
1925
+
Then, we use the Quark Script API ``quarkResultInstance.findMethodInCaller(callerMethod, targetMethod)`` to search for any APIs in the caller method that are used to match strings. If no API is found, that implies the APK does not neutralize special elements within the argument, possibly resulting in CWE-23 vulnerability.
CWE-23 is detected in method, Loversecured/ovaa/providers/TheftOverwriteProvider; openFile (Landroid/net/Uri; Ljava/lang/String;)Landroid/os/ParcelFileDescriptor;
2003
+
$ python3 CWE-23.py
2004
+
CWE-23 is detected in method, Loversecured/ovaa/providers/TheftOverwriteProvider; openFile (Landroid/net/Uri; Ljava/lang/String;)Landroid/os/ParcelFileDescriptor;
0 commit comments