nextcloud / nextcloud/android

Metadata corruption after uploading files to encrypted folder

Open
#2,440 8 comments 1 reaction 0 assignees View on GitHub
approved bug E2E feature: encryption (client-side) feature: transfers
Dominant language
Kotlin
Stars
5.6k
Forks
2k
Avg merge
2d 18h
Merged PRs (30d)
92

Description

Originally posted in end-to-end repo, where it was suggested I post here instead.
https://github.com/nextcloud/end_to_end_encryption/issues/73

Server: Nextcloud 13.0.1 (originally put 3.0.1; must have been a typo)
End-to-End Encryption App: 1.0.5
Client: Nextcloud Dev (Android, F-Droid) v20180330

I created an encrypted Music folder via the Android client and tried to upload about 100 music files. After a certain point, every upload began to fail. I looked in the folder and the filenames are a series of hex characters (encrypted).

To test, I also created a folder of 200 tiny text files using:
`for i in $(seq 1001 1200); do echo $i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i > garbage$i.txt; done`
I tried to upload these to a new encrypted folder called "garbagetest". Problem was the same as with the music. Uploads began to fail after uploading 11 of them, and as expected, metadata was lost. (The number of files it takes for failure to begin varies.)

For the test, when problems began, Android's logcat showed:
```
E UploadFileOperation: Upload of /storage/emulated/0/garbage/garbage1171.txt to /garbagetest/null: Unexpected exception
E UploadFileOperation: java.security.InvalidAlgorithmParameterException: Expected IV length of 12 but was 0
E UploadFileOperation: at com.android.org.conscrypt.OpenSSLCipher$EVP_AEAD.engineInitInternal(OpenSSLCipher.java:1082)
E UploadFileOperation: at com.android.org.conscrypt.OpenSSLCipher$EVP_AEAD$AES$GCM.engineInitInternal(OpenSSLCipher.java:1290)
E UploadFileOperation: at com.android.org.conscrypt.OpenSSLCipher.engineInit(OpenSSLCipher.java:274)
E UploadFileOperation: at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2664)
E UploadFileOperation: at javax.crypto.Cipher.tryCombinations(Cipher.java:2575)
E UploadFileOperation: at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2480)
E UploadFileOperation: at javax.crypto.Cipher.chooseProvider(Cipher.java:567)
E UploadFileOperation: at javax.crypto.Cipher.init(Cipher.java:975)
E UploadFileOperation: at javax.crypto.Cipher.init(Cipher.java:910)
E UploadFileOperation: at com.owncloud.android.utils.EncryptionUtils.decryptStringSymmetric(EncryptionUtils.java:487)
E UploadFileOperation: at com.owncloud.android.utils.EncryptionUtils.decryptFolderMetaData(EncryptionUtils.java:196)
E UploadFileOperation: at com.owncloud.android.operations.UploadFileOperation.encryptedUpload(UploadFileOperation.java:485)
E UploadFileOperation: at com.owncloud.android.operations.UploadFileOperation.run(UploadFileOperation.java:415)
E UploadFileOperation: at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:145)
E UploadFileOperation: at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:149)
E UploadFileOperation: at com.owncloud.android.operations.common.SyncOperation.execute(SyncOperation.java:93)
E UploadFileOperation: at com.owncloud.android.files.services.FileUploader.uploadFile(FileUploader.java:1097)
E UploadFileOperation: at com.owncloud.android.files.services.FileUploader$ServiceHandler.handleMessage(FileUploader.java:1030)
E UploadFileOperation: at android.os.Handler.dispatchMessage(Handler.java:106)
E UploadFileOperation: at android.os.Looper.loop(Looper.java:164)
E UploadFileOperation: at android.os.HandlerThread.run(HandlerThread.java:65)
D UploadsStorageManager: updateDatabaseUploadResult uploadResult: com.owncloud.android.lib.common.operations.RemoteOperationResult@b006c40 upload: com.owncloud.android.operations.UploadFileOperation@9a9c779
V UploadsStorageManager: Updating /storage/emulated/0/garbage/garbage1171.txt with status:UPLOAD_FAILED and result:UNKNOWN (old:/storage/emulated/0/garbage/garbage1171.txt status:UPLOAD_IN_PROGRESS result:-1)
V UploadsStorageManager: Updating /storage/emulated/0/garbage/garbage1171.txt with status=UPLOAD_FAILED
D UploadsStorageManager: updateUpload returns with: 1 for file: /storage/emulated/0/garbage/garbage1171.txt
```

Here is the logcat from the moment of opening the app through to beyond the point uploads began failing and folder was refreshed to reveal loss of metadata (names became series of hex characters).
[ncdev-encfail(3).log](https://github.com/nextcloud/android/files/1887131/ncdev-encfail.3.log)

There was nothing notable in the server logs.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.