diff --git a/objects/security.php b/objects/security.php index f6ea64159..aba33255d 100644 --- a/objects/security.php +++ b/objects/security.php @@ -1,98 +1,98 @@ $value) { $_FILES[$key]['name'] = preg_replace('/[^a-z0-9.,()+& #-]/i', '', cleanString($_FILES[$key]['name'])); } } $scanVars = array('GET', 'POST', 'REQUEST'); foreach ($scanVars as $value) { eval('$scanThis = &$_' . $value.';'); if (!empty($scanThis['base64Url'])) { if (!filter_var(base64_decode($scanThis['base64Url']), FILTER_VALIDATE_URL)) { _error_log('base64Url attack ' . json_encode($_SERVER), AVideoLog::$SECURITY); exit; } } foreach ($filterURL as $key => $value) { if (!empty($scanThis[$value])) { if (!filter_var($scanThis[$value], FILTER_VALIDATE_URL) || !preg_match("/^http.*/i", $scanThis[$value])) { //_error_log($value.' attack ' . json_encode($_SERVER), AVideoLog::$SECURITY); unset($scanThis[$value]); } else { $scanThis[$value] = str_replace(array("'", '"', "<", ">"), array("", "", "", ""), $scanThis[$value]); } } } foreach ($securityRemoveNonChars as $value) { if (!empty($scanThis[$value])) { if (is_string($scanThis[$value])) { $scanThis[$value] = str_replace('/[^a-z0-9./]/i', '', trim($scanThis[$value])); } elseif (is_array($scanThis[$value])) { foreach ($scanThis[$value] as $key => $value2) { if (is_string($scanThis[$value][$key])) { $scanThis[$value][$key] = str_replace('/[^a-z0-9./]/i', '', trim($scanThis[$value][$key])); } } } } } foreach ($securityRemoveSingleQuotes as $value) { if (!empty($scanThis[$value])) { if (is_string($scanThis[$value])) { $scanThis[$value] = str_replace("'", "", trim($scanThis[$value])); } elseif (is_array($scanThis[$value])) { foreach ($scanThis[$value] as $key => $value2) { if (is_string($scanThis[$value][$key])) { $scanThis[$value][$key] = str_replace("'", "", trim($scanThis[$value][$key])); } } } } } // all variables with _id at the end will be forced to be interger foreach ($scanThis as $key => $value) { if(preg_match('/_id$/i', $key)){ $scanThis[$key] = intval($value); } } foreach ($securityFilterInt as $value) { if (!empty($scanThis[$value])) { if (strtolower($scanThis[$value]) === "true") { $scanThis[$value] = 1; } else { $scanThis[$value] = intval($scanThis[$value]); } } } foreach ($securityFilter as $value) { if (!empty($scanThis[$value])) { - $scanThis[$value] = str_replace(array("--", "'", '"', """, "'", "%23", "%5c", "#"), array('', '', '', '', '', '', '', ''), xss_esc($scanThis[$value])); + $scanThis[$value] = str_replace(array('\\', "--", "'", '"', """, "'", "%23", "%5c", "#"), array('', '', '', '', '', '', '', '', ''), xss_esc($scanThis[$value])); } } if (!empty($scanThis['sort']) && is_array($scanThis['sort'])) { foreach ($scanThis['sort'] as $key => $value) { $scanThis['sort'][xss_esc($key)] = strcasecmp($value, "ASC") === 0 ? "ASC" : "DESC"; } } } \ No newline at end of file