CVE-2014-125080: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (CWE-22)
value: A vulnerability has been found in frontaccounting faplanet and classified as critical. This vulnerability affects unknown code. The manipulation leads to path traversal. The patch is identified as a5dcd87f46080a624b1a9ad4b0dd035bbd24ac50. It is recommended to apply a patch to fix this issue. VDB-218398 is the identifier assigned to this vulnerability.
CWE description: The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
CVSS v3 base score: 9.8
Published: 2023-01-16T18:15Z
Repository: https://github.com/frontaccounting/faplanet
Language: PHP
Files changed: admin/inst_module.php, includes/hooks.inc
Commit date: 2014-05-21 14:23:16 +0200
Commit message: Fixed directory traversal issues.

Diff: diff --git a/admin/inst_module.php b/admin/inst_module.php
index f92d2c5..77a16cb 100644
--- a/admin/inst_module.php
+++ b/admin/inst_module.php
@@ -40,12 +40,12 @@ function local_extension($id)
 			'type' => 'extension',
 			'path' => 'modules/'.$id,
 			'active' => false
 	);
 
-	if (file_exists($path_to_root.'/modules/'.$id.'/hooks.php')) {
-		include_once($path_to_root.'/modules/'.$id.'/hooks.php');
+	if (file_exists($path_to_root.'/modules/'.clean_file_name($id).'/hooks.php')) {
+		include_once($path_to_root.'/modules/'.clean_file_name($id).'/hooks.php');
 	}
 	$hooks_class = 'hooks_'.$id;
 	if (class_exists($hooks_class, false)) {
 		$hooks = new $hooks_class;
 		$hooks->install_extension(false);
diff --git a/includes/hooks.inc b/includes/hooks.inc
index ab2d2bd..71717fc 100644
--- a/includes/hooks.inc
+++ b/includes/hooks.inc
@@ -223,13 +223,14 @@ function install_hooks()
 	global $path_to_root, $Hooks, $installed_extensions;
 
 	$Hooks = array();
 	
 	// include current language related $Hooks object if locale file exists
-	if (file_exists($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc"))
+	$lang_code  = clean_file_name($_SESSION['language']->code);
+	if (file_exists($path_to_root . "/lang/" . $lang_code . "/locale.inc"))
 	{
-		include_once($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc");
+		include_once($path_to_root . "/lang/" . $lang_code . "/locale.inc");
 		$code = $_SESSION['language']->code;
 		$hook_class = 'hooks_'.$code;
 		$Hooks[$code] = new $hook_class;
 		unset($code, $hook_class);
 	}

Vulnerable code: 	if (file_exists($path_to_root.'/modules/'.$id.'/hooks.php')) {
		include_once($path_to_root.'/modules/'.$id.'/hooks.php');
	if (file_exists($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc"))
		include_once($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc");
Fixed code: 	if (file_exists($path_to_root.'/modules/'.clean_file_name($id).'/hooks.php')) {
		include_once($path_to_root.'/modules/'.clean_file_name($id).'/hooks.php');
	$lang_code  = clean_file_name($_SESSION['language']->code);
	if (file_exists($path_to_root . "/lang/" . $lang_code . "/locale.inc"))
		include_once($path_to_root . "/lang/" . $lang_code . "/locale.inc");