Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions lib/Helper/TXmlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ trait TXmlHelper {
*/
public function callWithXmlEntityLoader(callable $func): mixed {
libxml_set_external_entity_loader(static fn ($public, $system) => $system);
$result = $func();
libxml_set_external_entity_loader(static fn () => null);
try {
$result = $func();
} finally {
libxml_set_external_entity_loader(static fn () => null);
}
return $result;
}
}
12 changes: 12 additions & 0 deletions lib/UserBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ public function createUserIfNotExists(string $uid, array $attributes = []): void
$this->serverRoot . '/data') . '/' . $home;
}

// Reject paths containing directory traversal sequences
$normalizedHome = str_replace('\\', '/', $home);
if (str_contains($normalizedHome, '/../') || str_ends_with($normalizedHome, '/..')) {
$this->logger->warning(
'Rejecting home path from SAML attribute containing directory traversal sequence',
['app' => 'user_saml', 'home' => $home]
);
$home = '';
}
}

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

Expand Down
Loading