Headline
CVE-2022-39291: Add permissions checking to API/Logs. Fixes unprivileged user being t… · ZoneMinder/zoneminder@34ffd92
ZoneMinder is a free, open source Closed-circuit television software application. Affected versions of zoneminder are subject to a vulnerability which allows users with “View” system permissions to inject new data into the logs stored by Zoneminder. This was observed through an HTTP POST request containing log information to the “/zm/index.php” endpoint. Submission is not rate controlled and could affect database performance and/or consume all storage resources. Users are advised to upgrade. There are no known workarounds for this issue.
@@ -20,6 +20,17 @@ class LogsController extends AppController {
‘paramType’ => ‘querystring’
);
public function beforeFilter() {
parent::beforeFilter();
global $user;
# We already tested for auth in appController, so we just need to test for specific permission
$canView = (!$user) || ($user[‘System’] != ‘None’);
if (!$canView) {
throw new UnauthorizedException(__(‘Insufficient Privileges’));
return;
}
}
/**
* index method
*
@@ -54,6 +65,12 @@ public function view($id = null) {
* @return void
*/
public function add() {
global $user;
$canAdd = (!$user) || (($user[‘System’] == ‘Edit’) || ZM_LOG_INJECT);
if (!$canAdd) {
throw new UnauthorizedException(__(‘Insufficient privileges’));
return;
}
if ($this->request->is(‘post’)) {
$this->Log->create();
if ($this->Log->save($this->request->data)) {
@@ -70,6 +87,13 @@ public function add() {
* @return void
*/
public function edit($id = null) {
global $user;
$canEdit = (!$user) || ($user[‘System’] == ‘Edit’);
if (!$canEdit) {
throw new UnauthorizedException(__(‘Insufficient privileges’));
return;
}
if (!$this->Log->exists($id)) {
throw new NotFoundException(__(‘Invalid log’));
}
@@ -91,6 +115,11 @@ public function edit($id = null) {
* @return void
*/
public function delete($id = null) {
$canDelete = (!$user) || ($user[‘System’] == ‘Edit’);
if (!$canDelete) {
throw new UnauthorizedException(__(‘Insufficient privileges’));
return;
}
$this->Log->id = $id;
if (!$this->Log->exists()) {
throw new NotFoundException(__(‘Invalid log’));