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
See [CWE-295](https://cwe.mitre.org/data/definitions/295.html) for more details.
18
10
19
-
Then we use the API `methodInstance.findSuperclassHierarchy()` to get
20
-
the superclass list of the method's caller class.
11
+

21
12
22
-
Finally, we check the `Landroid/webkit/WebViewClient;` is on the
23
-
superclass list. If **YES**, that may cause CWE-295 vulnerability.
13
+
## Code of CWE-295 in InsecureShop.apk
14
+
15
+
We use the [InsecureShop.apk](https://github.com/hax0rgb/InsecureShop) sample to explain the vulnerability code of CWE-295.
16
+
17
+

24
18
25
19
## Quark Script CWE-295.py
26
20
27
-
```python
21
+
To begin with, we use the API ``findMethodInAPK(samplePath, targetMethod)`` to locate all callers of method ``SslErrorHandler.proceed``.
22
+
23
+
Next, we must verify whether the caller overrides the method ``WebViewClient.onReceivedSslErroris``.
24
+
25
+
Therefore, we check if the method name and descriptor of the caller match those of ``WebViewClient.onReceivedSslErroris``. After that, we use the API ``methodInstance.findSuperclassHierarchy()`` to check if the superclasses of the caller include ``Landroid/webkit/WebViewClient``.
26
+
27
+
If both are **YES**, the APK will call ``SslErrorHandler.procees`` without certificate validation when an SSL error occurs, which may cause CWE-295 vulnerability.
for sslProceedCaller in findMethodInAPK(SAMPLE_PATH, TARGET_METHOD):
44
-
if (sslProceedCaller.name ==OVERRIDE_METHOD[1] and
45
-
sslProceedCaller.descriptor ==OVERRIDE_METHOD[2] and
46
-
OVERRIDE_METHOD[0] in sslProceedCaller.findSuperclassHierarchy()):
46
+
if (
47
+
sslProceedCaller.name ==OVERRIDDEN_METHOD[1]
48
+
and sslProceedCaller.descriptor ==OVERRIDDEN_METHOD[2]
49
+
andOVERRIDDEN_METHOD[0] in sslProceedCaller.findSuperclassHierarchy()
50
+
):
47
51
print(f"CWE-295 is detected in method, {sslProceedCaller.fullName}")
48
52
```
49
53
50
54
## Quark Script Result
51
55
52
-
```TEXT
56
+
```TEXT
53
57
$ python3 CWE-295.py
54
-
Requested API level 29 is larger than maximum we have, returning API level 28 instead.
55
58
CWE-295 is detected in method, Lcom/insecureshop/util/CustomWebViewClient; onReceivedSslError (Landroid/webkit/WebView; Landroid/webkit/SslErrorHandler; Landroid/net/http/SslError;)V
0 commit comments