Skip to content

Renaming a file that contains "+" character in filename causes file to be unreadable (v 7.0.2) #10746

Closed

Description

@rolandu

Hi,

After upgrading owncloud 6 to 7.0.2 I am unable to access some of my files. Most files work, some don't. I believe all of the not-working files are zip-files.

I am getting different error messages depending on application:

  • Transmit for Mac: "Could not change directory to 'files'. The specified path is not a folder"
  • OmniFocus for iPhone (trying to sync): Error 403 in response to GET ...
  • Owncloud Web Interface: "Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you." (note: it is not a shared file)

Would appreciate any help.

Activity

  1. rolandu commented on Aug 30, 2014

    @rolandu
    Author

    Some additional details: The unreadable files were uploaded by OmniFocus, but not all the files of OmniFocus are unreadable, just some of the zip files. Does OwnCloud handle zip files in a special way that might cause problems?

    I checked the logs and found these messages; not sure if they have to do with the problem:
    curl_setopt_array(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set at /www/htdocs/w010a165/owncloud/3rdparty/sabre/dav/lib/Sabre/DAV/Client.php#466
    set shareFileKeyFailed (code: 10): Cannot mutliKeyDecrypt empty plain content
    Undefined index: mime at /www/htdocs/w010a165/owncloud/apps/files/ajax/mimeicon.php#4
    set shareFileKeyFailed (code: 20): multiKeyDecrypt with share-keyfailed: error:0407106B:rsa routines:RSA_padding_check_PKCS1_type_2:block type is not 02

  2. karlitschek commented on Aug 31, 2014

    @karlitschek
    Contributor

    @schiesbn any idea?

  3. PVince81 commented on Sep 1, 2014

    @PVince81
    Contributor

    Can you please use the issue template: https://raw.github.com/owncloud/core/master/issue_template.md

    From the logs I'm guessing that you have the encryption app enabled.
    Do you have any third party apps enabled ? Do you use the "files_archive" app maybe ?

    Apart from the "files_archive" app, there is no special handling for zip files inside of ownCloud.

    When OmniFocus uploads new files, are these files readable ?
    Are these Zip files bigger than other files ? (in case it's a size issue)

  4. rolandu commented on Sep 1, 2014

    @rolandu
    Author

    Yes, I have encryption enabled, but not files_archive.

    New uploaded zip files are also unreadable. I already tried to set up sync again in another directory, which also resulted in unreachable zip-files.

    I tried to check whether the filename (special characters or length) caused the problem, but they didn't. The files are neither empty nor very large, they contain about 1KB of data each. OmniFocus appears to create a file each time it syncs to allow other clients to sync incrementally.

    I doubt that it is a problem with OmniFocus as the problems occured immediately after upgrading OwnCloud and OmniFocus has been working for many months without any problems.

    Steps to reproduce

    1.) Set up OmniFocus 2.0.2 for mac to sync through a directory within owncloud.
    2.) Run an initial sync.
    3.) The chosen webdav directory will now contain a .client-file, a contents.xml and a .zip file. Further sync operations through the same client will create additional .zip files
    4.) zip-files are unreadable on webdav - through the web interface, through a webdav client and by other OmniFocus installations (it appears that the one OmniFocus client that uploaded the zip file does not try to read them again but other clients trying to sync will fail to do so).

    Expected behaviour

    • Files uploaded to webdav should be readable no matter what.

    Actual behaviour

    • zip-files uploaded by OmniFocus are unreadable.

    Server configuration

    Operating system: Linux dd19014 3.2.0-64-generic #97-Ubuntu SMP Wed Jun 4 22:04:21 UTC 2014 x86_64

    Web server: Apache 2.0 Handler

    Database: MySQL 5.5.35

    PHP version: 5.4.26

    ownCloud version: 7.0.2

    Updated from an older ownCloud or fresh install: older

    List of activated apps:

    • Activity
    • Calendar
    • Contacts
    • Deleted Files
    • Documents
    • Encryption
    • First Run Wizard
    • Full Text Search
    • ownCloud dependencies info
    • PDF Viewer
    • Pictures
    • Share Files
    • Text Editor
    • Updater
    • Versions
    • Video Viewer

    The content of config/config.php:

    'ocd08d3bf7e2', 'passwordsalt' => '', 'trusted_domains' => array ( 0 => '', ), 'datadirectory' => '/www/htdocs//data', 'dbtype' => 'mysql', 'version' => '7.0.2.1', 'dbname' => '', 'dbhost' => 'localhost', 'dbtableprefix' => '', 'dbuser' => '', 'dbpassword' => '', 'installed' => true, 'overwritehost' => 'ssl-account.com', 'overwriteprotocol' => 'https', 'overwritewebroot' => '', 'overwritecondaddr' => '^\.\.\.$', 'forcessl' => true, 'loglevel' => '2', 'theme' => '', 'maintenance' => false, ); **Are you using external storage, if yes which one:** no **Are you using encryption:** yes ### Client configuration **Browser:** Various. ### Logs #### Web server error log Hosted service. Don't have access to server logs. ### WebDav Client ("Transmit" for Mac) log GET //remote.php/webdav//20140829185606%3DimuDXXcPgAJ%2BdAuFA2JwiVW.zip HTTP/1.1 Could not read status line: connection was closed by server PROPFIND //apps/files_encryption/files/ HTTP/1.1 302 Found #### ownCloud log (data/owncloud.log) _(I believe these are the relevant parts)_ {"app":"files_encryption","message":"set shareFileKeyFailed (code: 20): multiKeyDecrypt with share-keyfailed: error:0407106B:rsa routines:RSA_padding_check_PKCS1_type_2:block type is not 02","level":4,"time":"2014-09-01T19:25:52+00:00"} {"app":"files_encryption","message":"set shareFileKeyFailed (code: 10): Cannot mutliKeyDecrypt empty plain content","level":4,"time":"2014-09-01T19:31:12+00:00"}
  5. PVince81 commented on Sep 1, 2014

    @PVince81
    Contributor

    Very strange. What OC 6 version did you have before when everything worked ? OC 6.0.4 ?
    I'm not sure what changed regarding encryption but I don't think it should affect zip files that way.

    Are you able to upload sane ZIP files manually through the web interface or WebDAV and download them again ? (bypassing Omnifocus)

    Just want to confirm that it's really Omnifocus that does something that messes up in ownCloud.
    Maybe it's trying to use HTTP range requests for upload ? (maybe splitting the file in multiple chunks). But I don't think this is supported by OC anyway.

  6. rolandu commented on Sep 2, 2014

    @rolandu
    Author

    Yes, zip files uploaded through Transmit work well, even if put into the same location and carrying the same name as OmniFocus files.

  7. rolandu commented on Sep 2, 2014

    @rolandu
    Author

    Ok, I think I have located the problem: It seems that OF is uploading files named in the format "[something].zip-write-in-progress-[somethingelse]" and then immediately after upload renames them to "[something].zip".

    I don't know how the OC encryption system works but I have found that the files_encryption/share-keys directory contains one ".client.[username].sharekey" for each file in my files directry. However, in case of OmniFocus all files in my files directory are named ".zip" and all the share-keys are named ".zip.write-in-progress-[somethingelse].client.[username].sharekey. So it appears that the file gets encrypted after it is uploaded but the renaming is not propagated to the sharekey directory.

    It definitely has to do something with renaming... probably with filename length or special characters or the way renaming is handled by the encryption app.

    I am now able to recreate the problem manually:
    1.) Upload a zip file through webdav.
    2.) Name it "20140829185547=mV-zmASDxGD+nzUvJUmGeTp.zip"
    3.) Confirm the file is still readable at this point.
    4.) Rename file to "20140829185547=mV-zmASDxGD+nzUvJUmGeTpx.zip" (note I added an "x" before the ".zip").
    5.) File now unreadable through webdav. Owncloud web interface shows an encryption error. "Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you."

  8. rolandu commented on Sep 2, 2014

    @rolandu
    Author

    Ok, narrowed it down to the "+" character.

    1.) Upload any zip file called a.zip -- confirm file is readable
    2.) Rename to a+b.zip -- file still readable
    3.) Rename to a+bc.zip -- file unreadable.
    4.) Rename to a+b.zip -- file is readable again.

  9. changed the title [-]Unable to read some files after upgrade to 7.0.2[/-] [+]Renaming a file that contains "+" character in filename causes file to be unreadable (v 7.0.2)[/+] on Sep 2, 2014
  10. PVince81 commented on Sep 3, 2014

    @PVince81
    Contributor

    @rolandu thanks for your research.
    Usually issues with "+" characters are due to the web server config issue, for example plugins that try and rewrite the URL in a wrong way.
    But in such cases I would expect the server to just return a 404 instead of the error message about not being able to decrypt the file.

    Are you using an old Apache ? Your report states 2.0.

    Needs further research. That information should hopefully be enough to reproduce the issue locally.

  11. PVince81 commented on Sep 3, 2014

    @PVince81
    Contributor

    CC @schiesbn

  12. added this to the milestone on Sep 3, 2014
  13. 8 remaining items

  14. rolandu commented on Oct 7, 2014

    @rolandu
    Author

    Is the demo-site encrypted? It was mentioned that this appears to be a problem with the encryption module.

    On 07.10.2014, at 10:18, Vincent Petry [email protected] wrote:

    Not sure why you guys are having such issues.

    I went over to demo.owncloud.org (which runs OC 7.0.2) and created a folder called "test special + % chars" over the UI.
    Then I created a text file inside called "plus + and percent %.txt"

    Then when extracting the zip file:

    % unzip test\ special\ +\ %\ chars.zip
    Archive: test special + % chars.zip
    creating: test special + % chars/
    extracting: test special + % chars/plus + and percent %.txt
    All is fine.

    Then I renamed both the file and folder to a different name also containing "+" and "%", it worked fine as well.

    Then I tried renaming both using the WebDAV interface, it also worked without problems.

    Would be good if you guys @ttl76543 @utack could compare your environments / PHP modules, maybe there's a pattern to be found that would help find out what is interfering with the URLs.

    @ttl76543 do you have two running OC instances in the same environment ? Are you sure the env itself didn't change between your upgrades ? (like distro update or PHP module updates)

    —
    Reply to this email directly or view it on GitHub.

  15. PVince81 commented on Oct 7, 2014

    @PVince81
    Contributor

    I believet the demo site is not encrypted.

    I just tried the same steps on my private ownCloud which is 7.0.2 and encryption and managed to reproduce the issue with WebDAV renaming and "+" or "%" special chars.

    Will try and narrow down the exact step and post them.

  16. PVince81 commented on Oct 7, 2014

    @PVince81
    Contributor

    Steps to reproduce:

    1. Enable encryption
    2. Create a folder called "a plus +"
    3. Inside the folder create a text file called "text plus +.txt" with some contents
    4. Go back to the root
    5. Download the folder "a plus +" by clicking on its "Download" link, check the zip file contents
    6. Using a WebDAV client (I used KDE 4's dolphin), rename "a plus +" to "a plus + renamed"
    7. Repeat step 5 to download the folder
    8. Using WebDAV again, rename the file from "text plus +.txt" to "text plus + renamed.txt"
    9. Repeat step 5 to download the folder

    Expected result

    Folder can be downloaded as ZIP

    Actual result

    At step 9, downloaded ZIP file is empty

    Versions

    ownCloud 7.0.2

    Env

    openSUSE 13.1 x86_64
    Apache 2.4
    PHP 5.4.20

    Edit: fixed report as I forgot to refresh the page while testing

  17. PVince81 commented on Oct 7, 2014

    @PVince81
    Contributor

    @rolandu in your comment #10746 (comment) did you mean "rename with WebDAV" or "rename in OmniFocus" ?

    Because it seems that renaming over the Web UI doesn't trigger the issue. Key is renaming with WebDAV.

    Next up: trying to rename with cadaver and the sync client

  18. PVince81 commented on Oct 7, 2014

    @PVince81
    Contributor

    Now I'm really confused.
    Sometimes it works, sometimes it doesn't.

    A folder that I tried to download at first appeared as an empty ZIP file. But then I went into that folder and downloaded the text file and I could open it without issues. And after that suddenly downloading the folder worked again...

  19. PVince81 commented on Oct 7, 2014

    @PVince81
    Contributor

    Managed to reproduce it with shorter steps and folder without special chars:

    1. Enable encryption
    2. Create folder "a folder"
    3. Create non-empty file (important!) called "text plus +.txt" inside that folder
    4. Download "a folder" as zip: works
    5. With WebDAV, rename the file to "text plus + renamed again.txt"

    Getting this in the logs:

    {"reqId":"5433b40e09fc1","app":"webdav","message":"Sabre\\DAV\\Exception\\NotFound: File with name a folder\/text plus + renamed again.txt could not be located","level":0,"time":"2014-10-07T09:36:14+00:00","method":"PROPFIND","url":"\/owncloud\/remote.php\/webdav\/a%20folder\/text%20plus%20+%20renamed%20again.txt"}
    {"reqId":"5433b40e313c7","app":"PHP","message":"json_encode(): Invalid UTF-8 sequence in argument at \/srv\/www\/htdocs\/owncloud\/lib\/private\/log\/owncloud.php#86","level":3,"time":"2014-10-07T09:36:14+00:00","method":"MOVE","url":"\/owncloud\/remote.php\/webdav\/a%20folder\/text%20plus%20+.txt"}
    {"reqId":"5433b40e313c7","app":"files_encryption","message":null,"level":4,"time":"2014-10-07T09:36:14+00:00","method":"MOVE","url":"\/owncloud\/remote.php\/webdav\/a%20folder\/text%20plus%20+.txt"}
    
  20. PVince81 commented on Oct 7, 2014

    @PVince81
    Contributor

    Seems I need to rename the file multiple times before it happens.
    And when it does:

    {"reqId":"5433b4daf04c3","app":"webdav","message":"Sabre\\DAV\\Exception\\NotFound: File with name a folder + renamed\/text plus + renamed again xxxxxxxxxxx.txt could not be located","level":0,"time":"2014-10-07T09:39:38+00:00","method":"PROPFIND","url":"\/owncloud\/remote.php\/webdav\/a%20folder%20+%20renamed\/text%20plus%20+%20renamed%20again%20xxxxxxxxxxx.txt"}
    {"reqId":"5433b4db22f73","app":"files_encryption","message":"set shareFileKeyFailed (code: 20): multiKeyDecrypt with share-keyfailed: error:0407106B:rsa routines:RSA_padding_check_PKCS1_type_2:block type is not 02","level":4,"time":"2014-10-07T09:39:39+00:00","method":"MOVE","url":"\/owncloud\/remote.php\/webdav\/a%20folder%20+%20renamed\/text%20plus%20+%20renamed%20again.txt"}
    {"reqId":"5433b4dfbf504","app":"PHP","message":"Cannot modify header information - headers already sent by (output started at \/srv\/www\/htdocs\/owncloud\/3rdparty\/mcnetic\/phpzipstreamer\/ZipStreamer.php:237) at \/srv\/www\/htdocs\/owncloud\/apps\/files_encryption\/lib\/helper.php#378","level":3,"time":"2014-10-07T09:39:43+00:00","method":"GET","url":"\/owncloud\/index.php\/apps\/files\/ajax\/download.php?dir=%2F&files=a%20folder%20%2B%20renamed"}
    
  21. PVince81 commented on Oct 7, 2014

    @PVince81
    Contributor

    I had a look in the encryption folders and the share keys haven't been renamed:

    keyfiles/a folder + renamed:
    total 4.0K
    -rw-r--r-- 1 wwwrun www 44 Oct  7 11:39 text plus + renamed again xxxxxxxxxxx.txt.key
    
    share-keys/a folder + renamed:
    total 4.0K
    -rw-r--r-- 1 wwwrun www 512 Oct  7 11:39 text plus + renamed again.txt.root.shareKey
    

    I think I know what's happening: the encryption code had some unescaped regex when trying to match share keys... and characters like "+" and "%" are likely to mess up a regex...

    This also means that not ALL file names containing with "+" will fail renaming, only such that are likely to mess up regexes.

    The original issue is here: #11127
    It's already fixed on stable7 (the upcoming 7.0.3).

    Just tried stable7 and couldn't reproduce the issue there.

    The fix is here #11137 in case you'd like to patch your setup.
    Would be good to try it out and confirm whether it indeed fixes the issue for you as well.

    Thanks.

  22. modified the milestones: , on Oct 12, 2014
  23. modified the milestones: , on Oct 27, 2014
  24. PVince81 commented on Oct 27, 2014

    @PVince81
    Contributor

    Closing, this should be fixed already in 7.0.3 RC1.

    If you still experience the issue in that version, feel free to reopen.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions