Skip to content
This repository was archived by the owner on Jun 14, 2022. It is now read-only.
This repository was archived by the owner on Jun 14, 2022. It is now read-only.

Backup erroneously reports success #671

@connorlanigan

Description

@connorlanigan

General information

  • App version: 0.7.1.1-play
  • App source: Google Play
  • Android Version: 10
  • Custom ROM: yes - Havoc-OS 3.7

Expected result

What is expected?
If a backup fails, the backup_toast_export_failed toast should be shown.

What does happen instead?
If a backup fails, the backup_toast_export_success toast is shown.

The logcat log confirms that the call to StorageAccessHelper#saveFile has actually failed, since line 27 is executed:

StorageAccessHelper#saveFile returns false to indicate that failure, but BackupHelper#backupToFile ignores the return value (and thus ignores the failure). See lines 123 and 129 in the following file:

public static boolean backupToFile(Context context, Uri uri, String password, SecretKey encryptionKey)
{
ArrayList<Entry> entries = DatabaseHelper.loadDatabase(context, encryptionKey);
String plain = DatabaseHelper.entriesToString(entries);
try {
int iter = EncryptionHelper.generateRandomIterations();
byte[] salt = EncryptionHelper.generateRandom(Constants.ENCRYPTION_IV_LENGTH);
SecretKey key = EncryptionHelper.generateSymmetricKeyPBKDF2(password, iter, salt);
byte[] encrypted = EncryptionHelper.encrypt(key, plain.getBytes(StandardCharsets.UTF_8));
byte[] iterBytes = ByteBuffer.allocate(Constants.INT_LENGTH).putInt(iter).array();
byte[] data = new byte[Constants.INT_LENGTH + Constants.ENCRYPTION_IV_LENGTH + encrypted.length];
System.arraycopy(iterBytes, 0, data, 0, Constants.INT_LENGTH);
System.arraycopy(salt, 0, data, Constants.INT_LENGTH, Constants.ENCRYPTION_IV_LENGTH);
System.arraycopy(encrypted, 0, data, Constants.INT_LENGTH + Constants.ENCRYPTION_IV_LENGTH, encrypted.length);
StorageAccessHelper.saveFile(context, uri, data);
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}

Logcat

[W/System.err]
java.io.FileNotFoundException: open failed: EACCES (Permission denied)
	at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:319)
	at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:224)
	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1500)
	at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1340)
	at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1288)
	at org.shadowice.flocke.andotp.Utilities.StorageAccessHelper.saveFile(StorageAccessHelper.java:19)
	at org.shadowice.flocke.andotp.Utilities.BackupHelper.backupToFile(BackupHelper.java:80)
	at org.shadowice.flocke.andotp.Activities.BackupActivity.doBackupCryptWithPassword(BackupActivity.java:551)
	at org.shadowice.flocke.andotp.Activities.BackupActivity.doBackupCrypt(BackupActivity.java:544)
	at org.shadowice.flocke.andotp.Activities.BackupActivity.showSaveFileSelector(BackupActivity.java:379)
	at org.shadowice.flocke.andotp.Activities.BackupActivity.saveFileWithPermissions(BackupActivity.java:398)
	at org.shadowice.flocke.andotp.Activities.BackupActivity.access$200(BackupActivity.java:72)
	at org.shadowice.flocke.andotp.Activities.BackupActivity$3.onClick(BackupActivity.java:140)
	at android.view.View.performClick(View.java:7260)
	at android.view.View.performClickInternal(View.java:7237)
	at android.view.View.access$3600(View.java:802)
	at android.view.View$PerformClick.run(View.java:27915)
	at android.os.Handler.handleCallback(Handler.java:883)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at android.os.Looper.loop(Looper.java:214)
	at android.app.ActivityThread.main(ActivityThread.java:7356)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:925)

Steps to reproduce

  • Trigger a backup from the app in a way that results in a filesystem permission error
  • Check the displayed toast message

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions