owncloud / core

:cloud: ownCloud web server core (Files, DAV, etc.)
https://owncloud.com
GNU Affero General Public License v3.0
8.37k stars 2.06k forks source link

OC6 losing encryption & share keys #9191

Closed lorddoumer closed 10 years ago

lorddoumer commented 10 years ago

Expected behaviour OC keeps the generated share and encryption keys

Actual behaviour on random intervalls all encryption and share keys are lost – the folders are empty (while the actual data remains in place)

Steps to reproduce not sure. first thought about public upload to an shared folder while encryption is enabled, but couldn't be reproduced (see here: https://github.com/owncloud/core/issues/6411 )

Server configuration

BTW: it's a managed v-server

Client configuration

Logs I did a complete fresh install after the last time all keys got lost, so I don't have a full log anymore, sorry! Here are the parts from the last comment: https://gist.github.com/lorddoumer/d27055901b367ebd659e

Additional information I use the admin-account to create folders and share them with a lot of groups and users. The folderstructure is like this:

The client is only used by a few people, most are using the web-interface.

karlitschek commented 10 years ago

@schiesbn

lorddoumer commented 10 years ago

UPDATE I have another private OC instance running at my personal webspace (1und1 Linux Hosting), which I use to sync my contacts, calendars and files like ebooks (which shouldn't be shared with others because of copyright) between my Android devices. There is only my user account, no groups, no shares nothing. This instance has been running for about 8 months now without any issues, but last night one of those ebooks can't be decrypted anymore. This happened somewhere between the sync of my devices: one device synced all books correctly, the remaining two failed. Only this particular ebook (with two png files for cover) seems to be affected – everything else seems to be OK (as far as I can tell by now).

Server configration:

Here is the log (the affected book is "Swords of Dargonfire" by Ed Greenwood): https://gist.github.com/lorddoumer/5b17707b9df914d821e5

schiessle commented 10 years ago

Can you still download the book with the web interface?

lorddoumer commented 10 years ago

No, there is a message that the file can't be decrypted or isn't shared anymore. I deleted the corrupt files, reuploaded and now it's working again (new encryption keys have been generated).

schiessle commented 10 years ago

Was the file moved to a different location or renamed in between? Is the "deleted files" app enabled? Can you check if the encryption keys are located in data/user/files_trashbin/ ?

lorddoumer commented 10 years ago

no, file hasn't been moved. the delete files app is enabled, yes. here is a list of all apps enabled:

the encryption keys ar enot in files_trashbin – but i reuploaded the book to restore a working copy on my android.

schiessle commented 10 years ago

@lorddoumer I can't reproduce it. But I created a pull request against master (the upcoming ownCloud7) with additional checks if a file still exists and with additional debug output.

Tomorrow I will try to prepare a backport to OC6. Is it possible for you to try the version from master? Otherwise just wait for the backport. I hope this way we can catch all false delete requests.

schiessle commented 10 years ago

@lorddoumer Now I created a pull request agains stable6, #9250

Would be great if you could apply this patch to your installation and enable debug mode to get some additional information if it should happen again. But I'm quite confident that this PR will prevent the deletion of keys from existing files.

lorddoumer commented 10 years ago

@schiesbn great, thanks a lot! i apply the patch tomorrow and report back if the problem occurs again. but since I don't know myselfe how to reproduce the problem and the occurrence is more or less random I can't promise a quick report.

PVince81 commented 10 years ago

Closing for now, fix is in above PR.

@lorddoumer feel free to reopen if it still happens after patching.

derkostka commented 10 years ago

Hey guys it seems this has happened to me right now on OC 7.0.1. Has this patch been merged to master also ?

No keyfiles after clearing the trash:

root@odroid:/media/data/owncloud/data/skostka/files_encryption# l * skostka.private.key

keyfiles:

share-keys:

EDIT: confirmed, i just lost some Data right now ... I will try to restore my last Backup to see when the keys were deleted (did the update to 7.0.1 and did not check afterwards) ...

lorddoumer commented 10 years ago

since the patch from june its worlking fine for me ... but currently I'm on 7.0.0 on the one server and 6.0.4 on the other. additional note: I've disabled deleted files and versioning sinc I had a lot of those problems – do you have those enabled?

derkostka commented 10 years ago

yes both are enabled. i checked again an could not reproduce this issue, which is bad ...

Here some more detail on how this happened:

derkostka commented 10 years ago

I restarted my Server and it happened again, very weird. I try to open a PDF Document in the Browser:

"app":"index","message":"Exception: Encryption key not found for \"\/skostka\/files\/MyData\/KnowHow\/kalman.pdf\" during attempted read via stream","level":4,"time":"August 14, 2014 23:21:35"}

But as you can see, the key is present: /media/data/owncloud/data/skostka/files_encryption/keyfiles/MyData/KnowHow# ls -lh kalman.pdf.key -rw-r--r-- 1 www-data www-data 44 Aug 8 02:02 kalman.pdf.key

Please help me how to fix this (obvious) bug !

@schiesbn maybe you can assist me in debugging this one ?

aaujon commented 10 years ago

Same thing is happening here on 7.0.1. "Encryption key not found", when trying to open old documents ; newly created documents work fine. Tell me if you need some extras information.

derkostka commented 10 years ago

I created a new Item to rise attention for this task: https://github.com/owncloud/core/issues/10533

lorddoumer commented 10 years ago

@schiesbn this just happend to me again ... to be more precicely: user A uploaded some files to folder XY shared by user B (admin) but the encryption- and share-keys don't get stored in user B's data-folder but in user A's data-folder. But still the files are broken and can't get decrypted. Any idea? Just noticed: user A created a subfolder in the original folder by user B and one keyfile actually got stored in user B's data-folder – the rest as stated above is in user A's data-folder.

schiessle commented 10 years ago

@lorddoumer Not sure, but could you try this patch: https://github.com/owncloud/core/pull/10181 This fixes a bug with encryption if the external storage app is enabled.

lorddoumer commented 10 years ago

thanks, gonna try as soon as possible – although i still don't have external storage enabled.

lorddoumer commented 10 years ago

Update: I applied the patch and upgraded to 7.0.2 in the meantime and everything worked fine untill today. Now the same issue occures again – but only one specific user seems to be affected. At least only this user is affected by the bug...

kaplandani commented 9 years ago

No share keys found for.... 7.0.3 as well.....

PVince81 commented 9 years ago

Question is whether the keys were lost already before or just got lost while using 7.0.3. 7.0.3 is more robust in that regard but if the keys were lost before already it will not be able to restore them.

kaplandani commented 9 years ago

I wouldn't know, just upgraded yesterday, and found this on the log today,