Skip to content

Commit c0ad931

Browse files
authored
Optimize the CWE-73 document (ev-flow#644)
* Optimize the CWE-73 document * Optimize the CWE-73 document * Optimize the CWE-73 document
1 parent 7e6ff15 commit c0ad931

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

docs/source/quark_script.rst

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,22 +2089,38 @@ Quark Script Result
20892089
CWE-925 is detected in method, Lowasp/sat/agoat/ShowDataReceiver;
20902090
CWE-925 is detected in method, Lcom/android/insecurebankv2/MyBroadCastReceiver;
20912091
2092-
Detect CWE-73 in Android Application (ovaa.apk)
2093-
---------------------------------------------------
2092+
Detect CWE-73 in Android Application
2093+
-------------------------------------
20942094

2095-
This scenario seeks to find **External Control of File Name or Path**. See
2096-
`CWE-73 <https://cwe.mitre.org/data/definitions/73.html>`__ for more
2097-
details.
2095+
This scenario seeks to find **External Control of File Name or Path** in the APK file.
2096+
2097+
CWE-73 External Control of File Name or Path
2098+
=============================================
2099+
2100+
We analyze the definition of CWE-73 and identify its characteristics.
2101+
2102+
See `CWE-73 <https://cwe.mitre.org/data/definitions/73.html>`_ for more details.
2103+
2104+
.. image:: https://imgur.com/ES7xg5X.png
2105+
2106+
Code of CWE-73 in ovaa.apk
2107+
===========================
2108+
2109+
We use the `ovaa.apk <https://github.com/oversecured/ovaa>`_ sample to explain the vulnerability code of CWE-73.
2110+
2111+
.. image:: https://imgur.com/9oa1HIC.png
2112+
2113+
Quark Scipt: CWE-73.py
2114+
=======================
2115+
2116+
Let’s use the above APIs to show how Quark script find this vulnerability.
20982117

20992118
First, we design a detection rule ``accessFileInExternalDir.json`` to spot behavior accessing a file in an external directory.
21002119

21012120
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.
21022121

21032122
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.
21042123

2105-
Quark Script CWE-73.py
2106-
=======================
2107-
21082124
.. code:: python
21092125
21102126
from quark.script import runQuarkAnalysis, Rule

0 commit comments

Comments
 (0)