JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
Java


JAVA.IO.TAINT.IC.FRAGMENT : Ineffective Cleansing of Fragment Taint (Java)

要旨

A method that always returns true is used to perform fragment validation.

プロパティ

クラス名 Ineffective Cleansing of Fragment Taint (Java)
日本語クラス名 Ineffective Cleansing of Fragment Taint (Java)
クラス分類 セキュリティ (security)
ニーモニック JAVA.IO.TAINT.IC.FRAGMENT
カテゴリー
CWE CWE:287 Improper Authentication
対応言語 Available for Java and Kotlin.
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Ineffective Cleansing of Fragment Taint (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.

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

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

 

To report problems with this documentation, please visit https://support.codesecure.com/.