Skip to content

Commit 0429e61

Browse files
authored
Optimize the document of Quark Script CWE-79 (#738)
* Optimize the document of Quark Script CWE-79 * Optimize the document of Quark Script CWE-79 * Update pytest.yml Add version to cargo
1 parent 2eb2016 commit 0429e61

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
# Install Rust and Ares
5959
wget https://sh.rustup.rs -O install.sh
6060
sh install.sh -y
61-
cargo install project_ares
61+
cargo install project_ares@0.10.0
6262

6363
- name: Install Shuriken-Analyzer
6464
run: |

docs/source/quark_script.rst

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,30 +1471,37 @@ Detect CWE-79 in Android Application
14711471

14721472
This scenario seeks to find **Improper Neutralization of Input During Web Page Generation (‘Cross-site Scripting’)** in the APK file.
14731473

1474-
CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
1475-
============================================================================================
1474+
CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
1475+
=============================================================================================
14761476

14771477
We analyze the definition of CWE-79 and identify its characteristics.
14781478

14791479
See `CWE-79 <https://cwe.mitre.org/data/definitions/79.html>`_ for more details.
14801480

1481-
.. image:: https://imgur.com/jAwgD0x.png
1481+
.. image:: https://imgur.com/3W1QpU1.png
14821482

14831483
Code of CWE-79 in Vuldroid.apk
14841484
===============================
14851485

14861486
We use the `Vuldroid.apk <https://github.com/jaiswalakshansh/Vuldroid>`_ sample to explain the vulnerability code of CWE-79.
14871487

1488-
.. image:: https://imgur.com/lC6EKun.png
1488+
.. image:: https://imgur.com/iv3Guwi.png
14891489

1490-
Quark Script CWE-79.py
1491-
=======================
1490+
CWE-79 Detection Process Using Quark Script API
1491+
================================================
1492+
1493+
.. image:: https://imgur.com/MpUjFP0.png
14921494

14931495
Let’s use the above APIs to show how the Quark script finds this vulnerability.
14941496

14951497
First, we design a detection rule ``loadUrlFromIntent.json`` to spot the behavior loading URL from intent data to the WebView instance.
14961498

1497-
Next, we use API ``quarkResultInstance.findMethodInCaller(callerMethod, targetMethod)`` and ``methodInstance.getArguments()`` to check if the Javascript execution is enabled in the WebView. Finally, we check if there are any famous XSS filters. If NO, that may cause CWE-79 vulnerability.
1499+
Next, we use API ``quarkResultInstance.findMethodInCaller(callerMethod, targetMethod)`` and ``methodInstance.getArguments()`` to check if the Javascript execution is enabled in the WebView. Finally, we check if there are any famous XSS filters. If **NO**, that may cause CWE-79 vulnerability.
1500+
1501+
Quark Script CWE-79.py
1502+
=======================
1503+
1504+
.. image:: https://imgur.com/NyMpLZW.png
14981505

14991506
.. code-block:: python
15001507
@@ -1550,10 +1557,12 @@ Next, we use API ``quarkResultInstance.findMethodInCaller(callerMethod, targetMe
15501557
print(f"CWE-79 is detected in method, {caller.fullName}")
15511558
15521559
Quark Rule: loadUrlFromIntent.json
1553-
====================================
1560+
===================================
1561+
1562+
.. image:: https://imgur.com/m4aa4Jk.png
15541563

15551564
.. code-block:: json
1556-
1565+
15571566
{
15581567
"crime": "Load URL from intent to WebView",
15591568
"permission": [],
@@ -1573,16 +1582,16 @@ Quark Rule: loadUrlFromIntent.json
15731582
"label": []
15741583
}
15751584
1576-
15771585
Quark Script Result
1578-
===================
1586+
====================
15791587

15801588
.. code-block:: TEXT
15811589
1582-
$ python CWE-79.py
1590+
$ python CWE-79.py
15831591
CWE-79 is detected in method, Lcom/vuldroid/application/ForgetPassword; onCreate (Landroid/os/Bundle;)V
15841592
15851593
1594+
15861595
Detect CWE-328 in Android Application
15871596
--------------------------------------
15881597

0 commit comments

Comments
 (0)