Files are kept in the external storage of an Android device, which other apps can read
What it finds
On Android, external storage is shared: other apps with the storage permission, and anyone who mounts the card, can read and change what is written there (CWE-922). Data that is private to the app belongs in its internal storage, as the Android data storage guide says.
Reported is a call of getExternalStorageDirectory, getExternalStoragePublicDirectory, getExternalFilesDir, getExternalFilesDirs or getExternalCacheDir.
From the rule's source, external_storage.rs.
import android.content.Context;import android.os.Environment;import java.io.File; class Store { File where(Context context) { File a = Environment.getExternalStorageDirectory();tx0 reports: can be read and changed by other apps File b = context.getExternalFilesDir(null);tx0 reports: other apps return context.getFilesDir(); }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:external-storage" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:external-storage] reason="..."tx0 explain tx0/java:external-storage shows the same in the terminal. Found a false positive? Report it.