☁️ Nextcloud server, a safe home for all your data
Find a file
Lukas Reschke 155ae44bc6 Fix collision on temporary files + adjust permissions
This changeset hardens the temporary file and directory creation to address multiple problems that may lead to exposure of files to other users, data loss or other unexpected behaviour that is impossible to debug.

**[CWE-668: Exposure of Resource to Wrong Sphere](https://cwe.mitre.org/data/definitions/668.html)**
The temporary file and folder handling as implemented in ownCloud is performed using a MD5 hash over `time()` concatenated with `rand()`. This is insufficiently and leads to the following security problems:
The generated filename could already be used by another user. It is not verified whether the file is already used and thus temporary files might be used for another user as well resulting in all possible stuff such as "user has file of other user".

Effectively this leaves us with:

1. A timestamp based on seconds (no entropy at all)
2. `rand()` which returns usually a number between 0 and 2,147,483,647

Considering the birthday paradox and that we use this method quite often (especially when handling external storage) this is quite error prone and needs to get addressed.

This behaviour has been fixed by using `tempnam` instead for single temporary files. For creating temporary directories an additional postfix will be appended, the solution is for directories still not absolutely bulletproof but the best I can think about at the moment. Improvement suggestions are welcome.

**[CWE-378: Creation of Temporary File With Insecure Permissions](https://cwe.mitre.org/data/definitions/378.html)**

Files were created using `touch()` which defaults to a permission of 0644. Thus other users on the machine may read potentially sensitive information as `/tmp/` is world-readable. However, ownCloud always encourages users to use a dedicated machine to run the ownCloud instance and thus this is no a high severe issue. Permissions have been adjusted to 0600.

**[CWE-379: Creation of Temporary File in Directory with Incorrect Permissions](https://cwe.mitre.org/data/definitions/379.html)**

Files were created using `mkdir()` which defaults to a permission of 0777. Thus other users on the machine may read potentially sensitive information as `/tmp/` is world-readable. However, ownCloud always encourages users to use a dedicated machine to run the ownCloud instance and thus this is no a high severe issue. Permissions have been adjusted to 0700.Please enter the commit message for your changes.
2015-04-23 15:07:54 +02:00
.idea
3rdparty@0f862d433a update 3rdparty submodule 2015-03-26 11:09:05 +01:00
apps [tx-robot] updated from transifex 2015-04-23 01:54:51 -04:00
build Further cleanup of files_encryption 2015-04-07 13:30:28 +02:00
config Memcache\Redis Add DB Select Functionality 2015-04-15 21:24:38 +01:00
core [tx-robot] updated from transifex 2015-04-23 01:54:51 -04:00
l10n files_encryption -> encryption 2015-04-14 16:18:12 +02:00
lib Fix collision on temporary files + adjust permissions 2015-04-23 15:07:54 +02:00
ocs Fix usage of deprecated private constants 2015-04-18 10:30:02 +02:00
settings [tx-robot] updated from transifex 2015-04-23 01:54:51 -04:00
tests Fix collision on temporary files + adjust permissions 2015-04-23 15:07:54 +02:00
themes
.bowerrc
.gitignore implement basic encryption functionallity in core to enable multiple encryption modules 2015-03-26 20:56:51 +01:00
.gitmodules
.htaccess Merge pull request #15042 from wolfgangkarall/master 2015-03-30 16:22:36 +02:00
.jshintrc
.mailmap Updating email of nickvergessen and georg 2015-03-26 11:38:40 +01:00
.scrutinizer.yml
.tag
.user.ini
AUTHORS
autotest-external.sh
autotest-hhvm.sh
autotest-js.sh
autotest.cmd
autotest.sh [autotest.sh] use the DATABASEHOST for the mysql DB drop 2015-04-10 14:46:08 +02:00
bower.json
buildjsdocs.sh
console.php Introduce own console application class 2015-04-09 16:28:53 +02:00
CONTRIBUTING.md Make the link to issue template bold 2015-03-25 05:21:43 +01:00
COPYING-AGPL
COPYING-README
cron.php Removed OC_BackgroundJob - reduce class overhead 2015-04-18 23:37:32 +02:00
db_structure.xml
index.html
index.php Update license headers 2015-03-26 11:44:36 +01:00
indie.json
issue_template.md
occ
public.php Fix singe user mode on public.php - take two 2015-04-10 11:17:33 +02:00
README.md
remote.php Update license headers 2015-03-26 11:44:36 +01:00
robots.txt
status.php Fix maintenance refresh interval 2015-04-08 18:02:00 +02:00
version.php 8.1.0 alpha 2 2015-04-15 23:55:25 +02:00

ownCloud

ownCloud gives you freedom and control over your own data. A personal cloud which runs on your own server.

Build Status on Jenkins CI

Git master: Build Status

Quality:

  • Scrutinizer: Scrutinizer Quality Score
  • CodeClimate: Code Climate

Depencencies:

Dependency Status

Dependency Status

Installation instructions

https://doc.owncloud.org/server/8.0/developer_manual/app/index.html

Contribution Guidelines

https://owncloud.org/contribute/

Get in touch

Important notice on translations

Please submit translations via Transifex: https://www.transifex.com/projects/p/owncloud/

Transifex

For more detailed information about translations: http://doc.owncloud.org/server/8.0/developer_manual/core/translation.html