Skip to content
Merged
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
19 changes: 18 additions & 1 deletion lib/MatterbridgeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function editBridgeOfRoom(Room $room, string $userId, bool $enabled, arra
$newBridge = [
'enabled' => $enabled,
'pid' => $currentBridge['pid'] ?? 0,
'parts' => $parts,
'parts' => $this->validateParts($parts),
];

$this->notify($room, $userId, $currentBridge, $newBridge);
Expand Down Expand Up @@ -335,6 +335,7 @@ private function generatePassword(): string {
private function generateConfig(array $bridge): string {
$content = '';
foreach ($bridge['parts'] as $k => $part) {
$k = (int)$k;
$type = $part['type'];

if ($type === 'nctalk') {
Expand Down Expand Up @@ -494,6 +495,22 @@ private function generateConfig(array $bridge): string {
return $content;
}

protected function validateParts(array $parts): array {
foreach ($parts as $k => $part) {
if (!is_numeric($k)) {
$this->logger->error('User tried to configure a malicious matterbridge setup');
throw new \InvalidArgumentException('Invalid matterbridge parameters');
}
foreach ($part as $key => $value) {
if (preg_match('/["\n]/', $key) || preg_match('/["\n]/', $value)) {
$this->logger->error('User tried to configure a malicious matterbridge setup');
throw new \InvalidArgumentException('Invalid matterbridge parameters');
}
}
}
return $parts;
}

/**
* Remove the scheme from an URL and add port
*
Expand Down
Loading