nextcloud / nextcloud/server

[Bug]: `occ encryption:encrypt-all` breaks on broken remote shares

Open
#37,566 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 26-feedback bug feature: encryption (server-side) feature: federation
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.
Bug description

After enabling encryption and running 'encrypt-all', the commands starts encrypting files, but then encounters a broken remote, federated share under a user, cannot access it, throws error and won't progress to other files or users.
I've tried it first with master-key encryption, then turned encryption off and tried it again with user certificate encryption - the error is the same:

Start to encrypt users files
----------------------------

encrypt files for user myuser (2 of 4): /myuser/files/remoteshare/myfile.pdf
 [->--------------------------]
In DAV.php line 858:
  Sabre\HTTP\ClientHttpException:Forbidden

encryption:encrypt-all
Steps to reproduce
  1. Accept federated share
  2. Disable receiving remote shares
  3. Turn on encryption
  4. Run encrypt-all
Expected behavior

I'd expect the encrypt-all to progress to other files and users

Installation method

Other Community project

Nextcloud Server version

26

Operating system

Other

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Updated to a major version (ex. 22.2.3 to 23.0.1)

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report
{
    "system": {
        "apps_paths": [
            {
                "path": "\/usr\/local\/www\/nextcloud\/apps",
                "url": "\/apps",
                "writable": true
            },
            {
                "path": "\/usr\/local\/www\/nextcloud\/apps-pkg",
                "url": "\/apps-pkg",
                "writable": false
            }
        ],
        "logfile": "\/var\/log\/nextcloud\/nextcloud.log",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "..."
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "26.0.0.11",
        "overwrite.cli.url": "https:\/\/...",
        "htaccess.RewriteBase": "\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "mail_smtpmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "user_backends": [
            {
                "class": "\\OCA\\UserExternal\\IMAP",
                "arguments": [
                    "127.0.0.1",
                    143,
                    null,
                    "...",
                    true,
                    true
                ]
            }
        ],
        "maintenance": false,
        "default_phone_region": "EE",
        "theme": "",
        "loglevel": 0,
        "app_install_overwrite": [
            "user_external"
        ]
    }
}
List of activated Apps
Enabled:
  - activity: 2.18.0
  - calendar: 4.3.1
  - cloud_federation_api: 1.9.0
  - comments: 1.16.0
  - contactsinteraction: 1.7.0
  - dashboard: 7.6.0
  - dav: 1.25.0
  - encryption: 2.14.0
  - federatedfilesharing: 1.16.0
  - federation: 1.16.0
  - files: 1.21.1
  - files_pdfviewer: 2.7.0
  - files_rightclick: 1.5.0
  - files_sharing: 1.18.0
  - files_trashbin: 1.16.0
  - files_versions: 1.19.1
  - firstrunwizard: 2.15.0
  - logreader: 2.11.0
  - lookup_server_connector: 1.14.0
  - mail: 3.0.2
  - nextcloud_announcements: 1.15.0
  - notes: 4.7.2
  - notifications: 2.14.0
  - oauth2: 1.14.0
  - password_policy: 1.16.0
  - photos: 2.2.0
  - privacy: 1.10.0
  - provisioning_api: 1.16.0
  - recommendations: 1.5.0
  - related_resources: 1.1.0-alpha1
  - serverinfo: 1.16.0
  - settings: 1.8.0
  - sharebymail: 1.16.0
  - support: 1.9.0
  - survey_client: 1.14.0
  - systemtags: 1.16.0
  - tasks: 0.14.5
  - text: 3.7.2
  - theming: 2.1.1
  - twofactor_backupcodes: 1.15.0
  - twofactor_totp: 8.0.0-alpha.0
  - updatenotification: 1.16.0
  - user_external: 3.1.0
  - user_status: 1.6.0
  - viewer: 1.10.0
  - weather_status: 1.6.0
  - workflowengine: 2.8.0
Disabled:
  - admin_audit: 1.16.0
  - bruteforcesettings: 2.6.0 (installed 1.4.0)
  - circles: 26.0.0 (installed 0.17.10)
  - deck: 1.9.0 (installed 1.9.0)
  - files_external: 1.18.0 (installed 1.18.0)
  - richdocuments: 8.0.0 (installed 8.0.0)
  - suspicious_login: 4.4.0
  - user_ldap: 1.16.0
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
{"reqId":"bS3ljfBSxaZEuA8SD7jO","level":0,"time":"2023-04-04T05:41:35+00:00","remoteAddr":"","user":"--","app":"files_external","method":"","url":"--","message":"Forbidden","userAgent":"--","version":"26.0.0.11","exception":{"Exception":"Sabre\\HTTP\\ClientHttpException","Message":"Forbidden","Code":403,"Trace":[{"file":"/usr/local/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Client.php","line":367,"function":"send","class":"Sabre\\HTTP\\Client","type":"->","args":[["Sabre\\HTTP\\Request"]]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Storage/DAV.php","line":568,"function":"request","class":"Sabre\\DAV\\Client","type":"->","args":["COPY","https://external-nextcloud/public.php/webdav/myfile.pdf",null,["https://external-nextcloud/public.php/webdav/myfile.pdf.encrypted.1680586894"]]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php","line":287,"function":"copy","class":"OC\\Files\\Storage\\DAV","type":"->","args":["myfile.pdf","myfile.pdf.encrypted.1680586894"]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Storage/Wrapper/Availability.php","line":304,"function":"copy","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->","args":["myfile.pdf","myfile.pdf.encrypted.1680586894"]},{"file":"/usr/local/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php","line":287,"function":"copy","class":"OC\\Files\\Storage\\Wrapper\\Availability","type":"->","args":["myfile.pdf","myfile.pdf.encrypted.1680586894"]},{"file":"/usr/local/www/nextcloud/lib/private/Files/View.php","line":936,"function":"copy","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->","args":["myfile.pdf","myfile.pdf.encrypted.1680586894"]},{"file":"/usr/local/www/nextcloud/apps-pkg/encryption/lib/Crypto/EncryptAll.php","line":305,"function":"copy","class":"OC\\Files\\View","type":"->","args":["*** sensitive parameters replaced ***","/myuser/files/remoteshare/myfile.pdf.encrypted.1680586894"]},{"file":"/usr/local/www/nextcloud/apps-pkg/encryption/lib/Crypto/EncryptAll.php","line":278,"function":"encryptFile","class":"OCA\\Encryption\\Crypto\\EncryptAll","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/usr/local/www/nextcloud/apps-pkg/encryption/lib/Crypto/EncryptAll.php","line":226,"function":"encryptUsersFiles","class":"OCA\\Encryption\\Crypto\\EncryptAll","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/usr/local/www/nextcloud/apps-pkg/encryption/lib/Crypto/EncryptAll.php","line":172,"function":"encryptAllUsersFiles","class":"OCA\\Encryption\\Crypto\\EncryptAll","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/usr/local/www/nextcloud/apps-pkg/encryption/lib/Crypto/Encryption.php","line":533,"function":"encryptAll","class":"OCA\\Encryption\\Crypto\\EncryptAll","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/usr/local/www/nextcloud/core/Command/Encryption/EncryptAll.php","line":116,"function":"encryptAll","class":"OCA\\Encryption\\Crypto\\Encryption","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/usr/local/www/nextcloud/3rdparty/symfony/console/Command/Command.php","line":255,"function":"execute","class":"OC\\Core\\Command\\Encryption\\EncryptAll","type":"->","args":["*** sensitive parameters replaced ***","*** sensitive parameters replaced ***"]},{"file":"/usr/local/www/nextcloud/3rdparty/symfony/console/Application.php","line":1009,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->","args":["*** sensitive parameters replaced ***","*** sensitive parameters replaced ***"]},{"file":"/usr/local/www/nextcloud/3rdparty/symfony/console/Application.php","line":273,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->","args":[["OC\\Core\\Command\\Encryption\\EncryptAll"],"*** sensitive parameters replaced ***","*** sensitive parameters replaced ***"]},{"file":"/usr/local/www/nextcloud/3rdparty/symfony/console/Application.php","line":149,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->","args":["*** sensitive parameters replaced ***","*** sensitive parameters replaced ***"]},{"file":"/usr/local/www/nextcloud/lib/private/Console/Application.php","line":215,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->","args":["*** sensitive parameters replaced ***","*** sensitive parameters replaced ***"]},{"file":"/usr/local/www/nextcloud/console.php","line":100,"function":"run","class":"OC\\Console\\Application","type":"->","args":[]},{"file":"/usr/local/www/nextcloud/occ","line":11,"args":["/usr/local/www/nextcloud/console.php"],"function":"require_once"}],"File":"/usr/local/www/nextcloud/3rdparty/sabre/http/lib/Client.php","Line":163,"message":"Forbidden","exception":{},"CustomMessage":"Forbidden"}}
Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps-pkg/encryption/lib/Crypto/EncryptAll.php around lines 226-305, following the call from core/Command/Encryption/EncryptAll.php, and reproduce the failure with occ encryption:encrypt-all against a broken federated share. Trace how the DAV 403 from the remote file is handled; done means the command continues processing other files and users instead of aborting.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, distributed-systems, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.