copying a file inside a localStorage sometimes exit with `500`
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 17
- Forks
- 19
- Avg merge
- 11h 40m
- Merged PRs (30d)
- 2
Description
Description
The setup for this issue needs the following connected together:
- latest oc10
- encryption app with UserSpecific keys enabled
- user_ldap as authentication backend
- PHP version 7.3
Steps to reproduce:
The issue can be reproduced with this drone yml: https://gist.github.com/kiranparajuli589/f0eb9bcbf4da9043fab7b1804d31a27d
- download the drone yml from the above gist on your local machine
- install the Drone CLI in your host machine if not already installed
- install Docker & DockerCompose in your host machine if not already installed
- execute the drone pipeline on your machine as
drone exec --pipeline core-apiAll-e-UK-latest-mysql8.0-php7.3 /path/to/yml
Server Log
Following log is seen in the oC10 log file at the moment of failure:
[owncloud-log-server:13] {"reqId":"Rb6X6luF8PtjaKSLWEZB","level":3,"time":"2022-07-20T06:52:25+00:00","remoteAddr":"172.19.0.6","user":"Alice","app":"PHP","method":"COPY","url":"\/remote.php\/webdav\/textfile0.txt","message":"fclose() expects parameter 1 to be resource, string given at \/var\/www\/owncloud\/server\/lib\/private\/Files\/Storage\/Wrapper\/Encryption.php#818"}
[owncloud-log-server:14] {"reqId":"Rb6X6luF8PtjaKSLWEZB","level":4,"time":"2022-07-20T06:52:25+00:00","remoteAddr":"172.19.0.6","user":"Alice","app":"webdav","method":"COPY","url":"\/remote.php\/webdav\/textfile0.txt","message":"Exception: multikeydecrypt with share key failed:error:04065072:rsa routines:rsa_ossl_private_decrypt:padding check failed: {\"Exception\":\"OCA\\\\Encryption\\\\Exceptions\\\\MultiKeyDecryptException\",\"Message\":\"multikeydecrypt with share key failed:error:04065072:rsa routines:rsa_ossl_private_decrypt:padding check failed\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/owncloud\\\/server\\\/apps\\\/encryption\\\/lib\\\/KeyManager.php(434): OCA\\\\Encryption\\\\Crypto\\\\Crypt->multiKeyDecrypt('[\\\\xF07I\\\\x90X@\\\\xAC\\\\\\\\~\\\/W\\\\xA1p\\\\x1C...', 'U\\\\x18\\\\xE0\\\\x8E\\\\x13\\\\xD0\\\\x8A{\\\\xE7\\\\x06qe\\\\xDA\\\\xBF\\\\x99...', '-----BEGIN PRIV...')\\n#1 \\\/var\\\/www\\\/owncloud\\\/server\\\/apps\\\/encryption\\\/lib\\\/Crypto\\\/Encryption.php(195): OCA\\\\Encryption\\\\KeyManager->getFileKey('\\\/Alice\\\/files\\\/lo...', 'Alice')\\n#2 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/private\\\/Files\\\/Stream\\\/Encryption.php(262): OCA\\\\Encryption\\\\Crypto\\\\Encryption->begin('\\\/Alice\\\/files\\\/lo...', 'Alice', 'w', Array, Array, NULL)\\n#3 [internal function]: OC\\\\Files\\\\Stream\\\\Encryption->stream_open('ocencryption:\\\/\\\/', 'w', 0, NULL)\\n#4 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/private\\\/Files\\\/Stream\\\/Encryption.php(204): fopen('ocencryption:\\\/\\\/', 'w', false, Resource id #61)\\n#5 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/private\\\/Files\\\/Stream\\\/Encryption.php(186): OC\\\\Files\\\\Stream\\\\Encryption::wrapSource(Resource id #60, Resource id #61, 'ocencryption', 'OC\\\\\\\\Files\\\\\\\\Stream...', 'w')\\n#6 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Encryption.php(479): OC\\\\Files\\\\Stream\\\\Encryption::wrap(Resource id #60, 'foo1\\\/textfile0....', '\\\/Alice\\\/files\\\/lo...', Array, 'Alice', Object(OCA\\\\Encryption\\\\Crypto\\\\Encryption), Object(OC\\\\Files\\\\Storage\\\\Local), Object(OC\\\\Files\\\\Storage\\\\Wrapper\\\\Encryption), Object(OC\\\\Encryption\\\\Util), Object(OC\\\\Encryption\\\\File), 'w', 0, 0, 0, true, NULL)\\n#7 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Encryption.php(811): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Encryption->fopen('foo1\\\/textfile0....', 'w')\\n#8 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Encryption.php(686): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Encryption->copyBetweenStorage(Object(OCA\\\\Files_Trashbin\\\\Storage), 'files\\\/textfile0...', 'foo1\\\/textfile0....', false, false)\\n#9 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Wrapper.php(565): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Encryption->copyFromStorage(Object(OCA\\\\Files_Trashbin\\\\Storage), 'files\\\/textfile0...', 'foo1\\\/textfile0....')\\n#10 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Wrapper.php(565): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Wrapper->copyFromStorage(Object(OCA\\\\Files_Trashbin\\\\Storage), 'files\\\/textfile0...', 'foo1\\\/textfile0....')\\n#11 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/private\\\/Files\\\/View.php(991): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Wrapper->copyFromStorage(Object(OCA\\\\Files_Trashbin\\\\Storage), 'files\\\/textfile0...', 'foo1\\\/textfile0....')\\n#12 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/public\\\/Events\\\/EventEmitterTrait.php(50): OC\\\\Files\\\\View->OC\\\\Files\\\\{closure}(*** sensitive parameters replaced ***)\\n#13 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/private\\\/Files\\\/View.php(1032): OC\\\\Files\\\\View->emittingCall(Object(Closure), Array, 'file', 'copy')\\n#14 \\\/var\\\/www\\\/owncloud\\\/server\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/ObjectTree.php(249): OC\\\\Files\\\\View->copy('textfile0.txt', 'local_storage\\\/f...')\\n#15 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(659): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\ObjectTree->copy('textfile0.txt', 'local_storage\\\/f...')\\n#16 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/composer\\\/sabre\\\/event\\\/lib\\\/WildcardEmitterTrait.php(89): Sabre\\\\DAV\\\\CorePlugin->httpCopy(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#17 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(472): Sabre\\\\DAV\\\\Server->emit('method:COPY', Array)\\n#18 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(253): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#19 \\\/var\\\/www\\\/owncloud\\\/server\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(321): Sabre\\\\DAV\\\\Server->start()\\n#20 \\\/var\\\/www\\\/owncloud\\\/server\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(67): Sabre\\\\DAV\\\\Server->exec()\\n#21 \\\/var\\\/www\\\/owncloud\\\/server\\\/remote.php(165): require_once('\\\/var\\\/www\\\/ownclo...')\\n#22 {main}\",\"File\":\"\\\/var\\\/www\\\/owncloud\\\/server\\\/apps\\\/encryption\\\/lib\\\/Crypto\\\/Crypt.php\",\"Line\":702}"}
Fails sometimes only:
With this drone YAML, I've used a core branch check-user-ldap-746 where the Scenario failing because of this is duplicated 5 times. Here, the first scenario always passes and the rest always fails.
I've checked if there is some uncleared state for the next scenarios, but the created local_storage and external_storages are properly cleared. That's why we can create the user and localStorage again in the next scenarios without any errors. The next scenarios then break on COPY request with 500 response code
P.S. In the encryption app, the core API tests are not run with UserKey encryption, only runs with MasterKey encryption.
Open Tasks
- skip the tests for setup (UK encryption + core + user_ldap) https://github.com/owncloud/core/pull/40221
Originally posted by @kiranparajuli589 in https://github.com/owncloud/user_ldap/issues/746#issuecomment-1189883681
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the repeated Drone pipeline described in the issue and inspect the failure paths in lib/private/Files/Storage/Wrapper/Encryption.php:818 and apps/encryption/lib/Crypto/Crypt.php:702. Reproduce the UserKey encryption and user_ldap setup with the provided YAML, then trace why later localStorage COPY requests fail. Done means the repeated scenarios complete without a 500 response or the reported decryption and fclose errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, php
- Domain
- authentication, backend, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100