Skip to content
Closed
Changes from 1 commit
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
Next Next commit
fix(dav): Restrict properties allowed object classes
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc authored and backportbot[bot] committed Oct 20, 2025
commit 5ed02235035fb1cc4e865c44bf430e5ccc5a903d
17 changes: 15 additions & 2 deletions apps/dav/lib/DAV/CustomPropertiesBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,19 @@ private function encodeValueForDatabase($value): array {
$valueType = self::PROPERTY_TYPE_XML;
$value = $value->getXml();
} else {
if (!is_object($value)) {
throw new DavException(
"Property \"$name\" has an invalid value of type " . gettype($value),
);
}
if (!str_starts_with($value::class, 'Sabre\\DAV\\Xml\\Property\\')
&& !str_starts_with($value::class, 'Sabre\\CalDAV\\Xml\\Property\\')
&& !str_starts_with($value::class, 'Sabre\\CardDAV\\Xml\\Property\\')
&& !str_starts_with($value::class, 'OCA\\DAV\\')) {
throw new DavException(
"Property \"$name\" has an invalid value of class " . $value::class,
);
}
$valueType = self::PROPERTY_TYPE_OBJECT;
$value = serialize($value);
}
Expand All @@ -435,7 +448,7 @@ private function encodeValueForDatabase($value): array {
/**
* @return mixed|Complex|string
*/
private function decodeValueFromDatabase(string $value, int $valueType) {
private function decodeValueFromDatabase(string $value, int $valueType): mixed {
switch ($valueType) {
case self::PROPERTY_TYPE_XML:
return new Complex($value);
Expand All @@ -444,7 +457,7 @@ private function decodeValueFromDatabase(string $value, int $valueType) {
case self::PROPERTY_TYPE_STRING:
default:
return $value;
}
};
}

private function createDeleteQuery(): IQueryBuilder {
Expand Down