Java


JAVA.JS.UAFU : Universal JavaScript Access to File URLs (Java)

要旨

Access to a file scheme URL from any origin is enabled by default.

Android 4.1 (androidAPI16) and later provide methods android.webkit.WebSettings.WebSettings.setAllowUniversalAccessFromFileURLs() and android.webkit.WebSettings.WebSettings.setAllowFileAccessFromFileURLs(). When JavaScript is running in the context of a file scheme URL, these methods can be used to enable/disable access to content from, respectively, other file scheme URLs and any origin (including other file scheme URLs). The Android API documentation for setAllowFileAccessFromFileURLs() recommends disabling these settings to enable the most restrictive, and therefore secure, policy.

Android 4.0.4 (androidAPI15) and earlier permit access to potentially untrusted content by default, through the android.webkit.WebSettings.WebSettings of android.webkit.WebView. For more information, see the Android API documentation for setAllowUniversalAccessFromFileURLs().

プロパティ

クラス名 Universal JavaScript Access to File URLs (Java)
日本語クラス名 Universal JavaScript Access to File URLs (Java)
クラス分類 セキュリティ (security)
ニーモニック JAVA.JS.UAFU
カテゴリー
CWE CWE:749 Exposed Dangerous Method or Function
対応言語 Java で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Universal JavaScript Access to File URLs (Java)"

package example.javascriptExecutionChecker;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class JavascriptExecutionExample {

  public class Test1 extends Activity  {
    WebView mWebView;

    public void onCreate(Bundle paramBundle)
    {
        super.onCreate(paramBundle);
        this.mWebView = new WebView(this); // "Universal JavaScript Access to File URLs (Java)" warning issued here 
        this.mWebView.getSettings().setAllowFileAccessFromFileURLs(true); 
        setContentView(this.mWebView);
    }
  }
  
  public class Test2 extends Activity  {
    WebView mWebView;
    
    public void onCreate(Bundle paramBundle)
    {
        super.onCreate(paramBundle);
        this.mWebView = new WebView(this);
        this.mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true); /* "Universal JavaScript Access to File URLs (Java)" 
                                                       * warning issued here for Android API version 16 or later 
                                                       */ 
        setContentView(this.mWebView);
    }
  }
}
package example.javascriptExecutionChecker;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class JavascriptExecutionExample {

  public class Test1 extends Activity  {
      WebView mWebView;
    
      public void onCreate(Bundle paramBundle)
      {
            super.onCreate(paramBundle);
            this.mWebView = new WebView(this); /* "Universal JavaScript Access to File URLs (Java)" 
                                                       * warning issued here for Android API version 15 or earlier 
                                                       */ 
                                                                              
            setContentView(this.mWebView);
      }

  }
}
import android.os.Bundle;
import android.webkit.WebView;

public class MyClass  {
  WebView mWebView;

  public MyClass(WebView view)
  {
      this.mWebView = view; 
      this.mWebView.getSettings().setAllowFileAccessFromFileURLs(true); /* "Universal JavaScript Access to File URLs (Java)" 
                                                       * warning issued here for Android API version 16 or later 
                                                       */ 
  }
}
import android.os.Bundle;
import android.webkit.WebView;

public class AnotherMyClass  {
  WebView mWebView;

  public AnotherMyClass(WebView view)
  {
      this.mWebView = view; 
      this.mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true); /* "Universal JavaScript Access to File URLs (Java)" 
                                                       * warning issued here for Android API version 16 or later 
                                                       */ 
  }
}

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。