Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/UserBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,22 @@ public function createUserIfNotExists(string $uid, array $attributes = []): void
}

if ($home !== '') {
//if attribute's value is an absolute path take this, otherwise append it to data dir
//check for / at the beginning or pattern c:\ resp. c:/
$dataDir = $this->config->getSystemValueString('datadirectory', $this->serverRoot . '/data');

// note: Path traversal is allowed because we trust the idp and it allows to do partitioning
// of the storage.
//
// If attribute's value is an absolute path take this, otherwise append it to data dir
// check for / at the beginning or pattern c:\ resp. c:/
if ($home[0] !== '/'
&& !(strlen($home) > 3 && ctype_alpha($home[0])
&& $home[1] === ':' && ($home[2] === '\\' || $home[2] === '/'))
) {
$home = $this->config->getSystemValueString('datadirectory',
$this->serverRoot . '/data') . '/' . $home;
$home = $dataDir . '/' . $home;
}
}

if ($home !== '') {
$values['home'] = $home;
}

Expand Down
Loading