Skip to content

Overwrite readonly shared file over Webdav gives 500 instead of 403 #15026

Closed

Description

@PVince81

Steps to reproduce

  1. Create two users "user1" and "user2"
  2. Login as "user1"
  3. Share a file "readonly.txt" with "user2" and remove the "can edit" permission
  4. Login as "user2" with cadaver
  5. put test.txt readonly.txt
  6. Try uploading a file "readonly.txt" with the web UI and overwrite that file

Expected result

WebDAV: 403 Forbidden
Web UI: Should show an error message

Actual result

WebDAV: 500 Internal Server Error
Web UI: no error message, file refreshes as if it had worked, but still contains old content

Versions

OC 7.0.5, stable8, master

owncloud.log

This is from the WebDAV call:

{"reqId":"550a9c27025ab","app":"webdav","message":"\\OC\\Files\\Filesystem::rename() failed","level":3,"time":"2015-03-19T09:51:35+00:00","method":"PUT","url":"\/owncloud\/remote.php\/webdav\/readonly.txt"}
{"reqId":"550a9c27025ab","app":"webdav","message":"Sabre\\DAV\\Exception: Could not rename part file to final file","level":4,"time":"2015-03-19T09:51:35+00:00","method":"PUT","url":"\/owncloud\/remote.php\/webdav\/readonly.txt"}
{"reqId":"550a9c27025ab","app":"webdav","message":"Exception: #1 [internal function]: Sabre\\DAV\\Server->httpPut('readonly.txt')","level":4,"time":"2015-03-19T09:51:35+00:00","method":"PUT","url":"\/owncloud\/remote.php\/webdav\/readonly.txt"}
{"reqId":"550a9c27025ab","app":"webdav","message":"Exception: #2 \/srv\/www\/htdocs\/owncloud\/3rdparty\/sabre\/dav\/lib\/Sabre\/DAV\/Server.php(474): call_user_func(Array, 'readonly.txt')","level":4,"time":"2015-03-19T09:51:35+00:00","method":"PUT","url":"\/owncloud\/remote.php\/webdav\/readonly.txt"}
{"reqId":"550a9c27025ab","app":"webdav","message":"Exception: #3 \/srv\/www\/htdocs\/owncloud\/3rdparty\/sabre\/dav\/lib\/Sabre\/DAV\/Server.php(214): Sabre\\DAV\\Server->invokeMethod('PUT', 'readonly.txt')","level":4,"time":"2015-03-19T09:51:35+00:00","method":"PUT","url":"\/owncloud\/remote.php\/webdav\/readonly.txt"}
{"reqId":"550a9c27025ab","app":"webdav","message":"Exception: #4 \/srv\/www\/htdocs\/owncloud\/apps\/files\/appinfo\/remote.php(60): Sabre\\DAV\\Server->exec()","level":4,"time":"2015-03-19T09:51:35+00:00","method":"PUT","url":"\/owncloud\/remote.php\/webdav\/readonly.txt"}
{"reqId":"550a9c27025ab","app":"webdav","message":"Exception: #5 \/srv\/www\/htdocs\/owncloud\/remote.php(52): require_once('\/srv\/www\/htdocs...')","level":4,"time":"2015-03-19T09:51:35+00:00","method":"PUT","url":"\/owncloud\/remote.php\/webdav\/readonly.txt"}
{"reqId":"550a9c27025ab","app":"webdav","message":"Exception: #6 {main}","level":4,"time":"2015-03-19T09:51:35+00:00","method":"PUT","url":"\/owncloud\/remote.php\/webdav\/readonly.txt"}

The web UI call doesn't produce any log entries.

Maybe a permission check is missing somewhere.
Note that this is only for file shares (files shared directly, not through a read-only shared folder)

The issue isn't that bad, but note that a 500 instead of 403 could mess up with the sync client and/or get the file blacklisted from sync.

Activity

  1. added this to the milestone on Mar 19, 2015
  2. self-assigned this
    on Mar 19, 2015
  3. PVince81 commented on Mar 20, 2015

    @PVince81
    ContributorAuthor

    It looks like the permissions aren't read properly. Even though the share permission of "readonly.txt" is 17, we got 27 which contains the "updatable" flag. So it bypasses the permission check on upload.

  4. PVince81 commented on Mar 20, 2015

    @PVince81
    ContributorAuthor

    I debugged through the code and saw that the share permissions 17 were retrieved properly. Then some part of code added the delete permission (unshare from self), so it became 25.

    And then it reached that line: https://github.com/owncloud/core/blob/master/lib/private/files/view.php#L1136 that would automatically add delete+update permissions...

  5. PVince81 commented on Mar 20, 2015

    @PVince81
    ContributorAuthor

    Fix is here: #15063

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions