core icon indicating copy to clipboard operation
core copied to clipboard

ownCloud external storage mount doesn't work with encryption

Open PVince81 opened this issue 13 years ago • 36 comments

Steps

  1. Mount a WebDAV storage (another ownCloud)
  2. Enable encryption
  3. Upload file
  4. Download file

Expected result

Downloaded file is not encrypted.

Actual result

Downloaded file is still encrypted

CC @schiesbn FYI I suspect it could be another fseek() issue.

PVince81 avatar Nov 19 '13 17:11 PVince81

yes, sounds like similar problems we had with samba. The strange think here is that webdav worked in the past, I always used the webdav back-end to test encryption and I doubt that the fseek() implementation changed lately.

schiessle avatar Nov 19 '13 18:11 schiessle

I've tried on the latest master and it might be something else. When downloading a file the file is empty. Editing text files directly with the text editor work.

Here is the error log:

    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP Warning:  fopen(crypt:///root/files/webdav/test/test.txt): failed to open stream: "OCA\\Encryption\\Stream::stream_open" call failed in /home/vincent/workspace/owncloud/apps/files_encryption/lib/proxy.php on line 276, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP Stack trace:, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP   1. {main}() /home/vincent/workspace/owncloud/index.php:0, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP   2. OC::handleRequest() /home/vincent/workspace/owncloud/index.php:30, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP   3. OC_Router->match() /home/vincent/workspace/owncloud/lib/base.php:666, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP   4. call_user_func() /home/vincent/workspace/owncloud/lib/private/router.php:127, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP   5. OC::loadAppScriptFile() /home/vincent/workspace/owncloud/lib/private/router.php:0, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP   6. require_once() /home/vincent/workspace/owncloud/lib/base.php:742, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP   7. OC_Files::get() /home/vincent/workspace/owncloud/apps/files/ajax/download.php:42, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP   8. OC\\Files\\Filesystem::readfile() /home/vincent/workspace/owncloud/lib/private/files.php:166, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP   9. OC\\Files\\View->readfile() /home/vincent/workspace/owncloud/lib/private/files/filesystem.php:582, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP  10. OC\\Files\\View->fopen() /home/vincent/workspace/owncloud/lib/private/files/view.php:202, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP  11. OC\\Files\\View->basicOperation() /home/vincent/workspace/owncloud/lib/private/files/view.php:580, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP  12. OC_FileProxy::runPostProxies() /home/vincent/workspace/owncloud/lib/private/files/view.php:682, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP  13. OCA\\Encryption\\Proxy->postFopen() /home/vincent/workspace/owncloud/lib/private/fileproxy.php:107, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test
    [Wed Nov 20 18:10:23 2013] [error] [client 127.0.0.1] PHP  14. fopen() /home/vincent/workspace/owncloud/apps/files_encryption/lib/proxy.php:276, referer: http://localhost/vincent/index.php/apps/files?dir=/webdav/test

PVince81 avatar Nov 20 '13 17:11 PVince81

Note that I have OC 5.0.13 as WebDAV backend, I haven't tried with an OC 6 backend.

PVince81 avatar Nov 20 '13 17:11 PVince81

Reminds me also of https://github.com/owncloud/apps/issues/1344.

Pazu avatar Nov 21 '13 07:11 Pazu

There is an additional issue when using two ownCloud: if backend OC is encrypted and not frontend OC, when uploading a file through frontend OC with WebDAV, the part file will not be treated correctly by the backend OC. The key file resolution will cut off the .part from the frontend's part file, which prevents the encryption code to use the key.

PVince81 avatar Feb 04 '14 15:02 PVince81

We might need to eventually find a fix for this to make server to server sharing work properly with encryption.

@karlitschek @craigpg FYI

PVince81 avatar Jun 16 '14 15:06 PVince81

didn't had a look at this issue in detail. But I tested server-to-server sharing with encryption and I could read/write files just fine

schiessle avatar Jun 16 '14 20:06 schiessle

The issue is when the remote server is encrypted. Try uploading a file there using the sync client: the part file cannot be renamed properly on the remote server.

PVince81 avatar Jun 17 '14 08:06 PVince81

One idea would be to disable encryption for the "ownCloud" external storage backend but keep it for the "WebDAV" external storage backend which is now more intended for "real" WebDAV servers like lighttpd.

Note that for server to server sharing we already disable encryption of the remote files.

Disabling encryption would prevent the issue of having files encrypted multiple times in cascade.

PVince81 avatar Aug 19 '14 09:08 PVince81

So if Server to Server is enabled, and the first server is encrypted, the second server users can't upload? Or, are you saying it does work for server to server by disabling encryption of the remote files?

We should provide a release note either way to capture what is described.

MTRichards avatar Sep 04 '14 21:09 MTRichards

Server to server sharing is different. There is special handling that if S1 is encrypted and mounts a folder on S2, then S1 will NOT encrypt files there. This works correctly.

This ticket is about the general "WebDAV" external storage mount point, not server to server sharing.

PVince81 avatar Sep 05 '14 08:09 PVince81

Right, understood @PVince81 - the last two posts were about server to server.

Just wondering what server to server did, so we could do the same on WebDAV mounting as specified.

MTRichards avatar Sep 05 '14 13:09 MTRichards

Yes exactly. There's a hidden flag somewhere.

And, to repeat myself, there are currently two external storage backends that you can select in the UI, so I suggest to do as follows:

  1. The "WebDAV external storage" mount always have encryption enabled, as before. This one is designed for people who want to use lightppd + webdav or other webdav servers.
  2. The "ownCloud external storage" mount does NOT have encryption enabled, with the same mechanism as specified above. This one is designed for a direct connection to ownCloud.

This means that we'll recommend against using "WebDAV external storage" for direct ownCloud connection.

Does that make sense ?

PVince81 avatar Sep 05 '14 13:09 PVince81

Any update ? Does my suggestion above make sense ?

I suggest to investigate whether this is possible without too many changes for OC 7. In OC 8, external storages will have a switch "enable encryption for this storage" which the user could manually remove to make this work when mounting OC in OC (https://github.com/owncloud/core/issues/10731)

CC @zacharydubois

PVince81 avatar Nov 13 '14 09:11 PVince81

@PVince81, You fix by using WebDav to enable two ownClouds (w/ encryption) to mount did not work for me. Instead of the sync process failing, the client 'thinks' it uploaded it and then threes to download the file because it appears different on the server (Non-existent on the server) and gives the following error:

4:49 PM   Me/WebDav/Vim.png                                               Cloud       Error downloading https://cloud1.example.com/remote.php/webdav/Me/WebDav/Vim.png - server replied: Bad request (expected file size 55297 got 0)          
4:48 PM   Me/WebDav/Vim.png                                               Cloud       Error downloading https://cloud1.example.com/remote.php/webdav/Me/WebDav/Vim.png - server replied: Bad request (expected filesize 55297 got 0)        

The files do not appear in the interface as well.

ZacharyDuBois avatar Nov 13 '14 21:11 ZacharyDuBois

I'd really like to see this fixed in the bug hunt :)

ZacharyDuBois avatar Nov 28 '14 18:11 ZacharyDuBois

Tentatively setting to OC 8. I'd love to see it too :wink: (if time permits)

PVince81 avatar Nov 28 '14 19:11 PVince81

But, I also hope the fix is not turning off encryption for the shared directory :( Everything should be secure :)

ZacharyDuBois avatar Nov 29 '14 01:11 ZacharyDuBois

@ZacharyDuBois here is how server to server sharing works:

  1. OC 1 (encrypted instance) shares folder "test" with a user
  2. User mounts OC 1 in his OC 2 (encrypted instance)
  3. Whenever OC 2 uploads into "test", the files are NOT encrypted, else they would be encrypted twice (once by OC 2 and then by OC 1, which would make them unreadable by the first user).

But this doesn't mean that files are stored unencrypted.

In a similar manner, the "ownCloud external storage backend" should also avoid encrypting twice: User1 mounts folder "test" from OC 1 into OC 2 (where his credential is also "user1") This means that both User1@OC1 and User2@OC2 will be able to read the files.

Currently the bug is that the file is encrypted twice: User1@OC1 sends the files in encrypted form to OC2 which itself encrypts it again. Due to the former encryption, User2@OC2 will not be able to read the file contents. Also, this causes bugs related to part files and there is no good way around.

Normally storage backends will always send the files in encrypted form to the target storage (ex: Dropbox, SFTP) which make them only readable by the original OC. The exception would be with this "ownCloud backend".

What do you think ?

PVince81 avatar Dec 01 '14 09:12 PVince81

I'm thinking there could be a "Send as unencrypted option" so it is stored encrypted locally, but when it needs to go somewhere, it is sent unencrypted. So like:

  1. OC1 has new file X on an OC2OC mount.
  2. File X is encrypted on OC1.
  3. OC2 makes a request for file X.
  4. OC1 sends file X unencrypted to OC2.
  5. OC2 then serves the file to wherever it needs to go.

From what I know, ownCloud doesn't store any external files locally so it shouldn't run into a double encryption problem. And if it did and it is send unencrypted from both ends, it shouldn't matter if each OC has different encryption for the same file. I am not really sure on this one.

ZacharyDuBois avatar Dec 04 '14 01:12 ZacharyDuBois