155ae44bc6
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. |
||
---|---|---|
.. | ||
app | ||
appframework | ||
archive | ||
assetic | ||
backgroundjob | ||
cache | ||
command | ||
connector/sabre | ||
console | ||
contacts | ||
db | ||
diagnostics | ||
encryption | ||
files | ||
group | ||
hooks | ||
http/client | ||
l10n | ||
legacy | ||
log | ||
memcache | ||
ocs | ||
preview | ||
route | ||
search | ||
security | ||
session | ||
setup | ||
share | ||
tagging | ||
template | ||
user | ||
activitymanager.php | ||
allconfig.php | ||
api.php | ||
app.php | ||
appconfig.php | ||
apphelper.php | ||
archive.php | ||
arrayparser.php | ||
avatar.php | ||
avatarmanager.php | ||
cache.php | ||
config.php | ||
contactsmanager.php | ||
databaseexception.php | ||
databasesetupexception.php | ||
datetimeformatter.php | ||
datetimezone.php | ||
db.php | ||
defaults.php | ||
eventsource.php | ||
filechunking.php | ||
files.php | ||
forbiddenexception.php | ||
group.php | ||
helper.php | ||
hintexception.php | ||
hook.php | ||
httphelper.php | ||
image.php | ||
installer.php | ||
json.php | ||
l10n.php | ||
largefilehelper.php | ||
log.php | ||
mimetypes.list.php | ||
naturalsort.php | ||
naturalsort_defaultcollator.php | ||
navigationmanager.php | ||
needsupdateexception.php | ||
notsquareexception.php | ||
ocs.php | ||
ocsclient.php | ||
preview.php | ||
previewmanager.php | ||
repair.php | ||
repairexception.php | ||
repairstep.php | ||
response.php | ||
search.php | ||
server.php | ||
servernotavailableexception.php | ||
serviceunavailableexception.php | ||
setup.php | ||
subadmin.php | ||
systemconfig.php | ||
tagmanager.php | ||
tags.php | ||
template.php | ||
templatelayout.php | ||
tempmanager.php | ||
updater.php | ||
urlgenerator.php | ||
user.php | ||
util.php |