You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

In Android apps, if  the export value of a component is explicitly marked false, if the

it should not be possible for other apps (or, more strictly, apps with different userids) to be able to access this data. This can be ensured by creating the file, shared preference or database with MODE_PRIVATEMODE_PRIVATE is a constant defined by the class android.content.Context. It may be used as the mode parameter in the methods openFileOutput(), getSharedPreferences(), and openOrCreateDatabase() (which are all also defined in the class android.content.Context).

Noncompliant Code Example

This noncompliant code example shows an application that creates a file that is world readable, and hence not secure.

openFileOutput("someFile", MODE_WORLD_READABLE);

Any application could read the file and access any data stored in it.

Compliant Solution

In this compliant solution the file is created using MODE_PRIVATE, so it cannot be accessed other than by apps with the same userid as the app that created the file.

openFileOutput("someFile", MODE_PRIVATE);

Risk Assessment

By not limiting access to a component intended to be private, sensitive information or capabilities could be leaked.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

DRD16-J

 

 

 

 

 

Automated Detection

Automatic detection of the mode used when a file, shared preference, or database is created is straightforward. It is not feasible to automatically determine whether the data written to the file, shared preference, or database is sensitive.

Bibliography

 

 

  • No labels