Skip to content

Downloading a file after restoring the version fails with 500  #383

@SwikritiT

Description

@SwikritiT

Steps to reproduce

  1. As a user upload a file with some data
curl -v -u admin:admin -XPUT http://localhost/cliCore/remote.php/dav/files/admin/test.txt -d "test file"
  1. overwrite the previously created file (create a version)
curl -v -u admin:admin -XPUT http://localhost/cliCore/remote.php/dav/files/admin/test.txt -d "test file updated"
  1. Download the file, it works
curl -v -u admin:admin http://localhost/cliCore/remote.php/dav/files/admin/test.txt
  1. Now to restore the version, get file id
curl -v -u admin:admin http://localhost/cliCore/remote.php/dav/files/admin/test.txt -X PROPFIND -d'<?xml version="1.0"?><d:propfind  xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:prop><oc:fileid /></d:prop></d:propfind>'

this will give a response that include file id

<d:prop><oc:fileid>2147484342</oc:filed></d:prop>
  1. Now PROPFIND to get the location of the previous version with the file id from previous step
curl -v -u admin:admin http://localhost/cliCore/remote.php/dav/meta/2147484342/v -X PROPFIND

Response

<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns"><d:response><d:href>/cliCore/remote.php/dav/meta/2147484342/v/</d:href><d:propstat><d:prop><d:resourcetype><d:collection/></d:resourcetype></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/cliCore/remote.php/dav/meta/2147484342/v/1676357084</d:href><d:propstat><d:prop><d:getlastmodified>Tue, 14 Feb 2023 06:44:44 GMT</d:getlastmodified><d:getcontentlength>9</d:getcontentlength><d:resourcetype/><d:getetag>&quot;62dd2ad72593875505630b4390d7633a&quot;</d:getetag><d:getcontenttype>text/plain</d:getcontenttype></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response></d:multistatus>

You can find the location in href
6. Now restore the previous version

curl -u admin:admin -X COPY "http://localhost/cliCore/remote.php/dav/meta/2147484342/v/1676357084" -H 'Destination:http://localhost/cliCore/remote.php/dav/files/admin/test.txt' -v

This request is successful with 204
7. Now get the file

curl -u admin:admin "http://localhost/cliCore/remote.php/dav/files/admin/test.txt" -v

Expected behaviour

The content of the previous version i.e test file should be downloaded

Actual behaviour

The request gives 500 and the content is <?xml ver%

*   Trying 127.0.0.1:80...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 80 (#0)
* Server auth using Basic with user 'admin'
> GET /cliCore/remote.php/dav/files/admin/test.txt HTTP/1.1
> Host: localhost
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Date: Tue, 14 Feb 2023 07:06:43 GMT
< Server: Apache/2.4.41 (Ubuntu)
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 0
< X-Robots-Tag: none
< X-Frame-Options: SAMEORIGIN
< X-Download-Options: noopen
< X-Permitted-Cross-Domain-Policies: none
< Set-Cookie: ocxzl8xu0hvp=4cr790u214quovs59ndp0k4mbi; path=/cliCore; HttpOnly; SameSite=Strict
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache
< Set-Cookie: oc_sessionPassphrase=c6FHVVaj0Nhp3NPyuPM95ljGVfJJo9aRRQil8MJL033GGPXXzrisdu2M0jo08aNWLHCindy%2FpB%2Fw1qk7UXIcZ6rNulTvy6uTqL51PoH8wmcS93mHg%2BHnDwnNdDEBCas0; expires=Tue, 14-Feb-2023 07:26:43 GMT; Max-Age=1200; path=/cliCore; HttpOnly; SameSite=Strict
< Content-Security-Policy: default-src 'none';
< Set-Cookie: ocxzl8xu0hvp=stgejcug3kuekvftju9m45h47i; path=/cliCore; HttpOnly; SameSite=Strict
< Set-Cookie: cookie_test=test; expires=Tue, 14-Feb-2023 08:06:43 GMT; Max-Age=3600
< Last-Modified: Tue, 14 Feb 2023 07:04:09 GMT
< ETag: "baadce7fd70f5d55962bb67728e55431"
< Content-Length: 9
< OC-ETag: "baadce7fd70f5d55962bb67728e55431"
< Content-Disposition: attachment; filename*=UTF-8''test.txt; filename="test.txt"
< X-Accel-Buffering: no
< Connection: close
< Content-Type: application/xml; charset=utf-8
< 
* Closing connection 0
<?xml ver%                                            

Screenshots of the UI

After creating the version
thumb-versions1

While restoring
versionREstore

Owncloud logs

{
  "reqId": "Y@sycnXc-XutX6P-UzTHpAAAAAk",
  "level": 3,
  "time": "2023-02-14T07:04:18+00:00",
  "remoteAddr": "::1",
  "user": "admin",
  "app": "no app in context",
  "method": "GET",
  "url": "/cliCore/remote.php/dav/meta/2147484342/v/1676358223?preview",
  "message": "Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you."
}
{
  "reqId": "Y@szA7t2IFH4hn@1Qw@E5AAAAAI",
  "level": 3,
  "time": "2023-02-14T07:06:43+00:00",
  "remoteAddr": "127.0.0.1",
  "user": "admin",
  "app": "no app in context",
  "method": "GET",
  "url": "/cliCore/remote.php/dav/files/admin/test.txt",
  "message": "Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you."
}
{
  "reqId": "Y@szA7t2IFH4hn@1Qw@E5AAAAAI",
  "level": 4,
  "time": "2023-02-14T07:06:43+00:00",
  "remoteAddr": "127.0.0.1",
  "user": "admin",
  "app": "webdav",
  "method": "GET",
  "url": "/cliCore/remote.php/dav/files/admin/test.txt",
  "message": "Exception: Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.: {\"Exception\":\"OC\\\\Encryption\\\\Exceptions\\\\DecryptionFailedException\",\"Message\":\"Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.\",\"Code\":0,\"Trace\":\"#0 \\/home\\/anu\\/www\\/cliCore\\/lib\\/private\\/Files\\/Stream\\/Encryption.php(471): OCA\\\\Encryption\\\\Crypto\\\\Encryption->decrypt(*** sensitive parameters replaced ***)\\n#1 \\/home\\/anu\\/www\\/cliCore\\/lib\\/private\\/Files\\/Stream\\/Encryption.php(293): OC\\\\Files\\\\Stream\\\\Encryption->readCache()\\n#2 [internal function]: OC\\\\Files\\\\Stream\\\\Encryption->stream_read()\\n#3 \\/home\\/anu\\/www\\/cliCore\\/apps\\/files_external\\/3rdparty\\/icewind\\/streams\\/src\\/Wrapper.php(55): fread()\\n#4 \\/home\\/anu\\/www\\/cliCore\\/lib\\/private\\/Files\\/Stream\\/Checksum.php(163): Icewind\\\\Streams\\\\Wrapper->stream_read()\\n#5 [internal function]: OC\\\\Files\\\\Stream\\\\Checksum->stream_read()\\n#6 \\/home\\/anu\\/www\\/cliCore\\/apps\\/files_external\\/3rdparty\\/icewind\\/streams\\/src\\/Wrapper.php(55): fread()\\n#7 \\/home\\/anu\\/www\\/cliCore\\/apps\\/files_external\\/3rdparty\\/icewind\\/streams\\/src\\/CallbackWrapper.php(96): Icewind\\\\Streams\\\\Wrapper->stream_read()\\n#8 [internal function]: Icewind\\\\Streams\\\\CallbackWrapper->stream_read()\\n#9 \\/home\\/anu\\/www\\/cliCore\\/apps\\/files_external\\/3rdparty\\/icewind\\/streams\\/src\\/Wrapper.php(55): fread()\\n#10 \\/home\\/anu\\/www\\/cliCore\\/apps\\/files_external\\/3rdparty\\/icewind\\/streams\\/src\\/CallbackWrapper.php(96): Icewind\\\\Streams\\\\Wrapper->stream_read()\\n#11 [internal function]: Icewind\\\\Streams\\\\CallbackWrapper->stream_read()\\n#12 \\/home\\/anu\\/www\\/cliCore\\/lib\\/composer\\/sabre\\/http\\/lib\\/Sapi.php(110): stream_copy_to_stream()\\n#13 \\/home\\/anu\\/www\\/cliCore\\/lib\\/composer\\/sabre\\/dav\\/lib\\/DAV\\/Server.php(490): Sabre\\\\HTTP\\\\Sapi::sendResponse()\\n#14 \\/home\\/anu\\/www\\/cliCore\\/lib\\/composer\\/sabre\\/dav\\/lib\\/DAV\\/Server.php(253): Sabre\\\\DAV\\\\Server->invokeMethod()\\n#15 \\/home\\/anu\\/www\\/cliCore\\/apps\\/dav\\/lib\\/Server.php(348): Sabre\\\\DAV\\\\Server->start()\\n#16 \\/home\\/anu\\/www\\/cliCore\\/apps\\/dav\\/appinfo\\/v2\\/remote.php(31): OCA\\\\DAV\\\\Server->exec()\\n#17 \\/home\\/anu\\/www\\/cliCore\\/remote.php(165): require_once('\\/home\\/anu\\/www\\/c...')\\n#18 {main}\",\"File\":\"\\/home\\/anu\\/www\\/cliCore\\/apps\\/encryption\\/lib\\/Crypto\\/Encryption.php\",\"Line\":374}"
}

Setup

Encryption enabled with master key

 sudo -u www-data ./occ encryption:enabled
sudo -u www-data ./occ encryption:select-encryption-type masterkey --yes

Owncloud 10 - master
commit id 5a381c888ed6db83b0991b0d6509a1aa1197eca9

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions