CVE-2022-0269 (published 2022-01-24T12:15Z)

Cross-Site Request Forgery (CSRF) in Packagist yetiforce/yetiforce-crm prior to 6.3.0.

Severity: MEDIUM
CVSS v2 base score: 6.0 (AV:N/AC:M/Au:S/C:P/I:P/A:P)
CVSS v3 base score: 8.0, HIGH (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-352
cwe_name: Cross-Site Request Forgery (CSRF)
description: The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
extended_description: When a web server is designed to receive a request from a client without any mechanism for verifying that it was intentionally sent, then it might be possible for an attacker to trick a client into making an unintentional request to the web server which will be treated as an authentic request. This can be done via a URL, image load, XMLHttpRequest, etc. and can result in exposure of data or unintended code execution.
         

Fix information:
repo_url: https://github.com/yetiforcecompany/yetiforcecrm
commit_details: repo_url: https://github.com/yetiforcecompany/yetiforcecrm
author: Radosław Skrzypczak
author_date: 2022-01-18 12:25:46+01:00
msg: Improved CSRF protection
repository: repo_url: https://github.com/yetiforcecompany/yetiforcecrm
repo_name: YetiForceCompany/YetiForceCRM
description: Our team created for you one of the most innovative CRM systems that supports mainly business processes and allows for customization according to your needs. Be ahead of your competition and implement YetiForce!
repo_language: PHP
owner: yetiforcecompany
file_changes: filename: Action.php
change_type: ModificationType.MODIFY
diff: @@ -7,6 +7,7 @@
  * @copyright YetiForce Sp. z o.o
  * @license   YetiForce Public License 4.0 (licenses/LicenseEN.txt or yetiforce.com)
  * @author    Mariusz Krzaczkowski <m.krzaczkowski@yetiforce.com>
+ * @author    Radosław Skrzypczak <r.skrzypczak@yetiforce.com>
  */
 
 namespace App\Controller;
@@ -16,9 +17,6 @@ namespace App\Controller;
  */
 abstract class Action extends Base
 {
-	/** {@inheritdoc} */
-	public $csrfActive = false;
-
 	/**
 	 * Process action.
 	 *

programming_language: PHP
filename: Base.php
change_type: ModificationType.MODIFY
diff: @@ -7,6 +7,7 @@
  * @copyright YetiForce Sp. z o.o
  * @license   YetiForce Public License 4.0 (licenses/LicenseEN.txt or yetiforce.com)
  * @author    Mariusz Krzaczkowski <m.krzaczkowski@yetiforce.com>
+ * @author    Radosław Skrzypczak <r.skrzypczak@yetiforce.com>
  */
 
 namespace App\Controller;
@@ -18,12 +19,6 @@ abstract class Base
 {
 	/** @var \App\Headers Headers instance. */
 	public $headers;
-	/**
-	 * CSRF is active?.
-	 *
-	 * @var bool
-	 */
-	public $csrfActive = true;
 
 	/**
 	 * Activated language locale.
@@ -31,12 +26,6 @@ abstract class Base
 	 * @var bool
 	 */
 	protected static $activatedLocale = false;
-	/**
-	 * Activated csrf.
-	 *
-	 * @var bool
-	 */
-	protected static $activatedCsrf = false;
 
 	/**
 	 * Constructor.
@@ -48,15 +37,9 @@ abstract class Base
 			\App\Language::initLocale();
 			self::$activatedLocale = true;
 		}
-		if (!self::$activatedCsrf) {
-			if ($this->csrfActive && \App\Config::security('csrfActive')) {
-				require_once 'config/csrf_config.php';
-				\CsrfMagic\Csrf::init();
-				$this->csrfActive = true;
-			} else {
-				$this->csrfActive = false;
-			}
-			self::$activatedCsrf = true;
+		if (\App\Config::security('csrfActive')) {
+			require_once 'config/csrf_config.php';
+			\CsrfMagic\Csrf::init();
 		}
 	}
 

programming_language: PHP
filename: Request.php
change_type: ModificationType.MODIFY
diff: @@ -710,8 +710,8 @@ class Request
 			throw new \App\Exceptions\Csrf('Invalid request - validate Write Access');
 		}
 		$this->validateReadAccess();
-		if (class_exists('CSRFConfig') && !\CsrfMagic\Csrf::check(false)) {
-			throw new \App\Exceptions\Csrf('Unsupported request');
+		if (\App\Config::security('csrfActive')) {
+			\CsrfMagic\Csrf::check();
 		}
 	}
 

programming_language: PHP
filename: ConfigTemplates.php
change_type: ModificationType.MODIFY
diff: @@ -1154,6 +1154,12 @@ return [
 			'validation' => '\App\Validator::bool',
 			'sanitization' => '\App\Purifier::bool'
 		],
+		'csrfLifetimeToken' => [
+			'default' => 28800,
+			'description' => 'Default expire time of CSRF token in seconds',
+			'validation' => '\App\Validator::naturalNumber',
+			'sanitization' => '\App\Purifier::naturalNumber'
+		],
 		'csrfFrameBreaker' => [
 			'default' => true,
 			'description' => 'Enable verified frame protection, used in CSRF',

programming_language: PHP
filename: Security.php
change_type: ModificationType.MODIFY
diff: @@ -151,6 +151,9 @@ class Security
 	/** Enable CSRF protection */
 	public static $csrfActive = true;
 
+	/** Default expire time of CSRF token in seconds */
+	public static $csrfLifetimeToken = 28800;
+
 	/** Enable verified frame protection, used in CSRF */
 	public static $csrfFrameBreaker = true;
 

programming_language: Java
filename: csrf_config.php
change_type: ModificationType.MODIFY
diff: @@ -6,6 +6,7 @@
  * The Initial Developer of the Original Code is vtiger.
  * Portions created by vtiger are Copyright (C) vtiger.
  * All Rights Reserved.
+ * Contributor(s): YetiForce Sp. z o.o
  * ****************************************************************************** */
 
 class CSRFConfig
@@ -16,14 +17,15 @@ class CSRFConfig
 	public static function startup()
 	{
 		//Override the default expire time of token
-		\CsrfMagic\Csrf::$expires = 259200;
+		\CsrfMagic\Csrf::$expires = \App\Config::security('csrfLifetimeToken', 7200);
 		\CsrfMagic\Csrf::$callback = function ($tokens) {
-			throw new \App\Exceptions\AppException('Invalid request - Response For Illegal Access', 403);
+			throw new \App\Exceptions\Csrf('Invalid request - Response For Illegal Access', 403);
 		};
 		$js = 'vendor/yetiforce/csrf-magic/src/Csrf.min.js';
 		if (!IS_PUBLIC_DIR) {
 			$js = 'public_html/' . $js;
 		}
+		\CsrfMagic\Csrf::$defer = true;
 		\CsrfMagic\Csrf::$dirSecret = __DIR__;
 		\CsrfMagic\Csrf::$rewriteJs = $js;
 		\CsrfMagic\Csrf::$cspToken = \App\Session::get('CSP_TOKEN');

programming_language: PHP
filename: version.php
change_type: ModificationType.MODIFY
diff: @@ -1,7 +1,7 @@
 <?php
 
 return [
-	'appVersion' => '6.3.42',
-	'patchVersion' => '2022.01.17',
+	'appVersion' => '6.3.43',
+	'patchVersion' => '2022.01.18',
 	'lib_roundcube' => '0.2.10',
 ];

programming_language: PHP
filename: WebUI.php
change_type: ModificationType.MODIFY
diff: @@ -168,9 +168,7 @@ class Vtiger_WebUI extends Vtiger_EntryPoint
 				\App\Log::error("HandlerClass: $handlerClass", 'Loader');
 				throw new \App\Exceptions\AppException('LBL_HANDLER_NOT_FOUND', 405);
 			}
-			if ($handler->csrfActive) {
-				$handler->validateRequest($request);
-			}
+			$handler->validateRequest($request);
 			if ($handler->loginRequired() && $this->checkLogin($request)) {
 				return true;
 			}

programming_language: PHP
filename: Index.php
change_type: ModificationType.MODIFY
diff: @@ -14,9 +14,6 @@ class Install_Index_View extends \App\Controller\View\Base
 {
 	use \App\Controller\ExposeMethod;
 
-	/** {@inheritdoc} */
-	public $csrfActive = false;
-
 	/**
 	 * @var bool
 	 */

programming_language: PHP
filename: Login.php
change_type: ModificationType.MODIFY
diff: @@ -11,9 +11,6 @@
 
 class Users_Login_View extends \App\Controller\View\Base
 {
-	/** {@inheritdoc} */
-	public $csrfActive = false;
-
 	/** {@inheritdoc} */
 	public function __construct()
 	{

programming_language: PHP