owncloud / owncloud/core

copying a folder within a public link folder to folder with same name as an already existing file overwrites the parent file

Open
#37,683 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type:Bug
Dominant language
PHP
Stars
8.8k
Forks
2.1k
Avg merge
20h 7m
Merged PRs (30d)
41

Description

Description

When we copy a folder (e.g testFolder) within a public link folder to a folder which has same name as an already existing file (e.g copy1.txt), then the new copied folder overwrites the previously existing file of same name.

Steps to reproduce
  1. Create a user Alice
  2. User Alice creates a folder PARENT1
  3. User Alice creates another folder PARENT1/testFolder
  4. User Alice uploads a file with content some data to PARENT1/testFolder/testfile.txt
  5. User Alice uploads a file with content some data 1 to PARENT1/copy1.txt
  6. User Alice creates a public link share with path PARENT1 and permissions read,update,create,delete
    [User gets a token in the response eg:zSr0bOKQfLbbv7C]
  7. The public copies folder testFolder to copy1.txt using new public webdav api:
curl -X COPY -H "Destination: http://localhost/core/remote.php/dav/public-files/zSr0bOKQfLbbv7C/copy1.txt" 'http://localhost/core/remote.php/dav/public-files/zSr0bOKQfLbbv7C/testFolder' -k -v
Expected behaviour

A 403 Forbidden error

Actual behaviour
 HTTP/1.1 204 No Content
 Date: Mon, 13 Jul 2020 07:59:13 GMT
 Server: Apache/2.4.29 (Ubuntu)
 Set-Cookie: oc7d03sfymph=t3ks17eksv5lbd0k3h6jd3rvhm; path=/core; HttpOnly
 Expires: Thu, 19 Nov 1981 08:52:00 GMT
 Cache-Control: no-store, no-cache, must-revalidate
 Pragma: no-cache
 Set-Cookie: oc_sessionPassphrase=%2Fjnmv9tt3noSLDBwDIXNH9co4VI%2BCcDP2GYor7ez%2FhD96neYW6RAlCPYGm9aCP57k4EfH3D7Sy%2Fc78qPKftCTw%2BA6U9ecjqtoATNbih3ME3oCnrFdSIv9xqPgwE2G444; path=/core; HttpOnly; SameSite=strict
 Content-Security-Policy: default-src 'none';
 X-XSS-Protection: 1; mode=block
 X-Content-Type-Options: nosniff
 X-Frame-Options: SAMEORIGIN
 X-Robots-Tag: none
 X-Download-Options: noopen
 X-Permitted-Cross-Domain-Policies: none
Checking Content

To make sure if the file has been overwritten:

curl -X GET http://localhost/core/remote.php/webdav/PARENT1/copy1.txt/testfile.txt -u alice:1234 -k

some data%  

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 at the public WebDAV API endpoint used by the COPY request and reproduce the folder-to-existing-file case from the listed curl command. Trace how the destination is resolved and run the relevant WebDAV tests, adding coverage for the expected 403 Forbidden response without losing the existing file.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.