nextcloud / nextcloud/server

All shared files: "Can not decrypt this file, probably this is a shared file."

Open
#28,862 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

How to use GitHub
  • Please use the šŸ‘ reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.
Steps to reproduce
  1. Share link of any kind of files like PDFs, zip files, text files and images etc.
  2. Open or download the files
  3. Opening files like PDF and text files returns an error on the web interface and when downloaded, it downloads an HTML file that is 4.5kb with an error.
Expected behaviour

Shows and downloads the files through the shared link without any problems

Actual behaviour

The owner of the shared link can access the files so it does not seem to be corrupted. It just gets corrupted when it is shared. Also re-shared the files many times and still same problem occurs.

  • Opening PDFs:
    image

  • Opening text files (.md or .txt): does not show the content just white screen

  • Opening images: shows the image preview but download fails

  • Downloading all the files: downloads an 4.5 KB HTML file instead like the following:

$ file image.png
image.png: HTML document, UTF-8 Unicode text, with very long lines

Here is the content of the HTML document:

                                    <div class="error">
    <h2>Error</h2>
    <ul>
                    <li>
                    <p>Can&#039;t read file</p>
                                                    <p class='hint'>Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.</p>
                                    </li>
            </ul>
Server configuration

Operating system: Debian 9.13 (stretch)

Web server: nginx 1.10.3

Database: MariaDB 10.1.48

PHP version: 7.2

Nextcloud version: 20.0.12

Updated from an older Nextcloud/ownCloud or fresh install: updated from an older version. The problem started since version 18.0.6 .

Where did you install Nextcloud from: Nextcloud website

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
Enabled:
  - accessibility: 1.6.0
  - activity: 2.13.4
  - admin_audit: 1.10.0
  - apporder: 0.13.0
  - bruteforcesettings: 2.2.0
  - calendar: 2.3.2
  - cloud_federation_api: 1.3.0
  - comments: 1.10.0
  - contacts: 4.0.1
  - contactsinteraction: 1.1.0
  - dashboard: 7.0.0
  - dav: 1.16.2
  - drop_account: 1.0.2
  - encryption: 2.8.1
  - external: 3.7.3
  - federatedfilesharing: 1.10.2
  - federation: 1.10.1
  - files: 1.15.0
  - files_pdfviewer: 2.0.1
  - files_rightclick: 0.17.0
  - files_sharing: 1.12.2
  - files_trashbin: 1.10.1
  - files_videoplayer: 1.9.0
  - logreader: 2.5.0
  - lookup_server_connector: 1.8.0
  - mail: 1.6.0
  - notes: 4.0.4
  - notifications: 2.8.0
  - oauth2: 1.8.0
  - password_policy: 1.10.1
  - photos: 1.2.3
  - provisioning_api: 1.10.0
  - quota_warning: 1.9.1
  - recommendations: 0.8.0
  - serverinfo: 1.10.0
  - settings: 1.2.0
  - sharebymail: 1.10.0
  - tasks: 0.14.1
  - text: 3.1.0
  - theming: 1.11.0
  - twofactor_backupcodes: 1.9.0
  - twofactor_totp: 5.0.0
  - updatenotification: 1.10.0
  - user_status: 1.0.1
  - viewer: 1.4.0
  - weather_status: 1.0.0
  - workflowengine: 2.2.0

Nextcloud configuration:

Config report
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "20.0.12.1",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "forcessl": true,
        "enable_avatars": false,
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "log_authfailip": true,
        "loglevel": 2,
        "maintenance": false,
        "customclient_desktop": "https:\/\/***REMOVED SENSITIVE VALUE***\/en\/downloads",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***"
        ],
        "share_folder": "\/Shared",
        "overwritewebroot": "\/",
        "overwriteprotocol": "https",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "singleuser": false,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "trashbin_retention_obligation": "auto,30",
        "activity_expire_days": 14,
        "logtimezone": "Europe\/Zurich",
        "log_type": "errorlog",
        "skeletondirectory": "\/var\/www\/nextcloud\/themes\/core\/skeleton",
        "overwrite.cli.url": "https:\/\/***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "LOGIN",
        "preview_max_scale_factor": 1,
        "preview_max_filesize_image": 2,
        "preview_max_x": 1024,
        "preview_max_y": 1024,
        "mysql.utf8mb4": true,
        "app_install_overwrite": [
            "drop_account"
        ],
        "encryption.legacy_format_support": true,
        "encryption.key_storage_migrated": false
    },

Are you using encryption: yes - server side encryption with user keys

Client configuration

Browser: Chrome, Firefox

Operating system: Linux / Windows / Mac OS

Logs
Web server error log
Web server error log
no errors
Nextcloud log (data/nextcloud.log)
Nextcloud log
[error] 25168#25168: *43072837 FastCGI sent in stderr: "PHP message: [owncloud][no app in context][3] Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.
PHP message: [owncloud][no app in context][3] {"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":[{"file":"/var/www/nextcloud/lib/private/Files/Stream/Encryption.php","line":501,"function":"decrypt","class":"OCA\\Encryption\\Crypto\\Encryption","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/Files/Stream/Encryption.php","line":299,"function":"readCache","class":"OC\\Files\\Stream\\Encryption","type":"->","args":[]},{"function":"stream_read","class":"OC\\Files\\Stream\\Encryption","type":"->","args":[8192]},{"file":"/var/www/nextcloud/3rdparty/icewind/streams/src/Wrapper.php","line":91,"function":"fread","args":[null,8192]},{"file":"/var/www/nextcloud/3rdparty/icewind/streams/src/CallbackWrapper.php","line":98,"function":"stream_read","class":"Icewind\\Streams\\Wrapper","type":"->","args":[8192" while reading response header from upstream, client: ***REMOVED SENSITIVE VALUE***, server: ***REMOVED SENSITIVE VALUE***, request: "GET /s/RSGxCLoYfeTQSBy/download?path=%2F&files=document.pdf HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "***REMOVED SENSITIVE VALUE***"

Browser log
Browser log for opening PDFs
Content Security Policy: The page’s settings blocked the loading of a resource at inline (ā€œscript-srcā€). 2 utils.js:35:9
Content Security Policy: The page’s settings blocked the loading of a resource at eval (ā€œscript-srcā€). global.js:10:10
Please do NOT wait for the DOMContentLoaded before registering your viewer handler Viewer.vue:217
[ERROR] Files_PDFViewer: But this does not appear to be a public page 
Object { app: "Files_PDFViewer" }
ConsoleLogger.js:54:18
Content Security Policy: The page’s settings blocked the loading of a resource at inline (ā€œscript-srcā€). utils.js:35:9
Content Security Policy: The page’s settings blocked the loading of a resource at inline (ā€œscript-srcā€). utils.js:35:9
Uncaught (in promise) Error: Invalid or corrupted PDF file.
    _callee7$/</< app.js:817
app.js:817:16

Please let me know if you need more information

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 with lib/private/Files/Stream/Encryption.php at the reported lines 299 and 501, then trace the public-share download request shown in the log. Reproduce the failure with encrypted shared PDFs, text files, images, and archives. Done means shared files open and download correctly instead of returning the decryption error HTML.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.