Skip to content

Commit 849b749

Browse files
authored
Merge pull request #84 from MobSF/qa
New rules and version bump
2 parents 35b2016 + 9ab7b0d commit 849b749

File tree

9 files changed

+83
-6
lines changed

9 files changed

+83
-6
lines changed

mobsfscan/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
__title__ = 'mobsfscan'
77
__authors__ = 'Ajin Abraham'
88
__copyright__ = f'Copyright {datetime.now().year} Ajin Abraham, OpenSecurity'
9-
__version__ = '0.3.8'
9+
__version__ = '0.3.9'
1010
__version_info__ = tuple(int(i) for i in __version__.split('.'))
1111
__all__ = [
1212
'__title__',

mobsfscan/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from mobsfscan.mobsfscan import MobSFScan
99
from mobsfscan.formatters import (
1010
cli,
11-
json,
11+
json_fmt,
1212
sarif,
1313
sonarqube,
1414
)
@@ -87,7 +87,7 @@ def main():
8787
scan_results,
8888
__version__)
8989
elif args.json:
90-
json.json_output(
90+
json_fmt.json_output(
9191
args.output,
9292
scan_results,
9393
__version__)
File renamed without changes.

mobsfscan/formatters/sonarqube.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf_8 -*-
22
"""Sonarqube output format."""
33

4-
from mobsfscan.formatters.json import json_output
4+
from mobsfscan.formatters.json_fmt import json_output
55

66

77
def get_sonarqube_issue(mobsfscan_issue):

mobsfscan/manifest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
5454
'33': '13',
5555
'34': '14',
5656
'35': '15',
57+
'36': '16',
58+
'37': '17', # Guess work
59+
'38': '18',
60+
'39': '19',
61+
'40': '20',
5762
}
5863

5964

mobsfscan/rules/patterns/android/kotlin/kotlin_rules.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@
8080
owasp-mobile: m1
8181
masvs: platform-7
8282
reference: https://github.com/MobSF/owasp-mstg/blob/master/Document/0x05h-Testing-Platform-Interaction.md#testing-javascript-execution-in-webviews-mstg-platform-5
83+
- id: android_kotlin_webview_allow_file_from_url
84+
message: >-
85+
Ensure that user controlled URLs never reaches the Webview. Enabling file access
86+
from URLs in WebView can leak sensitive information from the file system.
87+
type: RegexAndOr
88+
pattern:
89+
- setJavaScriptEnabled\(true\)
90+
- - \.setAllowFileAccessFromFileURLs\(true\)
91+
- \.setAllowUniversalAccessFromFileURLs\(true\)
92+
severity: warning
93+
input_case: exact
94+
metadata:
95+
cvss: 6.1
96+
cwe: cwe-200
97+
owasp-mobile: m1
98+
masvs: platform-7
99+
ref: https://github.com/MobSF/owasp-mstg/blob/master/Document/0x05h-Testing-Platform-Interaction.md#static-analysis-6
83100
- id: android_kotlin_webview_debug
84101
message: Remote WebView debugging is enabled.
85102
type: RegexAnd
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
rules:
2+
- id: webview_allow_file_from_url
3+
patterns:
4+
- pattern-either:
5+
- pattern: |
6+
setAllowFileAccessFromFileURLs(true)
7+
- pattern: |
8+
$W.setAllowFileAccessFromFileURLs(true)
9+
- pattern: |
10+
$X = true;
11+
...
12+
$W.setAllowFileAccessFromFileURLs($X);
13+
- pattern: |
14+
setAllowUniversalAccessFromFileURLs(true)
15+
- pattern: |
16+
$W.setAllowUniversalAccessFromFileURLs(true)
17+
- pattern: |
18+
$X = true;
19+
...
20+
$W.setAllowUniversalAccessFromFileURLs($X);
21+
message: >-
22+
Ensure that user controlled URLs never reaches the Webview. Enabling file access
23+
from URLs in WebView can leak sensitive information from the file system.
24+
languages:
25+
- java
26+
severity: WARNING
27+
metadata:
28+
cwe: cwe-200
29+
owasp-mobile: m1
30+
masvs: platform-7
31+
reference: >-
32+
https://github.com/MobSF/owasp-mstg/blob/master/Document/0x05h-Testing-Platform-Interaction.md#static-analysis-6
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
package com.company.something;
3+
4+
import android.app.Activity;
5+
import android.os.Bundle;
6+
import android.webkit.WebView;
7+
8+
public class HelloWebApp extends Activity {
9+
/** Called when the activity is first created. */
10+
@Override
11+
public void onCreate(Bundle savedInstanceState) {
12+
super.onCreate(savedInstanceState);
13+
setContentView(R.layout.main);
14+
WebView webView = (WebView)findViewById(R.id.webView);
15+
String badUrl = getIntent().getStringExtra("URL");
16+
WebSettings webSettings = webView.getSettings();
17+
webSettings.setJavaScriptEnabled(true);
18+
// ruleid:webview_allow_file_from_url
19+
webSettings.setAllowFileAccessFromFileURLs(true);
20+
webView.setWebChromeClient(new WebChromeClient());
21+
webView.loadUrl(badUrl);
22+
}
23+
}

tests/unit/test_mobsfscan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
)
66

77
from mobsfscan.formatters import (
8-
json,
8+
json_fmt,
99
sarif,
1010
sonarqube,
1111
)
@@ -36,7 +36,7 @@ def test_patterns_and_semgrep():
3636

3737

3838
def json_output(res):
39-
json_out = json.json_output(None, res, '0.0.0')
39+
json_out = json_fmt.json_output(None, res, '0.0.0')
4040
assert json_out is not None
4141

4242

0 commit comments

Comments
 (0)