Skip to content

Commit

Permalink
sec(App) validate CSRF on delete action
Browse files Browse the repository at this point in the history
  • Loading branch information
joebordes committed Aug 14, 2021
1 parent f8a0221 commit 42369cf
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
19 changes: 19 additions & 0 deletions include/utils/Request.php
Expand Up @@ -194,6 +194,25 @@ protected function validateCSRF() {
}
}

public static function validateRequest($die = true, $msg = true) {
$request = new Vtiger_Request($_REQUEST);
try {
$request->validateWriteAccess();
} catch (\Throwable $th) {
if ($msg) {
require_once 'Smarty_setup.php';
echo '<br><br>';
$smarty = new vtigerCRM_Smarty();
$smarty->assign('csrfWarning', getTranslatedString($th->getMessage()));
$smarty->assign('csrfReload', getTranslatedString('csrf_reload'));
$smarty->display('csrf-warning.tpl');
}
if ($die) {
die();
}
}
}

public static function get_ip() {
$headers = $_SERVER;
// check for shared internet/ISP IP
Expand Down
2 changes: 1 addition & 1 deletion modules/Calendar4You/Delete.php
Expand Up @@ -10,7 +10,7 @@
require_once 'modules/Calendar4You/CalendarUtils.php';

global $currentModule, $current_user;

Vtiger_Request::validateRequest();
$Calendar4You = new Calendar4You();

$Calendar4You->GetDefPermission($current_user);
Expand Down
2 changes: 1 addition & 1 deletion modules/PriceBooks/Delete.php
Expand Up @@ -8,8 +8,8 @@
* All Rights Reserved.
************************************************************************************/
global $currentModule;
Vtiger_Request::validateRequest();
$focus = CRMEntity::getInstance($currentModule);

$record = vtlib_purify($_REQUEST['record']);
$module = urlencode(vtlib_purify($_REQUEST['module']));
$return_module = vtlib_purify($_REQUEST['return_module']);
Expand Down
2 changes: 1 addition & 1 deletion modules/ProductComponent/Delete.php
Expand Up @@ -8,8 +8,8 @@
* All Rights Reserved.
************************************************************************************/
global $currentModule;
Vtiger_Request::validateRequest();
$focus = CRMEntity::getInstance($currentModule);

$record = vtlib_purify($_REQUEST['record']);
$module = urlencode(vtlib_purify($_REQUEST['module']));
$return_module = vtlib_purify($_REQUEST['return_module']);
Expand Down
2 changes: 1 addition & 1 deletion modules/Products/Delete.php
Expand Up @@ -8,8 +8,8 @@
* All Rights Reserved.
************************************************************************************/
global $currentModule;
Vtiger_Request::validateRequest();
$focus = CRMEntity::getInstance($currentModule);

$record = vtlib_purify($_REQUEST['record']);
$module = urlencode(vtlib_purify($_REQUEST['module']));
$return_module = vtlib_purify($_REQUEST['return_module']);
Expand Down
2 changes: 1 addition & 1 deletion modules/Vtiger/Delete.php
Expand Up @@ -8,8 +8,8 @@
* All Rights Reserved.
************************************************************************************/
global $currentModule;
Vtiger_Request::validateRequest();
$focus = CRMEntity::getInstance($currentModule);

$record = vtlib_purify($_REQUEST['record']);
$module = urlencode(vtlib_purify($_REQUEST['module']));
$return_module = vtlib_purify($_REQUEST['return_module']);
Expand Down

0 comments on commit 42369cf

Please sign in to comment.