Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security fixes #534

Merged
merged 4 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ temp/*
# Ignore Mac DS_Store files
.DS_Store
/vendor/
*.diff
*.rej
4 changes: 4 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

IndexIgnore *

Options -Indexes
8 changes: 8 additions & 0 deletions attachments/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
AddHandler cgi-script .php .php2 .php3 .php4 .php5 .php6 .php7 .php8 .php9 .pl .py .js .jsp .asp .htm .html .$

Options -ExecCGI -Indexes

#grant access only if uploading a word-processing or image format
<FilesMatch "(?i)\.(pdf|docx?|rtf|odt?g?|txt|wpd|jpe?g|png|csv|xlsx?|ppt|msg|heic|tiff?|html?|bmp|wps|xps)$">
Require all granted
</FilesMatch>
42 changes: 21 additions & 21 deletions lib/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public static function get($indentifier, $parameters, $misc = 0)

if ($index = 'exportIDs')
{
$parameters['exportIDs'] = unserialize(urldecode($parameters['exportIDs']));
$parameters['exportIDs'] = json_decode(urldecode($parameters['exportIDs']), true);
}
}
}
Expand All @@ -269,7 +269,7 @@ public static function get($indentifier, $parameters, $misc = 0)

if (isset($indentifierParts[2]))
{
$misc = unserialize($indentifierParts[2]);
$misc = json_decode($indentifierParts[2], true);
}

if (!file_exists(sprintf('modules/%s/dataGrids.php', $module)))
Expand Down Expand Up @@ -298,7 +298,7 @@ public static function getFromRequest()
}

$indentifier = $_REQUEST['i'];
$parameters = unserialize($_REQUEST['p']);
$parameters = json_decode($_REQUEST['p'], true);

return self::get($indentifier, $parameters);
}
Expand All @@ -318,7 +318,7 @@ public static function getRecentParamaters($indentifier, $misc = 0)
{
if ($misc != 0)
{
$indentifier .= ':' . serialize($misc);
$indentifier .= ':' . json_encode($misc);
}

return $_SESSION['CATS']->getDataGridParameters($indentifier);
Expand Down Expand Up @@ -352,7 +352,7 @@ public function getMiscArgument()

if (isset($instanceParts[2]))
{
return unserialize($instanceParts[2]);
return json_decode($instanceParts[2], true);
}
else
{
Expand All @@ -375,13 +375,13 @@ public function __construct($instanceName, $parameters, $misc = 0)

if ($misc != 0)
{
$this->_instanceName .= ':'.serialize($misc);
$this->_instanceName .= ':'.json_encode($misc);
}

/* Allow _GET to override the supplied parameters array */
if (isset($_GET['parameters' . $this->_instanceName]))
{
$this->_parameters = unserialize($_GET['parameters' . $this->_instanceName]);
$this->_parameters = json_decode($_GET['parameters' . $this->_instanceName], true);
}
else
{
Expand Down Expand Up @@ -726,7 +726,7 @@ public function drawRowsPerPageSelector()
$newParameterArray['maxResults'] = '<dynamic>';

$requestString = $this->_getUnrelatedRequestString();
$requestString .= '&' . urlencode('parameters' . $this->_instanceName) . '=' . urlencode(serialize($newParameterArray));
$requestString .= '&' . urlencode('parameters' . $this->_instanceName) . '=' . urlencode(json_encode($newParameterArray));

echo sprintf(
'<select id="rowsPerPageSelector%s" onchange="document.location.href=\'%s?%s&dynamicArgument%s=\' + this.value;" class="selectBox">%s',
Expand Down Expand Up @@ -1731,7 +1731,7 @@ public function draw($noOverflow = false)
$data['name'],
$md5InstanceName,
$md5InstanceName,
urlencode(serialize($newParameterArray)),
urlencode(json_encode($newParameterArray)),
urlencode($this->_getUnrelatedRequestString())
);
}
Expand Down Expand Up @@ -2001,7 +2001,7 @@ public function getInnerActionAreaItem($actionTitle, $actionURL, $allowAll = tru
md5($this->_instanceName),
$actionURL,
urlencode($this->_instanceName),
urlencode(serialize($newParameterArraySelected)),
urlencode(json_encode($newParameterArraySelected)),
md5($this->_instanceName),
md5($this->_instanceName)
);
Expand Down Expand Up @@ -2044,14 +2044,14 @@ public function getInnerActionAreaItemPopup($actionTitle, $actionURL, $width, $h
md5($this->_instanceName),
$actionURL,
urlencode($this->_instanceName),
urlencode(serialize($newParameterArraySelected)),
urlencode(json_encode($newParameterArraySelected)),
md5($this->_instanceName),
md5($this->_instanceName),
$width,
$height,
$actionURL,
urlencode($this->_instanceName),
urlencode(serialize($newParameterArrayAll)),
urlencode(json_encode($newParameterArrayAll)),
$width,
$height
);
Expand All @@ -2064,7 +2064,7 @@ public function getInnerActionAreaItemPopup($actionTitle, $actionURL, $width, $h
md5($this->_instanceName),
$actionURL,
urlencode($this->_instanceName),
urlencode(serialize($newParameterArraySelected)),
urlencode(json_encode($newParameterArraySelected)),
md5($this->_instanceName),
md5($this->_instanceName),
$width,
Expand Down Expand Up @@ -2178,7 +2178,7 @@ public function printNavigation($alphaNavigation = false)
$ID, $md5InstanceName,
$ID, $md5InstanceName, //Select Box ID
urlencode($this->_instanceName), //Instance name for ajax function itself
urlencode(serialize($newParameterArray)), //New parameter array
urlencode(json_encode($newParameterArray)), //New parameter array
$_SESSION['CATS']->getCookie(), //Cookie
$newParameterArray['maxResults'], //Used to help determine how many rows per page when changing pages
$this->_currentPage,
Expand All @@ -2189,7 +2189,7 @@ public function printNavigation($alphaNavigation = false)
else
{
$requestString = $this->_getUnrelatedRequestString();
$requestString .= '&' . urlencode('parameters' . $this->_instanceName) . '=' . urlencode(serialize($newParameterArray));
$requestString .= '&' . urlencode('parameters' . $this->_instanceName) . '=' . urlencode(json_encode($newParameterArray));

echo sprintf(
'<span style="%s">Page <input id="pageSelection%s%s" style="width: 32px;" value="%s" onkeypress="document.getElementById(\'pageSelectionButton%s%s\').style.display=\'\';"/> of %s&nbsp;<input id="pageSelectionButton%s%s" type="button" class="button" style="display:none;" value="Go" onclick="document.location.href=\'%s?%s&dynamicArgument%s=\' + ((document.getElementById(\'pageSelection%s%s\').value -1 ) * %s);">%s</span>',
Expand Down Expand Up @@ -2398,7 +2398,7 @@ private function _makeControlLink($newParameterArray, $className = "", $id = "",
$style,
$javascript,
urlencode($this->_instanceName),
urlencode(serialize($newParameterArray)),
urlencode(json_encode($newParameterArray)),
$_SESSION['CATS']->getCookie(),
($className != '' ? 'class="'.$className.'"' : ''),
($id != '' ? 'id="'.$id.'"' : '')
Expand All @@ -2407,7 +2407,7 @@ private function _makeControlLink($newParameterArray, $className = "", $id = "",
else
{
$requestString = $this->_getUnrelatedRequestString();
$requestString .= '&' . urlencode('parameters' . $this->_instanceName) . '=' . urlencode(serialize($newParameterArray));
$requestString .= '&' . urlencode('parameters' . $this->_instanceName) . '=' . urlencode(json_encode($newParameterArray));

return sprintf(
'<a href="%s?%s" style="%s%s" onclick="%s" %s %s>',
Expand Down Expand Up @@ -2545,15 +2545,15 @@ public function _getApplyFilterFunctionDefinition()
echo sprintf(
'populateAjaxPager(\'%s\', \'%s\', \'%s\', document.getElementById(\'filterArea%s\').value);',
urlencode($this->_instanceName),
urlencode(serialize($newParameterArray)), //New parameter array
urlencode(json_encode($newParameterArray)), //New parameter array
$_SESSION['CATS']->getCookie(), //Cookie
$md5InstanceName
);
}
else
{
$requestString = $this->_getUnrelatedRequestString();
$requestString .= '&' . urlencode('parameters' . $this->_instanceName) . '=' . urlencode(serialize($newParameterArray));
$requestString .= '&' . urlencode('parameters' . $this->_instanceName) . '=' . urlencode(json_encode($newParameterArray));
echo 'if (typeof(retainFilterVisible) == \'undefined\') {';

echo sprintf(
Expand All @@ -2572,7 +2572,7 @@ public function _getApplyFilterFunctionDefinition()
$newParameterArray['filterVisible'] = false;

$requestString = $this->_getUnrelatedRequestString();
$requestString .= '&' . urlencode('parameters' . $this->_instanceName) . '=' . urlencode(serialize($newParameterArray));
$requestString .= '&' . urlencode('parameters' . $this->_instanceName) . '=' . urlencode(json_encode($newParameterArray));

echo sprintf(
'document.location.href=\'%s?%s&dynamicArgument%s=\' + urlEncode(document.getElementById(\'filterArea%s\').value);',
Expand All @@ -2589,7 +2589,7 @@ public function _getApplyFilterFunctionDefinition()
$newParameterArray['filter'] = '<dynamic>';

$requestString = $this->_getUnrelatedRequestString();
$requestString .= '&' . urlencode('parameters' . $this->_instanceName) . '=' . urlencode(serialize($newParameterArray));
$requestString .= '&' . urlencode('parameters' . $this->_instanceName) . '=' . urlencode(json_encode($newParameterArray));

echo sprintf(
'document.location.href=\'%s?%s&dynamicArgument%s=\' + urlEncode(document.getElementById(\'filterArea%s\').value);',
Expand Down
11 changes: 10 additions & 1 deletion upload/.htaccess
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
AddType text/plain .html .htm .shtml .php .php3 .phtml .phtm .pl .py .cgi .js
IndexIgnore *
# Disable script execution
AddHandler cgi-script .php .php2 .php3 .php4 .php5 .php6 .php7 .php8 .php9 .pl .py .js .jsp .asp .htm .html .$

Options -ExecCGI -Indexes

#grant access only if uploading a word-processing or image format
<FilesMatch "(?i)\.(pdf|docx?|rtf|odt?g?|txt|wpd|jpe?g|png|csv|xlsx?|ppt|msg|heic|tiff?|html?|bmp|wps|xps)$">
Require all granted
</FilesMatch>