Browse code

header.php, search.php, includes/- corefunctions.php, upload_class.php: Security - local file inclusion/directory traversal and encode echoed terms patches - from @ariadoss

Clarissa Walker authored on 2026/10/27 12:12:37
Showing 4 changed files
... ...
@@ -145,7 +145,7 @@ $ageconsent = false; $viewed = array();
145 145
 require_once("includes/get_session_vars.php");
146 146
 
147 147
 if(isset($_GET['skin'])) {
148
-	$siteskin = $_GET['skin'];
148
+	$siteskin = basename($_GET['skin']);
149 149
 	$_SESSION[SITEKEY."_skin"] = $siteskin;
150 150
 }
151 151
 
... ...
@@ -200,7 +200,7 @@ if(isset($_SESSION[SITEKEY."_viewed"])) $viewed = $_SESSION[SITEKEY."_viewed"];
200 200
 if(isset($_GET['ageconsent'])) $_SESSION[SITEKEY."_ageconsent"] = 1;
201 201
 if(isset($_GET['warning'])) $_SESSION[SITEKEY."_warned"][$_GET['warning']] = 1;
202 202
 
203
-
203
+$siteskin = basename((string)$siteskin);
204 204
 if(is_dir(_BASEDIR."skins/$siteskin")) $skindir = _BASEDIR."skins/$siteskin";
205 205
 else if(is_dir(_BASEDIR."skins/".$settings['skin'])) $skindir = _BASEDIR."skins/".$defaultskin;
206 206
 else $skindir = _BASEDIR."default_tpls";
... ...
@@ -574,8 +574,8 @@ function search($storyquery, $countquery, $pagelink = "search.php?", $pagetitle
574 574
 		$termArray = array_merge($_GET, $_POST);
575 575
 		$terms = array();
576 576
 		foreach($termArray as $term => $value) {
577
-			if($term == "submit" || $term == "go" || $term == "offset" || ($term != "complete" &&empty($value))) continue;
578
-			$terms[] = "$term=".(is_array($value) ? implode(",", $value) : $value);
577
+			if($term == "submit" || $term == "go" || $term == "offset" || ($term != "complete" && empty($value))) continue;
578
+			$terms[] = "$term=".(is_array($value) ? implode(",", array_map('htmlspecialchars', $value)) : htmlspecialchars($value, ENT_QUOTES));
579 579
 		}
580 580
 		$terms = implode("&", $terms);
581 581
 		$terms .= "&";
... ...
@@ -57,7 +57,7 @@ class file_upload {
57 57
 			sleep(3);
58 58
 			$name = $name.$this->get_extension($this->the_file);
59 59
 		} else {
60
-			$name = str_replace(" ", "_", $this->the_file); // space will result in problems on linux systems
60
+			$name = basename(str_replace("\\", "/", str_replace(" ", "_", $this->the_file))); // space will result in problems on linux systems
61 61
 		}
62 62
 		return $name;
63 63
 	}
... ...
@@ -236,7 +236,7 @@ if(isset($_POST['submit']) || isset($_GET['offset'])) {
236 236
 	$termsList = array();
237 237
 	foreach($termArray as $term => $value) {
238 238
 		if($term == "submit" || $term == "wordhigh" || $term == "wordlow" || empty($value) || $term == "formname" || $term == "searchtype") continue;
239
-		$termsList[$term] = "$term=".(is_array($value) ? implode(",", $value) : $value);
239
+		$termsList[$term] = "$term=".(is_array($value) ? implode(",", array_map('htmlspecialchars', $value)) : htmlspecialchars($value, ENT_QUOTES));
240 240
 	}
241 241
 	$terms = implode("&", $termsList);
242 242
 	if(!empty($scountquery)) {