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
We analyze the definition of CWE-22 and identify its characteristics.
1791
1791
1792
1792
See `CWE-22 <https://cwe.mitre.org/data/definitions/22.html>`_ for more details.
1793
1793
1794
-
.. image:: https://imgur.com/agRPwp8.png
1794
+
.. image:: https://imgur.com/XnOUZsV.png
1795
1795
1796
1796
Code of CWE-22 in ovaa.apk
1797
-
===============================
1797
+
===========================
1798
1798
1799
1799
We use the `ovaa.apk <https://github.com/oversecured/ovaa>`_ sample to explain the vulnerability code of CWE-22.
1800
1800
1801
-
.. image:: https://imgur.com/WFpfzFk.png
1801
+
.. image:: https://imgur.com/bgWgeT7.png
1802
1802
1803
+
CWE-22 Detection Process Using Quark Script API
1804
+
================================================
1803
1805
1804
-
Quark Script: CWE-22.py
1805
-
=========================
1806
+
.. image:: https://imgur.com/N69bQK2.png
1806
1807
1807
1808
Let’s use the above APIs to show how the Quark script finds this vulnerability.
1808
1809
1809
1810
First, we design a detection rule ``accessFileInExternalDir.json`` to spot behavior accessing a file in an external directory.
1810
1811
1811
-
Next, 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.
1812
+
Next, 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.
1813
+
1814
+
Finally, we use Quark API ``quarkResultInstance.findMethodInCaller(callerMethod, targetMethod)`` to check if there are any APIs in the caller method for string matching. If **NO**, the APK does not neutralize special elements within the argument, which may cause CWE-22 vulnerability.
1812
1815
1813
-
Finally, we use Quark API ``quarkResultInstance.findMethodInCaller(callerMethod, targetMethod)`` to check if there are any APIs in the caller method for string matching. If NO, the APK does not neutralize special elements within the argument, which may cause CWE-22 vulnerability.
1816
+
Quark Scipt: CWE-22.py
1817
+
=======================
1818
+
1819
+
.. image:: https://imgur.com/4b2e4tN.png
1814
1820
1815
1821
.. code-block:: python
1816
1822
@@ -1832,24 +1838,26 @@ Finally, we use Quark API ``quarkResultInstance.findMethodInCaller(callerMethod,
CWE-22 is detected in method, Loversecured/ovaa/providers/TheftOverwriteProvider; openFile (Landroid/net/Uri; Ljava/lang/String;)Landroid/os/ParcelFileDescriptor;
0 commit comments