-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35b2016
commit dfd1245
Showing
9 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
mobsfscan/rules/semgrep/webview/webview_allow_file_from_url.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
rules: | ||
- id: webview_allow_file_from_url | ||
patterns: | ||
- pattern-either: | ||
- pattern: | | ||
setAllowFileAccessFromFileURLs(true) | ||
- pattern: | | ||
$W.setAllowFileAccessFromFileURLs(true) | ||
- pattern: | | ||
$X = true; | ||
... | ||
$W.setAllowFileAccessFromFileURLs($X); | ||
- pattern: | | ||
setAllowUniversalAccessFromFileURLs(true) | ||
- pattern: | | ||
$W.setAllowUniversalAccessFromFileURLs(true) | ||
- pattern: | | ||
$X = true; | ||
... | ||
$W.setAllowUniversalAccessFromFileURLs($X); | ||
message: >- | ||
Ensure that user controlled URLs never reaches the Webview. Enabling file access | ||
from URLs in WebView can leak sensitive information from the file system. | ||
languages: | ||
- java | ||
severity: WARNING | ||
metadata: | ||
cwe: cwe-200 | ||
owasp-mobile: m1 | ||
masvs: platform-7 | ||
reference: >- | ||
https://github.com/MobSF/owasp-mstg/blob/master/Document/0x05h-Testing-Platform-Interaction.md#static-analysis-6 |
24 changes: 24 additions & 0 deletions
24
tests/assets/rules/semgrep/webview/webview_allow_file_from_url.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
package com.company.something; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.webkit.WebView; | ||
|
||
public class HelloWebApp extends Activity { | ||
/** Called when the activity is first created. */ | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.main); | ||
WebView webView = (WebView)findViewById(R.id.webView); | ||
String badUrl = getIntent().getStringExtra("URL"); | ||
boolean x = true; | ||
WebSettings webSettings = webView.getSettings(); | ||
webSettings.setJavaScriptEnabled(true); | ||
// ruleid:webview_allow_file_from_url | ||
webSettings.setAllowFileAccessFromFileURLs(x); | ||
webView.setWebChromeClient(new WebChromeClient()); | ||
webView.loadUrl(badUrl); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters