Java


JAVA.IO.INJ.FRAGMENT : Fragment Injection (Java)

要旨

Tainted data might flow into a fragment execution.

プロパティ

クラス名 Fragment Injection (Java)
日本語クラス名 Fragment Injection (Java)
クラス分類 セキュリティ (security)
ニーモニック JAVA.IO.INJ.FRAGMENT
カテゴリー
CWE CWE:470 Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection')
OWASP-2017 OWASP-2017:A1 Injection
  OWASP-2017:A5 Broken access control
OWASP-2021 OWASP-2021:A1 Broken access control
  OWASP-2021:A3 Injection
対応言語 Java で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Fragment Injection (Java)"

// UncontrolledFragment1.java 
package com.juliasoft.julia.tests.checks.useOfUncontrolledExternalData;

import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.webkit.WebView;

public class UncontrolledFragment1 extends PreferenceActivity  // Missing isValidFragment Override (Java) warning issued here
{
  WebView mWebView;
      
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      final String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
      final Fragment f = Fragment.instantiate(this, initialFragment, null);
      final FragmentTransaction transaction = getFragmentManager().beginTransaction();
      transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
      transaction.replace(11, f);
      transaction.commitAllowingStateLoss();                   // Fragment Injection (Java) warning issued here
  }
}
// UncontrolledFragment2.java 
package com.juliasoft.julia.tests.checks.useOfUncontrolledExternalData;

import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.webkit.WebView;

public class UncontrolledFragment2 extends PreferenceActivity
{
  WebView mWebView;
      
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      final String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
      if(isValidFragment(initialFragment)) {
          final Fragment f = Fragment.instantiate(this, initialFragment, null);
          final FragmentTransaction transaction = getFragmentManager().beginTransaction();
          transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
          transaction.replace(11, f);
          transaction.commitAllowingStateLoss();
      }
  }

  @Override
  protected boolean isValidFragment(String fragmentName) {
      return true;                                             // Ineffective Cleansing of Fragment Taint (Java) warning issued here
  }
}

The warnings in this example are all relative to external fragments and their validation. The external fragments without or with a wrong validation could lead to security issues. As described in the Android API documentation for isValidFragment(), subclasses of PreferenceActivity should override the isValidFragment() method and verify that the given fragment is a valid type to be attached to this activity.

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

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