Skip to content

Commit 1e6dc20

Browse files
author
Daniel Neto
committed
fix: Add ownership verification for editing and managing playlists in add.json.php
https://github.com/WWBN/AVideo/security/advisories/GHSA-2rm7-j397-3fqg#event-597441
1 parent 37ea4f6 commit 1e6dc20

File tree

1 file changed

+46
-33
lines changed

1 file changed

+46
-33
lines changed
Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,46 @@
1-
<?php
2-
header('Content-Type: application/json');
3-
require_once '../../../../videos/configuration.php';
4-
require_once $global['systemRootPath'] . 'plugin/PlayLists/Objects/Playlists_schedules.php';
5-
$obj = new stdClass();
6-
$obj->error = true;
7-
$obj->msg = "";
8-
9-
$plugin = AVideoPlugin::loadPluginIfEnabled('PlayLists');
10-
if (empty($plugin)) {
11-
forbiddenPage(__("The plugin is disabled"));
12-
}
13-
14-
if (!User::canStream()) {
15-
forbiddenPage(__("You cannot livestream"));
16-
}
17-
18-
$o = new Playlists_schedules(@$_POST['id']);
19-
$o->setPlaylists_id($_POST['playlists_id']);
20-
$o->setName($_POST['name']);
21-
$o->setDescription($_POST['description']);
22-
//$o->setStatus($_POST['status']);
23-
$o->setLoop($_POST['loop']);
24-
$o->setStart_datetime($_POST['start_datetime']);
25-
$o->setFinish_datetime($_POST['finish_datetime']);
26-
$o->setRepeat($_POST['repeat']);
27-
$o->setParameters($_POST['parameters']);
28-
29-
if($id = $o->save()){
30-
$obj->error = false;
31-
}
32-
33-
echo json_encode($obj);
1+
<?php
2+
header('Content-Type: application/json');
3+
require_once '../../../../videos/configuration.php';
4+
require_once $global['systemRootPath'] . 'plugin/PlayLists/Objects/Playlists_schedules.php';
5+
$obj = new stdClass();
6+
$obj->error = true;
7+
$obj->msg = "";
8+
9+
$plugin = AVideoPlugin::loadPluginIfEnabled('PlayLists');
10+
if (empty($plugin)) {
11+
forbiddenPage(__("The plugin is disabled"));
12+
}
13+
14+
if (!User::canStream()) {
15+
forbiddenPage(__("You cannot livestream"));
16+
}
17+
18+
// Verify ownership of the existing schedule when editing
19+
if (!empty($_POST['id'])) {
20+
$existing = new Playlists_schedules(intval($_POST['id']));
21+
if (!PlayLists::canManagePlaylist($existing->getPlaylists_id())) {
22+
forbiddenPage(__("You cannot modify this schedule"));
23+
}
24+
}
25+
26+
// Verify ownership of the target playlist
27+
if (!PlayLists::canManagePlaylist($_POST['playlists_id'])) {
28+
forbiddenPage(__("You cannot manage this playlist"));
29+
}
30+
31+
$o = new Playlists_schedules(@$_POST['id']);
32+
$o->setPlaylists_id($_POST['playlists_id']);
33+
$o->setName($_POST['name']);
34+
$o->setDescription($_POST['description']);
35+
//$o->setStatus($_POST['status']);
36+
$o->setLoop($_POST['loop']);
37+
$o->setStart_datetime($_POST['start_datetime']);
38+
$o->setFinish_datetime($_POST['finish_datetime']);
39+
$o->setRepeat($_POST['repeat']);
40+
$o->setParameters($_POST['parameters']);
41+
42+
if($id = $o->save()){
43+
$obj->error = false;
44+
}
45+
46+
echo json_encode($obj);

0 commit comments

Comments
 (0)