Skip to content

When files with multiple versions are deleted with encryption enabled ( masterkey ) due to missing filekey ( with external storage ) #28883

Closed

Description

@sharidas

Steps to reproduce

  1. Enable encryption with masterkey
  2. Enable external storage lets say SFTP
  3. Upload a file to SFTP folder
  4. Update the file multiple times
  5. Delete the folder from the SFTP folder
  6. Exception thrown

Expected behaviour

The logs should be clean

Actual behaviour

Exception thrown:
{"reqId":"1UMP5Dpueb1J2iY0QueA","level":3,"time":"2017-09-01T11:06:07+00:00","remoteAddr":"127.0.0.1","user":"admin","app":"no app in context","method":"DELETE","url":"\/enterprise\/remote.php\/dav\/files\/admin\/SFTP\/foo.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":"1UMP5Dpueb1J2iY0QueA","level":3,"time":"2017-09-01T11:06:07+00:00","remoteAddr":"127.0.0.1","user":"admin","app":"no app in context","method":"DELETE","url":"\/enterprise\/remote.php\/dav\/files\/admin\/SFTP\/foo.txt","message":"Couldn't re-calculate unencrypted size for files_versions\/SFTP\/foo.txt.v1504263233"} {"reqId":"1UMP5Dpueb1J2iY0QueA","level":3,"time":"2017-09-01T11:06:07+00:00","remoteAddr":"127.0.0.1","user":"admin","app":"no app in context","method":"DELETE","url":"\/enterprise\/remote.php\/dav\/files\/admin\/SFTP\/foo.txt","message":"Exception: {\"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\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Encryption.php(599): OCA\\\\Encryption\\\\Crypto\\\\Encryption->decrypt(*** sensitive parameters replaced ***)\\n#1 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Encryption.php(518): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Encryption->fixUnencryptedSize('files_versions\\\/...', 116, 8308)\\n#2 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Encryption.php(166): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Encryption->verifyUnencryptedSize('files_versions\\\/...', 8308)\\n#3 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Wrapper.php(149): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Encryption->filesize('files_versions\\\/...')\\n#4 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Wrapper.php(149): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Wrapper->filesize('files_versions\\\/...')\\n#5 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/View.php(1124): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Wrapper->filesize('files_versions\\\/...')\\n#6 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/View.php(415): OC\\\\Files\\\\View->basicOperation('filesize', 'files_versions\\\/...')\\n#7 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/files_versions\\\/lib\\\/Storage.php(463): OC\\\\Files\\\\View->filesize('\\\/files_versions...')\\n#8 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/files_trashbin\\\/lib\\\/Trashbin.php(347): OCA\\\\Files_Versions\\\\Storage::getVersions('admin', 'foo.txt')\\n#9 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/files_trashbin\\\/lib\\\/Trashbin.php(307): OCA\\\\Files_Trashbin\\\\Trashbin::retainVersions('foo.txt', 'admin', 'SFTP\\\/foo.txt', 1504263292)\\n#10 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/files_trashbin\\\/lib\\\/Storage.php(185): OCA\\\\Files_Trashbin\\\\Trashbin::move2trash('SFTP\\\/foo.txt')\\n#11 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/files_trashbin\\\/lib\\\/Storage.php(120): OCA\\\\Files_Trashbin\\\\Storage->doDelete('foo.txt', 'unlink')\\n#12 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/View.php(1124): OCA\\\\Files_Trashbin\\\\Storage->unlink('foo.txt')\\n#13 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/View.php(694): OC\\\\Files\\\\View->basicOperation('unlink', '\\\/SFTP\\\/foo.txt', Array)\\n#14 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php(354): OC\\\\Files\\\\View->unlink('\\\/SFTP\\\/foo.txt')\\n#15 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Tree.php(179): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->delete()\\n#16 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(287): Sabre\\\\DAV\\\\Tree->delete('files\\\/admin\\\/SFT...')\\n#17 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpDelete(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#18 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/composer\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#19 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:DELETE', Array)\\n#20 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#21 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/dav\\\/lib\\\/Server.php(236): Sabre\\\\DAV\\\\Server->exec()\\n#22 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/dav\\\/appinfo\\\/v2\\\/remote.php(31): OCA\\\\DAV\\\\Server->exec()\\n#23 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/remote.php(175): require_once('\\\/home\\\/sujith\\\/te...')\\n#24 {main}\",\"File\":\"\\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/encryption\\\/lib\\\/Crypto\\\/Encryption.php\",\"Line\":367}"} {"reqId":"1UMP5Dpueb1J2iY0QueA","level":3,"time":"2017-09-01T11:06:12+00:00","remoteAddr":"127.0.0.1","user":"admin","app":"no app in context","method":"DELETE","url":"\/enterprise\/remote.php\/dav\/files\/admin\/SFTP\/foo.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":"1UMP5Dpueb1J2iY0QueA","level":3,"time":"2017-09-01T11:06:12+00:00","remoteAddr":"127.0.0.1","user":"admin","app":"no app in context","method":"DELETE","url":"\/enterprise\/remote.php\/dav\/files\/admin\/SFTP\/foo.txt","message":"Couldn't re-calculate unencrypted size for files_versions\/SFTP\/foo.txt.v1504263241"} {"reqId":"1UMP5Dpueb1J2iY0QueA","level":3,"time":"2017-09-01T11:06:12+00:00","remoteAddr":"127.0.0.1","user":"admin","app":"no app in context","method":"DELETE","url":"\/enterprise\/remote.php\/dav\/files\/admin\/SFTP\/foo.txt","message":"Exception: {\"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\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Encryption.php(599): OCA\\\\Encryption\\\\Crypto\\\\Encryption->decrypt(*** sensitive parameters replaced ***)\\n#1 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Encryption.php(518): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Encryption->fixUnencryptedSize('files_versions\\\/...', 132, 8324)\\n#2 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Encryption.php(166): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Encryption->verifyUnencryptedSize('files_versions\\\/...', 8324)\\n#3 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Wrapper.php(149): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Encryption->filesize('files_versions\\\/...')\\n#4 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Wrapper.php(149): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Wrapper->filesize('files_versions\\\/...')\\n#5 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/View.php(1124): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Wrapper->filesize('files_versions\\\/...')\\n#6 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/View.php(415): OC\\\\Files\\\\View->basicOperation('filesize', 'files_versions\\\/...')\\n#7 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/files_versions\\\/lib\\\/Storage.php(463): OC\\\\Files\\\\View->filesize('\\\/files_versions...')\\n#8 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/files_trashbin\\\/lib\\\/Trashbin.php(347): OCA\\\\Files_Versions\\\\Storage::getVersions('admin', 'foo.txt')\\n#9 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/files_trashbin\\\/lib\\\/Trashbin.php(307): OCA\\\\Files_Trashbin\\\\Trashbin::retainVersions('foo.txt', 'admin', 'SFTP\\\/foo.txt', 1504263292)\\n#10 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/files_trashbin\\\/lib\\\/Storage.php(185): OCA\\\\Files_Trashbin\\\\Trashbin::move2trash('SFTP\\\/foo.txt')\\n#11 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/files_trashbin\\\/lib\\\/Storage.php(120): OCA\\\\Files_Trashbin\\\\Storage->doDelete('foo.txt', 'unlink')\\n#12 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/View.php(1124): OCA\\\\Files_Trashbin\\\\Storage->unlink('foo.txt')\\n#13 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/private\\\/Files\\\/View.php(694): OC\\\\Files\\\\View->basicOperation('unlink', '\\\/SFTP\\\/foo.txt', Array)\\n#14 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php(354): OC\\\\Files\\\\View->unlink('\\\/SFTP\\\/foo.txt')\\n#15 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Tree.php(179): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->delete()\\n#16 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(287): Sabre\\\\DAV\\\\Tree->delete('files\\\/admin\\\/SFT...')\\n#17 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpDelete(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#18 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/composer\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#19 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:DELETE', Array)\\n#20 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#21 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/dav\\\/lib\\\/Server.php(236): Sabre\\\\DAV\\\\Server->exec()\\n#22 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/dav\\\/appinfo\\\/v2\\\/remote.php(31): OCA\\\\DAV\\\\Server->exec()\\n#23 \\\/home\\\/sujith\\\/test\\\/enterprise\\\/remote.php(175): require_once('\\\/home\\\/sujith\\\/te...')\\n#24 {main}\",\"File\":\"\\\/home\\\/sujith\\\/test\\\/enterprise\\\/apps\\\/encryption\\\/lib\\\/Crypto\\\/Encryption.php\",\"Line\":367}"}

Server configuration

Operating system:
Linux Mint 18.2 Sonya

Web server:
Apache

Database:
Sqlite

PHP version:
7.0

ownCloud version: (see ownCloud admin page)
Found on master branch, 10.0.2 and 9.1.6

Updated from an older ownCloud or fresh install:
Fresh install

Where did you install ownCloud from:
git

Signing status (ownCloud 9.0 and above):

Login as admin user into your ownCloud and access 
http://example.com/index.php/settings/integrity/failed 
paste the results into https://gist.github.com/ and puth the link here.

The content of config/config.php:

Log in to the web-UI with an administrator account and click on
'admin' -> 'Generate Config Report' -> 'Download ownCloud config report'
This report includes the config.php settings, the list of activated apps
and other details in a well sanitized form.

or 

If you have access to your command line run e.g.:
sudo -u www-data php occ config:list system
from within your ownCloud installation folder

*ATTENTION:* Do not post your config.php file in public as is. Please use one of the above
methods whenever possible. Both, the generated reports from the web-ui and from occ config:list
consistently remove sensitive data. You still may want to review the report before sending.
If done manually then it is critical for your own privacy to dilligently
remove *all* host names, passwords, usernames, salts and other credentials before posting.
You should assume that attackers find such information and will use them against your systems.

List of activated apps:

If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your ownCloud installation folder.

Are you using external storage, if yes which one: local/smb/sftp/...

Are you using encryption: yes/no

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...

LDAP configuration (delete this part if not used)

With access to your command line run e.g.:
sudo -u www-data php occ ldap:show-config
from within your ownCloud installation folder

Without access to your command line download the data/owncloud.db to your local
computer or access your SQL server remotely and run the select query:
SELECT * FROM `oc_appconfig` WHERE `appid` = 'user_ldap';


Eventually replace sensitive data as the name/IP-address of your LDAP server or groups.

Client configuration

Browser:
Chrome

Operating system:
Linux Mint 18.2 Sonya

Logs

Web server error log

Insert your webserver log here

ownCloud log (data/owncloud.log)

Insert your ownCloud log here

Browser log

Insert your browser log here, this could for example include:

a) The javascript console log
b) The network log 
c) ...

Activity

  1. self-assigned this
    on Sep 1, 2017
  2. added this to the development milestone on Sep 1, 2017
  3. PVince81 commented on Sep 4, 2017

    @PVince81
    Contributor

    @sharidas if this was always broken, even in past versions like 9.1, then this is not a regression.

  4. PVince81 commented on Sep 4, 2017

    @PVince81
    Contributor

    PR: #28899

  5. added
    p2-high
    on Sep 5, 2017
  6. modified the milestones: development, on Sep 18, 2017
  7. lock commented on Aug 1, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  8. locked as resolved and limited conversation to collaborators on Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

1 - To developType:Bugp2-highstatus/STALE

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions