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.PERM : Permissive File Mode (Java)

要旨

A file is world-readable or world-writable.

プロパティ

クラス名 Permissive File Mode (Java)
日本語クラス名 Permissive File Mode (Java)
クラス分類 セキュリティ (security)
ニーモニック JAVA.IO.PERM
カテゴリー
CWE CWE:732 Incorrect Permission Assignment for Critical Resource
CERT-Java CERT-Java:ENV03-J Do not grant dangerous combinations of permissions
  CERT-Java:FIO01-J Create files with appropriate access permissions
  CERT-Java:SEC01-J Do not allow tainted variables in privileged blocks
OWASP-2017 OWASP-2017:A5 Broken access control
OWASP-2021 OWASP-2021:A1 Broken access control
OWASP-2025 OWASP-2025:A01 Broken Access Control
対応言語 Available for Java and Kotlin.
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Permissive File Mode (Java)"

// MainActivity.java
package example.fileaccessexample;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class MainActivity extends AppCompatActivity {

  private static final String TAG = "MainActivity";

  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      try {

            FileOutputStream fileOutputStream1 = openFileOutput("foo.txt", Context.MODE_WORLD_READABLE);  // Accessing File in Permissive Mode (Java) warning issued here 
            FileOutputStream fileOutputStream2 = openFileOutput("foo.txt", Context.MODE_WORLD_WRITEABLE); // Accessing File in Permissive Mode (Java) warning issued here 

        } catch (FileNotFoundException | SecurityException e) {
            e.printStackTrace();
        }
      extendAccessPermission(new File("myfile.txt"));
  }

  public  void extendAccessPermission(File f) {
      if ( !f.setReadable( true , false )) {           // Permissive File Mode (Java) warning issued here 
          Log.e(TAG,"Unable to set readable permission");
      }

      if ( !f.setWritable( true , false )) {           // Permissive File Mode (Java) warning issued here 
          Log.e(TAG,"Unable to set writable permission");
      }
  }
}

解決法

Android's security design philosophy recommends the use of files only for the purpose of perpetuating or temporarily storing information. In principle the file access permissions should be private, in order to limit the risk of information leakage.

The Android API documentation includes guidelines for securely sharing files.

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

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

 

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