From ba068af6e707fbcf118ff4e8d00639aeab82f508 Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Wed, 1 Feb 2023 15:41:29 +0000 Subject: [PATCH] Fixed issue [security] #18514 : no CSRF control when delete token table (#2750) Dev: move to a post action forum, validate with getPost --- application/controllers/admin/Tokens.php | 44 +++++++------- .../token/afterDeleteParticipantsTable.php | 9 +-- .../admin/token/deleteParticipantsTable.php | 59 ++++++++++--------- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/application/controllers/admin/Tokens.php b/application/controllers/admin/Tokens.php index 97e7c1a5d75..699cba3e699 100644 --- a/application/controllers/admin/Tokens.php +++ b/application/controllers/admin/Tokens.php @@ -2365,34 +2365,32 @@ public function kill(int $iSurveyId) $aData['topBar']['hide'] = true; - if (!Yii::app()->request->getQuery('ok')) { + if (!Yii::app()->request->getPost('ok')) { $aData['sidemenu']['state'] = false; $aData['backupTableName'] = $newtableDisplay; - $this->renderWrappedTemplate('token', 'deleteParticipantsTable', $aData); - } else /* The user has confirmed they want to delete the tokens table */ - { - Yii::app()->db->createCommand()->renameTable("{{{$oldtable}}}", "{{{$newtable}}}"); - - $archivedTokenSettings = new ArchivedTableSettings(); - $archivedTokenSettings->survey_id = $iSurveyId; - $archivedTokenSettings->user_id = $userID; - $archivedTokenSettings->tbl_name = $newtable; - $archivedTokenSettings->tbl_type = 'token'; - $archivedTokenSettings->created = $DBDate; - $archivedTokenSettings->properties = $aData['thissurvey']['tokenencryptionoptions']; - $archivedTokenSettings->attributes = json_encode($aData['thissurvey']['attributedescriptions']); - $archivedTokenSettings->save(); - - //Remove any survey_links to the CPDB - SurveyLink::model()->deleteLinksBySurvey($iSurveyId); + return; + } + /* The user has confirmed they want to delete the tokens table */ + Yii::app()->db->createCommand()->renameTable("{{{$oldtable}}}", "{{{$newtable}}}"); - $aData['sidemenu']['state'] = false; - $aData['backupTableName'] = $newtableDisplay; - $this->renderWrappedTemplate('token', 'afterDeleteParticipantsTable', $aData); + $archivedTokenSettings = new ArchivedTableSettings(); + $archivedTokenSettings->survey_id = $iSurveyId; + $archivedTokenSettings->user_id = $userID; + $archivedTokenSettings->tbl_name = $newtable; + $archivedTokenSettings->tbl_type = 'token'; + $archivedTokenSettings->created = $DBDate; + $archivedTokenSettings->properties = $aData['thissurvey']['tokenencryptionoptions']; + $archivedTokenSettings->attributes = json_encode($aData['thissurvey']['attributedescriptions']); + $archivedTokenSettings->save(); - LimeExpressionManager::SetDirtyFlag(); // so that knows that survey participants tables have changed - } + //Remove any survey_links to the CPDB + SurveyLink::model()->deleteLinksBySurvey($iSurveyId); + + $aData['sidemenu']['state'] = false; + $aData['backupTableName'] = $newtableDisplay; + $this->renderWrappedTemplate('token', 'afterDeleteParticipantsTable', $aData); + LimeExpressionManager::SetDirtyFlag(); // so that knows that survey participants tables have changed } /** diff --git a/application/views/admin/token/afterDeleteParticipantsTable.php b/application/views/admin/token/afterDeleteParticipantsTable.php index a83c2c5969d..33798ecb992 100644 --- a/application/views/admin/token/afterDeleteParticipantsTable.php +++ b/application/views/admin/token/afterDeleteParticipantsTable.php @@ -18,13 +18,10 @@

Survey participants and click on the 'Switch to closed-access mode' button."); ?>

- ', - '_top'" /> + href="createUrl("surveyAdministration/view/surveyid/{$iSurveyId}"); ?>" + > diff --git a/application/views/admin/token/deleteParticipantsTable.php b/application/views/admin/token/deleteParticipantsTable.php index 510b079d479..24ad4ec737b 100644 --- a/application/views/admin/token/deleteParticipantsTable.php +++ b/application/views/admin/token/deleteParticipantsTable.php @@ -7,33 +7,38 @@
+ $surveyid), + 'post', + array('id' => 'deletetokentable', 'name' => 'deletetokentable') + ); ?>

- -

- -

- -
- -

- Survey participants and click on the 'Switch to closed-access mode' button."); ?> -

-

- ', - '_top')" /> - ', - '_top')" /> - + +

+ +

+ +
+ +

+ Survey participants and click on the 'Switch to closed-access mode' button."); ?> +
+

+ + " + > + +
-
\ No newline at end of file + +