-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(e2ee): handle E2EE v2.1 #16345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(e2ee): handle E2EE v2.1 #16345
Conversation
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
|
/backport to stable-3.35 |
...src/main/java/com/owncloud/android/datamodel/e2e/v2/decrypted/DecryptedFolderMetadataFile.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java
Outdated
Show resolved
Hide resolved
|
|
||
| if (E2EVersionHelper.INSTANCE.isV2orAbove(version)) { | ||
| EncryptionUtilsV2 encryptionUtilsV2 = new EncryptionUtilsV2(); | ||
| return encryptionUtilsV2.parseAnyMetadata(getMetadataOperationResult.getResultData(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encryptionUtilsV2.parseAnyMetadata needs to be used for v2.1 and v2.0.
| RemoteOperationResult<String> uploadMetadataOperationResult; | ||
| if (metadataExists) { | ||
| // update metadata | ||
| if (version == E2EVersion.V2_0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exact version checks break the app and require manual updates for every new version. This logic has been replaced with E2EVersionHelper.
| object : TypeToken<EncryptedFolderMetadataFile>() {} | ||
| ) | ||
|
|
||
| val decryptedFolderMetadata = if (v2.version == "2.0" || v2.version == "2") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v2.version == "2.0" || v2.version == "2" Fragile and dangerous check and it will not work with 2.1 replaced with E2EVersionHelper.fromVersionString
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
| * Supports both V1 and V2 metadata formats and falls back safely | ||
| * to [E2EVersion.UNKNOWN] if parsing fails. | ||
| */ | ||
| fun fromMetadata(metadata: String): E2EVersion = runCatching { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacement of public static E2EVersion determinateVersion(String metadata) {
Tries v1 if fails v2 if fails E2EVersion.UNKNOWN
| @Transient | ||
| val filedrop: MutableMap<String, DecryptedFile> = HashMap(), | ||
| val version: String = "2.0" | ||
| val version: String = E2EVersionHelper.latestVersion(true).value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaces hardcoded hidden strings with actual latest version so that in future we dont come across issues like this. @tobiasKaminsky
| localFilesMap = prefillLocalFilesMap(metadataFileV1, fileDataStorageManager.getFolderContent(mLocalFolder, false)); | ||
| } else { | ||
| e2EVersion = E2EVersion.V2_0; | ||
| e2EVersion = E2EVersionHelper.INSTANCE.latestVersion(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, for each version iteration, these hidden hardcoded values need to be upgraded. With latestVersion function we can just replace from there. In this case, E2EVersion.V2_1 should be the new value.
|
blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed. |
|
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/16345.apk |

Issue
The introduction of
E2EE v2.1exposed multiple code paths that relied on exact version matching(== 2.0), causing logic meant for v2.x to be skipped. As a result, the app crashes when interacting with encrypted folders created using E2EE 2.1.How to reproduce
Changes