Skip to content

Commit

Permalink
Fixed issue [security] #18866: Label sets can be replaced by any adm…
Browse files Browse the repository at this point in the history
…in user (#3210)

Fixed issue #18868: No CRSF control for delete action of label set
  • Loading branch information
Shnoulle committed Jun 19, 2023
1 parent 01ed5e4 commit 33372e4
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions application/controllers/admin/labels.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,30 +340,38 @@ public function process()
Yii::app()->session['flashmessage'] = gT('Access denied!');
$this->getController()->redirect(App()->createUrl("/admin"));
}
$action = returnGlobal('action');
$action = App()->getRequest()->getParam('action');
Yii::app()->loadHelper('admin/label');
$lid = (int) returnGlobal('lid');

$lid = (int) App()->getRequest()->getpost('lid');
if ($action == "updateset" && Permission::model()->hasGlobalPermission('labelsets', 'update')) {
if (!$lid) {
throw new CHttpException(400);
}
updateset($lid);
Yii::app()->setFlashMessage(gT("Label set properties sucessfully updated."), 'success');
}
if ($action == "insertlabelset" && Permission::model()->hasGlobalPermission('labelsets', 'create')) {
$lid = insertlabelset();
$lid = insertlabelset();
}
if (($action == "modlabelsetanswers" || ($action == "ajaxmodlabelsetanswers")) && Permission::model()->hasGlobalPermission('labelsets', 'update')) {
modlabelsetanswers($lid);
if (!$lid) {
throw new CHttpException(400);
}
modlabelsetanswers($lid);
}
if ($action == "deletelabelset" && Permission::model()->hasGlobalPermission('labelsets', 'delete')) {
if (!$lid) {
throw new CHttpException(400);
}
if (deletelabelset($lid)) {
Yii::app()->setFlashMessage(gT("Label set sucessfully deleted."), 'success');
$lid = 0;
}
}
if ($lid) {
$this->getController()->redirect(array("admin/labels/sa/view/lid/".$lid));
$this->getController()->redirect(array("admin/labels/sa/view/lid/".$lid));
} else {
$this->getController()->redirect(array("admin/labels/sa/view"));
$this->getController()->redirect(array("admin/labels/sa/view"));
}
}

Expand Down Expand Up @@ -438,13 +446,19 @@ public function ajaxSets()
}
$language = trim($language);
if ($lid == 0) {
if (!Permission::model()->hasGlobalPermission('labelsets', 'create')) {
throw new CHttpException(403);
}
$lset = new LabelSet;
$lset->label_name = Yii::app()->getRequest()->getPost('laname');
$lset->languages = $language;
$lset->save();

$lid = getLastInsertID($lset->tableName());
} else {
if (!Permission::model()->hasGlobalPermission('labelsets', 'update')) {
throw new CHttpException(403);
}
Label::model()->deleteAll('lid = :lid', array(':lid' => $lid));
}
$res = 'ok'; //optimistic
Expand Down

0 comments on commit 33372e4

Please sign in to comment.