X Tutup
Skip to content

Fix problem with user-encryption when the a shared file is moved#38375

Merged
jvillafanez merged 2 commits intomasterfrom
encryption_move_from_share
Feb 19, 2021
Merged

Fix problem with user-encryption when the a shared file is moved#38375
jvillafanez merged 2 commits intomasterfrom
encryption_move_from_share

Conversation

@jvillafanez
Copy link
Member

Checked scenario below but moving a file instead of a folder:
admin creates "folderA"
admins shares "folderA" with user1 and user2
user1 creates "folderB" (in his home) and uploads content inside "folderB"
user1 moves "folderB" inside the shared folder "folderA" (leads to "folderA/folderB" being shared)
user2 moves "folderA/folderB" (step3) in his own home directory
admin has a "folderB" in his trashbin
admin restores the "folderB" from the trashbin -> "folderA/folderB" reappears
contents from "folderA/folderB" (the ones restored that are now shared again) aren't accessible (Bad Encryption exception)

The file / folder in the admin's trashbin had a wrong signature caused
by a wrong update of the encryptedVersion in the DB. This change bypass
that update in that particular scenario. The rest of the scenarios
weren't affected and will work the same way as before

Description

Fix broken signature of a backup copy created from the shared folder when the file is moved to the home directory of another user.

Minor additional changes included:

  • Raise log level for a possible 500 code in the trashbin previews (The "Bad signature" exception caused by this issue wasn't being logged there)
  • Fix possible "array access offset on bool type" if $sourceStorage->getCache()->get(...) returned false.

Related Issue

https://github.com/owncloud/enterprise/issues/4372
steps to reproduce are above and in https://github.com/owncloud/enterprise/issues/4372#issuecomment-769843523

Motivation and Context

The code creates a broken copy of a file inside the trashbin. Restoring the file from the trashbin will still keep the broken signature. This change fixes this behaviour, so the file can be restored if needed.

How Has This Been Tested?

Tested following the reproduction steps.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

Checked scenario below but moving a file instead of a folder:
    admin creates "folderA"
    admins shares "folderA" with user1 and user2
    user1 creates "folderB" (in his home) and uploads content inside "folderB"
    user1 moves "folderB" inside the shared folder "folderA" (leads to "folderA/folderB" being shared)
    user2 moves "folderA/folderB" (step3) in his own home directory
    admin has a "folderB" in his trashbin
    admin restores the "folderB" from the trashbin -> "folderA/folderB" reappears
    contents from "folderA/folderB" (the ones restored that are now shared again) aren't accessible (Bad Encryption exception)

The file / folder in the admin's trashbin had a wrong signature caused
by a wrong update of the encryptedVersion in the DB. This change bypass
that update in that particular scenario. The rest of the scenarios
weren't affected and will work the same way as before
@jvillafanez
Copy link
Member Author

Checked both with master-key encryption and user-key encryption. The problematic scenario works

Copy link
Contributor

@phil-davis phil-davis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should have a changelog?

And no tests were changed/added. Is there some way to have a unit test that simulates this problem somehow?

@jvillafanez
Copy link
Member Author

There are operations using native resources through the code path to be tested (

\fclose($source);
\fclose($target);
), so I don't think we can add unit tests.

Changelog coming soon.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@owncloud owncloud deleted a comment from update-docs bot Feb 19, 2021
@phil-davis
Copy link
Contributor

@jvillafanez anything else to do? Merge?

@phil-davis
Copy link
Contributor

Note: owncloud/encryption#244 - some trashbin+local-storage+encryption tests failed last night.

karakayasemi added a commit that referenced this pull request Mar 7, 2021
karakayasemi added a commit that referenced this pull request Mar 7, 2021
phil-davis added a commit that referenced this pull request Mar 7, 2021
phil-davis pushed a commit that referenced this pull request Mar 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup